Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
| 5 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 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: |
| 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | *****************************************************************************/ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/module.h> |
| 31 | #include <linux/etherdevice.h> |
| 32 | #include <linux/sched.h> |
| 33 | #include <linux/slab.h> |
| 34 | #include <net/mac80211.h> |
| 35 | |
| 36 | #include "iwl-eeprom.h" |
| 37 | #include "iwl-dev.h" |
| 38 | #include "iwl-debug.h" |
| 39 | #include "iwl-core.h" |
| 40 | #include "iwl-io.h" |
| 41 | #include "iwl-power.h" |
| 42 | #include "iwl-sta.h" |
| 43 | #include "iwl-helpers.h" |
| 44 | |
| 45 | |
| 46 | MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); |
| 47 | MODULE_VERSION(IWLWIFI_VERSION); |
| 48 | MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); |
| 49 | MODULE_LICENSE("GPL"); |
| 50 | |
| 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 | */ |
John W. Linville | ef33417 | 2011-02-25 15:51:01 -0500 | [diff] [blame] | 67 | static bool bt_coex_active = true; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 68 | module_param(bt_coex_active, bool, S_IRUGO); |
| 69 | MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); |
| 70 | |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 71 | u32 il_debug_level; |
| 72 | EXPORT_SYMBOL(il_debug_level); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 73 | |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 74 | const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
| 75 | EXPORT_SYMBOL(il_bcast_addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 76 | |
| 77 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 78 | /* This function both allocates and initializes hw and il. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 79 | struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 80 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 81 | struct il_priv *il; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 82 | /* mac80211 allocates memory for this device instance, including |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 83 | * space for this driver's ilate structure */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 84 | struct ieee80211_hw *hw; |
| 85 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 86 | hw = ieee80211_alloc_hw(sizeof(struct il_priv), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 87 | cfg->ops->ieee80211_ops); |
| 88 | if (hw == NULL) { |
| 89 | pr_err("%s: Can not allocate network device\n", |
| 90 | cfg->name); |
| 91 | goto out; |
| 92 | } |
| 93 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 94 | il = hw->priv; |
| 95 | il->hw = hw; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 96 | |
| 97 | out: |
| 98 | return hw; |
| 99 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 100 | EXPORT_SYMBOL(il_alloc_all); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 101 | |
| 102 | #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ |
| 103 | #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 104 | static void il_init_ht_hw_capab(const struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 105 | struct ieee80211_sta_ht_cap *ht_info, |
| 106 | enum ieee80211_band band) |
| 107 | { |
| 108 | u16 max_bit_rate = 0; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 109 | u8 rx_chains_num = il->hw_params.rx_chains_num; |
| 110 | u8 tx_chains_num = il->hw_params.tx_chains_num; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 111 | |
| 112 | ht_info->cap = 0; |
| 113 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
| 114 | |
| 115 | ht_info->ht_supported = true; |
| 116 | |
| 117 | ht_info->cap |= IEEE80211_HT_CAP_SGI_20; |
| 118 | max_bit_rate = MAX_BIT_RATE_20_MHZ; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 119 | if (il->hw_params.ht40_channel & BIT(band)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 120 | ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 121 | ht_info->cap |= IEEE80211_HT_CAP_SGI_40; |
| 122 | ht_info->mcs.rx_mask[4] = 0x01; |
| 123 | max_bit_rate = MAX_BIT_RATE_40_MHZ; |
| 124 | } |
| 125 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 126 | if (il->cfg->mod_params->amsdu_size_8K) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 127 | ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; |
| 128 | |
| 129 | ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; |
| 130 | ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; |
| 131 | |
| 132 | ht_info->mcs.rx_mask[0] = 0xFF; |
| 133 | if (rx_chains_num >= 2) |
| 134 | ht_info->mcs.rx_mask[1] = 0xFF; |
| 135 | if (rx_chains_num >= 3) |
| 136 | ht_info->mcs.rx_mask[2] = 0xFF; |
| 137 | |
| 138 | /* Highest supported Rx data rate */ |
| 139 | max_bit_rate *= rx_chains_num; |
| 140 | WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK); |
| 141 | ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); |
| 142 | |
| 143 | /* Tx MCS capabilities */ |
| 144 | ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; |
| 145 | if (tx_chains_num != rx_chains_num) { |
| 146 | ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; |
| 147 | ht_info->mcs.tx_params |= ((tx_chains_num - 1) << |
| 148 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 153 | * il_init_geos - Initialize mac80211's geo/channel info based from eeprom |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 154 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 155 | int il_init_geos(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 156 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 157 | struct il_channel_info *ch; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 158 | struct ieee80211_supported_band *sband; |
| 159 | struct ieee80211_channel *channels; |
| 160 | struct ieee80211_channel *geo_ch; |
| 161 | struct ieee80211_rate *rates; |
| 162 | int i = 0; |
Stanislaw Gruszka | 332704a | 2011-04-13 10:56:51 +0200 | [diff] [blame] | 163 | s8 max_tx_power = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 164 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 165 | if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || |
| 166 | il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 167 | D_INFO("Geography modes already initialized.\n"); |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 168 | set_bit(S_GEO_CONFIGURED, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | channels = kzalloc(sizeof(struct ieee80211_channel) * |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 173 | il->channel_count, GFP_KERNEL); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 174 | if (!channels) |
| 175 | return -ENOMEM; |
| 176 | |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 177 | rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 178 | GFP_KERNEL); |
| 179 | if (!rates) { |
| 180 | kfree(channels); |
| 181 | return -ENOMEM; |
| 182 | } |
| 183 | |
| 184 | /* 5.2GHz channels start after the 2.4GHz channels */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 185 | sband = &il->bands[IEEE80211_BAND_5GHZ]; |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 186 | sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 187 | /* just OFDM */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 188 | sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 189 | sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 190 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 191 | if (il->cfg->sku & IL_SKU_N) |
| 192 | il_init_ht_hw_capab(il, &sband->ht_cap, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 193 | IEEE80211_BAND_5GHZ); |
| 194 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 195 | sband = &il->bands[IEEE80211_BAND_2GHZ]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 196 | sband->channels = channels; |
| 197 | /* OFDM & CCK */ |
| 198 | sband->bitrates = rates; |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 199 | sband->n_bitrates = RATE_COUNT_LEGACY; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 200 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 201 | if (il->cfg->sku & IL_SKU_N) |
| 202 | il_init_ht_hw_capab(il, &sband->ht_cap, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 203 | IEEE80211_BAND_2GHZ); |
| 204 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 205 | il->ieee_channels = channels; |
| 206 | il->ieee_rates = rates; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 207 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 208 | for (i = 0; i < il->channel_count; i++) { |
| 209 | ch = &il->channel_info[i]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 210 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 211 | if (!il_is_channel_valid(ch)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 212 | continue; |
| 213 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 214 | sband = &il->bands[ch->band]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 215 | |
| 216 | geo_ch = &sband->channels[sband->n_channels++]; |
| 217 | |
| 218 | geo_ch->center_freq = |
| 219 | ieee80211_channel_to_frequency(ch->channel, ch->band); |
| 220 | geo_ch->max_power = ch->max_power_avg; |
| 221 | geo_ch->max_antenna_gain = 0xff; |
| 222 | geo_ch->hw_value = ch->channel; |
| 223 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 224 | if (il_is_channel_valid(ch)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 225 | if (!(ch->flags & EEPROM_CHANNEL_IBSS)) |
| 226 | geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; |
| 227 | |
| 228 | if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) |
| 229 | geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 230 | |
| 231 | if (ch->flags & EEPROM_CHANNEL_RADAR) |
| 232 | geo_ch->flags |= IEEE80211_CHAN_RADAR; |
| 233 | |
| 234 | geo_ch->flags |= ch->ht40_extension_channel; |
| 235 | |
Stanislaw Gruszka | 332704a | 2011-04-13 10:56:51 +0200 | [diff] [blame] | 236 | if (ch->max_power_avg > max_tx_power) |
| 237 | max_tx_power = ch->max_power_avg; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 238 | } else { |
| 239 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; |
| 240 | } |
| 241 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 242 | D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 243 | ch->channel, geo_ch->center_freq, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 244 | il_is_channel_a_band(ch) ? "5.2" : "2.4", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 245 | geo_ch->flags & IEEE80211_CHAN_DISABLED ? |
| 246 | "restricted" : "valid", |
| 247 | geo_ch->flags); |
| 248 | } |
| 249 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 250 | il->tx_power_device_lmt = max_tx_power; |
| 251 | il->tx_power_user_lmt = max_tx_power; |
| 252 | il->tx_power_next = max_tx_power; |
Stanislaw Gruszka | 332704a | 2011-04-13 10:56:51 +0200 | [diff] [blame] | 253 | |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 254 | if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && |
| 255 | (il->cfg->sku & IL_SKU_A)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 256 | IL_INFO("Incorrectly detected BG card as ABG. " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 257 | "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 258 | il->pci_dev->device, |
| 259 | il->pci_dev->subsystem_device); |
| 260 | il->cfg->sku &= ~IL_SKU_A; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 261 | } |
| 262 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 263 | IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 264 | il->bands[IEEE80211_BAND_2GHZ].n_channels, |
| 265 | il->bands[IEEE80211_BAND_5GHZ].n_channels); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 266 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 267 | set_bit(S_GEO_CONFIGURED, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 268 | |
| 269 | return 0; |
| 270 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 271 | EXPORT_SYMBOL(il_init_geos); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 272 | |
| 273 | /* |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 274 | * il_free_geos - undo allocations in il_init_geos |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 275 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 276 | void il_free_geos(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 277 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 278 | kfree(il->ieee_channels); |
| 279 | kfree(il->ieee_rates); |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 280 | clear_bit(S_GEO_CONFIGURED, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 281 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 282 | EXPORT_SYMBOL(il_free_geos); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 283 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 284 | static bool il_is_channel_extension(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 285 | enum ieee80211_band band, |
| 286 | u16 channel, u8 extension_chan_offset) |
| 287 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 288 | const struct il_channel_info *ch_info; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 289 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 290 | ch_info = il_get_channel_info(il, band, channel); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 291 | if (!il_is_channel_valid(ch_info)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 292 | return false; |
| 293 | |
| 294 | if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) |
| 295 | return !(ch_info->ht40_extension_channel & |
| 296 | IEEE80211_CHAN_NO_HT40PLUS); |
| 297 | else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) |
| 298 | return !(ch_info->ht40_extension_channel & |
| 299 | IEEE80211_CHAN_NO_HT40MINUS); |
| 300 | |
| 301 | return false; |
| 302 | } |
| 303 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 304 | bool il_is_ht40_tx_allowed(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 305 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 306 | struct ieee80211_sta_ht_cap *ht_cap) |
| 307 | { |
| 308 | if (!ctx->ht.enabled || !ctx->ht.is_40mhz) |
| 309 | return false; |
| 310 | |
| 311 | /* |
| 312 | * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
| 313 | * the bit will not set if it is pure 40MHz case |
| 314 | */ |
| 315 | if (ht_cap && !ht_cap->ht_supported) |
| 316 | return false; |
| 317 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 318 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 319 | if (il->disable_ht40) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 320 | return false; |
| 321 | #endif |
| 322 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 323 | return il_is_channel_extension(il, il->band, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 324 | le16_to_cpu(ctx->staging.channel), |
| 325 | ctx->ht.extension_chan_offset); |
| 326 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 327 | EXPORT_SYMBOL(il_is_ht40_tx_allowed); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 328 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 329 | static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 330 | { |
| 331 | u16 new_val; |
| 332 | u16 beacon_factor; |
| 333 | |
| 334 | /* |
| 335 | * If mac80211 hasn't given us a beacon interval, program |
| 336 | * the default into the device. |
| 337 | */ |
| 338 | if (!beacon_val) |
| 339 | return DEFAULT_BEACON_INTERVAL; |
| 340 | |
| 341 | /* |
| 342 | * If the beacon interval we obtained from the peer |
| 343 | * is too large, we'll have to wake up more often |
| 344 | * (and in IBSS case, we'll beacon too much) |
| 345 | * |
| 346 | * For example, if max_beacon_val is 4096, and the |
| 347 | * requested beacon interval is 7000, we'll have to |
| 348 | * use 3500 to be able to wake up on the beacons. |
| 349 | * |
| 350 | * This could badly influence beacon detection stats. |
| 351 | */ |
| 352 | |
| 353 | beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; |
| 354 | new_val = beacon_val / beacon_factor; |
| 355 | |
| 356 | if (!new_val) |
| 357 | new_val = max_beacon_val; |
| 358 | |
| 359 | return new_val; |
| 360 | } |
| 361 | |
| 362 | int |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 363 | il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 364 | { |
| 365 | u64 tsf; |
| 366 | s32 interval_tm, rem; |
| 367 | struct ieee80211_conf *conf = NULL; |
| 368 | u16 beacon_int; |
| 369 | struct ieee80211_vif *vif = ctx->vif; |
| 370 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 371 | conf = il_ieee80211_get_hw_conf(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 372 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 373 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 374 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 375 | memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 376 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 377 | ctx->timing.timestamp = cpu_to_le64(il->timestamp); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 378 | ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); |
| 379 | |
| 380 | beacon_int = vif ? vif->bss_conf.beacon_int : 0; |
| 381 | |
| 382 | /* |
Stanislaw Gruszka | 6ce1dc4 | 2011-08-26 15:49:28 +0200 | [diff] [blame] | 383 | * TODO: For IBSS we need to get atim_win from mac80211, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 384 | * for now just always use 0 |
| 385 | */ |
Stanislaw Gruszka | 6ce1dc4 | 2011-08-26 15:49:28 +0200 | [diff] [blame] | 386 | ctx->timing.atim_win = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 387 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 388 | beacon_int = il_adjust_beacon_interval(beacon_int, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 389 | il->hw_params.max_beacon_itrvl * TIME_UNIT); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 390 | ctx->timing.beacon_interval = cpu_to_le16(beacon_int); |
| 391 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 392 | tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 393 | interval_tm = beacon_int * TIME_UNIT; |
| 394 | rem = do_div(tsf, interval_tm); |
| 395 | ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); |
| 396 | |
| 397 | ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; |
| 398 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 399 | D_ASSOC( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 400 | "beacon interval %d beacon timer %d beacon tim %d\n", |
| 401 | le16_to_cpu(ctx->timing.beacon_interval), |
| 402 | le32_to_cpu(ctx->timing.beacon_init_val), |
Stanislaw Gruszka | 6ce1dc4 | 2011-08-26 15:49:28 +0200 | [diff] [blame] | 403 | le16_to_cpu(ctx->timing.atim_win)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 404 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 405 | return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 406 | sizeof(ctx->timing), &ctx->timing); |
| 407 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 408 | EXPORT_SYMBOL(il_send_rxon_timing); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 409 | |
| 410 | void |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 411 | il_set_rxon_hwcrypto(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 412 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 413 | int hw_decrypt) |
| 414 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 415 | struct il_rxon_cmd *rxon = &ctx->staging; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 416 | |
| 417 | if (hw_decrypt) |
| 418 | rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; |
| 419 | else |
| 420 | rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; |
| 421 | |
| 422 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 423 | EXPORT_SYMBOL(il_set_rxon_hwcrypto); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 424 | |
| 425 | /* validate RXON structure is valid */ |
| 426 | int |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 427 | il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 428 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 429 | struct il_rxon_cmd *rxon = &ctx->staging; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 430 | bool error = false; |
| 431 | |
| 432 | if (rxon->flags & RXON_FLG_BAND_24G_MSK) { |
| 433 | if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 434 | IL_WARN("check 2.4G: wrong narrow\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 435 | error = true; |
| 436 | } |
| 437 | if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 438 | IL_WARN("check 2.4G: wrong radar\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 439 | error = true; |
| 440 | } |
| 441 | } else { |
| 442 | if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 443 | IL_WARN("check 5.2G: not short slot!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 444 | error = true; |
| 445 | } |
| 446 | if (rxon->flags & RXON_FLG_CCK_MSK) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 447 | IL_WARN("check 5.2G: CCK!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 448 | error = true; |
| 449 | } |
| 450 | } |
| 451 | if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 452 | IL_WARN("mac/bssid mcast!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 453 | error = true; |
| 454 | } |
| 455 | |
| 456 | /* make sure basic rates 6Mbps and 1Mbps are supported */ |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 457 | if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && |
| 458 | (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 459 | IL_WARN("neither 1 nor 6 are basic\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 460 | error = true; |
| 461 | } |
| 462 | |
| 463 | if (le16_to_cpu(rxon->assoc_id) > 2007) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 464 | IL_WARN("aid > 2007\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 465 | error = true; |
| 466 | } |
| 467 | |
| 468 | if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) |
| 469 | == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 470 | IL_WARN("CCK and short slot\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 471 | error = true; |
| 472 | } |
| 473 | |
| 474 | if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) |
| 475 | == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 476 | IL_WARN("CCK and auto detect"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 477 | error = true; |
| 478 | } |
| 479 | |
| 480 | if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | |
| 481 | RXON_FLG_TGG_PROTECT_MSK)) == |
| 482 | RXON_FLG_TGG_PROTECT_MSK) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 483 | IL_WARN("TGg but no auto-detect\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 484 | error = true; |
| 485 | } |
| 486 | |
| 487 | if (error) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 488 | IL_WARN("Tuning to channel %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 489 | le16_to_cpu(rxon->channel)); |
| 490 | |
| 491 | if (error) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 492 | IL_ERR("Invalid RXON\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 493 | return -EINVAL; |
| 494 | } |
| 495 | return 0; |
| 496 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 497 | EXPORT_SYMBOL(il_check_rxon_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 498 | |
| 499 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 500 | * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 501 | * @il: staging_rxon is compared to active_rxon |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 502 | * |
| 503 | * If the RXON structure is changing enough to require a new tune, |
| 504 | * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that |
| 505 | * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. |
| 506 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 507 | int il_full_rxon_required(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 508 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 509 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 510 | const struct il_rxon_cmd *staging = &ctx->staging; |
| 511 | const struct il_rxon_cmd *active = &ctx->active; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 512 | |
| 513 | #define CHK(cond) \ |
| 514 | if ((cond)) { \ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 515 | D_INFO("need full RXON - " #cond "\n"); \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 516 | return 1; \ |
| 517 | } |
| 518 | |
| 519 | #define CHK_NEQ(c1, c2) \ |
| 520 | if ((c1) != (c2)) { \ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 521 | D_INFO("need full RXON - " \ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 522 | #c1 " != " #c2 " - %d != %d\n", \ |
| 523 | (c1), (c2)); \ |
| 524 | return 1; \ |
| 525 | } |
| 526 | |
| 527 | /* These items are only settable from the full RXON command */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 528 | CHK(!il_is_associated_ctx(ctx)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 529 | CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); |
| 530 | CHK(compare_ether_addr(staging->node_addr, active->node_addr)); |
| 531 | CHK(compare_ether_addr(staging->wlap_bssid_addr, |
| 532 | active->wlap_bssid_addr)); |
| 533 | CHK_NEQ(staging->dev_type, active->dev_type); |
| 534 | CHK_NEQ(staging->channel, active->channel); |
| 535 | CHK_NEQ(staging->air_propagation, active->air_propagation); |
| 536 | CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, |
| 537 | active->ofdm_ht_single_stream_basic_rates); |
| 538 | CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, |
| 539 | active->ofdm_ht_dual_stream_basic_rates); |
| 540 | CHK_NEQ(staging->assoc_id, active->assoc_id); |
| 541 | |
| 542 | /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can |
| 543 | * be updated with the RXON_ASSOC command -- however only some |
| 544 | * flag transitions are allowed using RXON_ASSOC */ |
| 545 | |
| 546 | /* Check if we are not switching bands */ |
| 547 | CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, |
| 548 | active->flags & RXON_FLG_BAND_24G_MSK); |
| 549 | |
| 550 | /* Check if we are switching association toggle */ |
| 551 | CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, |
| 552 | active->filter_flags & RXON_FILTER_ASSOC_MSK); |
| 553 | |
| 554 | #undef CHK |
| 555 | #undef CHK_NEQ |
| 556 | |
| 557 | return 0; |
| 558 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 559 | EXPORT_SYMBOL(il_full_rxon_required); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 560 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 561 | u8 il_get_lowest_plcp(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 562 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 563 | { |
| 564 | /* |
| 565 | * Assign the lowest rate -- should really get this from |
| 566 | * the beacon skb from mac80211. |
| 567 | */ |
| 568 | if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 569 | return RATE_1M_PLCP; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 570 | else |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 571 | return RATE_6M_PLCP; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 572 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 573 | EXPORT_SYMBOL(il_get_lowest_plcp); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 574 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 575 | static void _il_set_rxon_ht(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 576 | struct il_ht_config *ht_conf, |
| 577 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 578 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 579 | struct il_rxon_cmd *rxon = &ctx->staging; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 580 | |
| 581 | if (!ctx->ht.enabled) { |
| 582 | rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | |
| 583 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | |
| 584 | RXON_FLG_HT40_PROT_MSK | |
| 585 | RXON_FLG_HT_PROT_MSK); |
| 586 | return; |
| 587 | } |
| 588 | |
| 589 | rxon->flags |= cpu_to_le32(ctx->ht.protection << |
| 590 | RXON_FLG_HT_OPERATING_MODE_POS); |
| 591 | |
| 592 | /* Set up channel bandwidth: |
| 593 | * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ |
| 594 | /* clear the HT channel mode before set the mode */ |
| 595 | rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | |
| 596 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 597 | if (il_is_ht40_tx_allowed(il, ctx, NULL)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 598 | /* pure ht40 */ |
| 599 | if (ctx->ht.protection == |
| 600 | IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { |
| 601 | rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; |
| 602 | /* Note: control channel is opposite of extension channel */ |
| 603 | switch (ctx->ht.extension_chan_offset) { |
| 604 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
| 605 | rxon->flags &= |
| 606 | ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; |
| 607 | break; |
| 608 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
| 609 | rxon->flags |= |
| 610 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; |
| 611 | break; |
| 612 | } |
| 613 | } else { |
| 614 | /* Note: control channel is opposite of extension channel */ |
| 615 | switch (ctx->ht.extension_chan_offset) { |
| 616 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
| 617 | rxon->flags &= |
| 618 | ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); |
| 619 | rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; |
| 620 | break; |
| 621 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
| 622 | rxon->flags |= |
| 623 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; |
| 624 | rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; |
| 625 | break; |
| 626 | case IEEE80211_HT_PARAM_CHA_SEC_NONE: |
| 627 | default: |
| 628 | /* channel location only valid if in Mixed mode */ |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 629 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 630 | "invalid extension channel offset\n"); |
| 631 | break; |
| 632 | } |
| 633 | } |
| 634 | } else { |
| 635 | rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; |
| 636 | } |
| 637 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 638 | if (il->cfg->ops->hcmd->set_rxon_chain) |
| 639 | il->cfg->ops->hcmd->set_rxon_chain(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 640 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 641 | D_ASSOC("rxon flags 0x%X operation mode :0x%X " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 642 | "extension channel offset 0x%x\n", |
| 643 | le32_to_cpu(rxon->flags), ctx->ht.protection, |
| 644 | ctx->ht.extension_chan_offset); |
| 645 | } |
| 646 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 647 | void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 648 | { |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 649 | _il_set_rxon_ht(il, ht_conf, &il->ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 650 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 651 | EXPORT_SYMBOL(il_set_rxon_ht); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 652 | |
| 653 | /* Return valid, unused, channel for a passive scan to reset the RF */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 654 | u8 il_get_single_channel_number(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 655 | enum ieee80211_band band) |
| 656 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 657 | const struct il_channel_info *ch_info; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 658 | int i; |
| 659 | u8 channel = 0; |
| 660 | u8 min, max; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 661 | |
| 662 | if (band == IEEE80211_BAND_5GHZ) { |
| 663 | min = 14; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 664 | max = il->channel_count; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 665 | } else { |
| 666 | min = 0; |
| 667 | max = 14; |
| 668 | } |
| 669 | |
| 670 | for (i = min; i < max; i++) { |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 671 | channel = il->channel_info[i].channel; |
| 672 | if (channel == le16_to_cpu(il->ctx.staging.channel)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 673 | continue; |
| 674 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 675 | ch_info = il_get_channel_info(il, band, channel); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 676 | if (il_is_channel_valid(ch_info)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 677 | break; |
| 678 | } |
| 679 | |
| 680 | return channel; |
| 681 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 682 | EXPORT_SYMBOL(il_get_single_channel_number); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 683 | |
| 684 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 685 | * il_set_rxon_channel - Set the band and channel values in staging RXON |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 686 | * @ch: requested channel as a pointer to struct ieee80211_channel |
| 687 | |
| 688 | * NOTE: Does not commit to the hardware; it sets appropriate bit fields |
| 689 | * in the staging RXON flag structure based on the ch->band |
| 690 | */ |
| 691 | int |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 692 | il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 693 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 694 | { |
| 695 | enum ieee80211_band band = ch->band; |
| 696 | u16 channel = ch->hw_value; |
| 697 | |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 698 | if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 699 | return 0; |
| 700 | |
| 701 | ctx->staging.channel = cpu_to_le16(channel); |
| 702 | if (band == IEEE80211_BAND_5GHZ) |
| 703 | ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; |
| 704 | else |
| 705 | ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; |
| 706 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 707 | il->band = band; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 708 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 709 | D_INFO("Staging channel set to %d [%d]\n", channel, band); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 710 | |
| 711 | return 0; |
| 712 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 713 | EXPORT_SYMBOL(il_set_rxon_channel); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 714 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 715 | void il_set_flags_for_band(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 716 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 717 | enum ieee80211_band band, |
| 718 | struct ieee80211_vif *vif) |
| 719 | { |
| 720 | if (band == IEEE80211_BAND_5GHZ) { |
| 721 | ctx->staging.flags &= |
| 722 | ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK |
| 723 | | RXON_FLG_CCK_MSK); |
| 724 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; |
| 725 | } else { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 726 | /* Copied from il_post_associate() */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 727 | if (vif && vif->bss_conf.use_short_slot) |
| 728 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; |
| 729 | else |
| 730 | ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; |
| 731 | |
| 732 | ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; |
| 733 | ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; |
| 734 | ctx->staging.flags &= ~RXON_FLG_CCK_MSK; |
| 735 | } |
| 736 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 737 | EXPORT_SYMBOL(il_set_flags_for_band); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 738 | |
| 739 | /* |
| 740 | * initialize rxon structure with default values from eeprom |
| 741 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 742 | void il_connection_init_rx_config(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 743 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 744 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 745 | const struct il_channel_info *ch_info; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 746 | |
| 747 | memset(&ctx->staging, 0, sizeof(ctx->staging)); |
| 748 | |
| 749 | if (!ctx->vif) { |
| 750 | ctx->staging.dev_type = ctx->unused_devtype; |
| 751 | } else |
| 752 | switch (ctx->vif->type) { |
| 753 | |
| 754 | case NL80211_IFTYPE_STATION: |
| 755 | ctx->staging.dev_type = ctx->station_devtype; |
| 756 | ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; |
| 757 | break; |
| 758 | |
| 759 | case NL80211_IFTYPE_ADHOC: |
| 760 | ctx->staging.dev_type = ctx->ibss_devtype; |
| 761 | ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; |
| 762 | ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | |
| 763 | RXON_FILTER_ACCEPT_GRP_MSK; |
| 764 | break; |
| 765 | |
| 766 | default: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 767 | IL_ERR("Unsupported interface type %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 768 | ctx->vif->type); |
| 769 | break; |
| 770 | } |
| 771 | |
| 772 | #if 0 |
| 773 | /* TODO: Figure out when short_preamble would be set and cache from |
| 774 | * that */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 775 | if (!hw_to_local(il->hw)->short_preamble) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 776 | ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; |
| 777 | else |
| 778 | ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
| 779 | #endif |
| 780 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 781 | ch_info = il_get_channel_info(il, il->band, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 782 | le16_to_cpu(ctx->active.channel)); |
| 783 | |
| 784 | if (!ch_info) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 785 | ch_info = &il->channel_info[0]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 786 | |
| 787 | ctx->staging.channel = cpu_to_le16(ch_info->channel); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 788 | il->band = ch_info->band; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 789 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 790 | il_set_flags_for_band(il, ctx, il->band, ctx->vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 791 | |
| 792 | ctx->staging.ofdm_basic_rates = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 793 | (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 794 | ctx->staging.cck_basic_rates = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 795 | (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 796 | |
| 797 | /* clear both MIX and PURE40 mode flag */ |
| 798 | ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | |
| 799 | RXON_FLG_CHANNEL_MODE_PURE_40); |
| 800 | if (ctx->vif) |
| 801 | memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); |
| 802 | |
| 803 | ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; |
| 804 | ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; |
| 805 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 806 | EXPORT_SYMBOL(il_connection_init_rx_config); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 807 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 808 | void il_set_rate(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 809 | { |
| 810 | const struct ieee80211_supported_band *hw = NULL; |
| 811 | struct ieee80211_rate *rate; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 812 | int i; |
| 813 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 814 | hw = il_get_hw_mode(il, il->band); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 815 | if (!hw) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 816 | IL_ERR("Failed to set rate: unable to get hw mode\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 817 | return; |
| 818 | } |
| 819 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 820 | il->active_rate = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 821 | |
| 822 | for (i = 0; i < hw->n_bitrates; i++) { |
| 823 | rate = &(hw->bitrates[i]); |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 824 | if (rate->hw_value < RATE_COUNT_LEGACY) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 825 | il->active_rate |= (1 << rate->hw_value); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 826 | } |
| 827 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 828 | D_RATE("Set active_rate = %0x\n", il->active_rate); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 829 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 830 | il->ctx.staging.cck_basic_rates = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 831 | (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 832 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 833 | il->ctx.staging.ofdm_basic_rates = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 834 | (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 835 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 836 | EXPORT_SYMBOL(il_set_rate); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 837 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 838 | void il_chswitch_done(struct il_priv *il, bool is_success) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 839 | { |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 840 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 841 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 842 | if (test_bit(S_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 843 | return; |
| 844 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 845 | if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 846 | ieee80211_chswitch_done(ctx->vif, is_success); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 847 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 848 | EXPORT_SYMBOL(il_chswitch_done); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 849 | |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 850 | void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 851 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 852 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 853 | struct il_csa_notification *csa = &(pkt->u.csa_notif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 854 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 855 | struct il_rxon_context *ctx = &il->ctx; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 856 | struct il_rxon_cmd *rxon = (void *)&ctx->active; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 857 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 858 | if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) |
Stanislaw Gruszka | 51e6525 | 2011-06-08 15:26:31 +0200 | [diff] [blame] | 859 | return; |
| 860 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 861 | if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { |
Stanislaw Gruszka | 51e6525 | 2011-06-08 15:26:31 +0200 | [diff] [blame] | 862 | rxon->channel = csa->channel; |
| 863 | ctx->staging.channel = csa->channel; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 864 | D_11H("CSA notif: channel %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 865 | le16_to_cpu(csa->channel)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 866 | il_chswitch_done(il, true); |
Stanislaw Gruszka | 51e6525 | 2011-06-08 15:26:31 +0200 | [diff] [blame] | 867 | } else { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 868 | IL_ERR("CSA notif (fail) : channel %d\n", |
Stanislaw Gruszka | 51e6525 | 2011-06-08 15:26:31 +0200 | [diff] [blame] | 869 | le16_to_cpu(csa->channel)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 870 | il_chswitch_done(il, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 871 | } |
| 872 | } |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 873 | EXPORT_SYMBOL(il_hdl_csa); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 874 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 875 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 876 | void il_print_rx_config_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 877 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 878 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 879 | struct il_rxon_cmd *rxon = &ctx->staging; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 880 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 881 | D_RADIO("RX CONFIG:\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 882 | il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 883 | D_RADIO("u16 channel: 0x%x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 884 | le16_to_cpu(rxon->channel)); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 885 | D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); |
| 886 | D_RADIO("u32 filter_flags: 0x%08x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 887 | le32_to_cpu(rxon->filter_flags)); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 888 | D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); |
| 889 | D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 890 | rxon->ofdm_basic_rates); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 891 | D_RADIO("u8 cck_basic_rates: 0x%02x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 892 | rxon->cck_basic_rates); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 893 | D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); |
| 894 | D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); |
| 895 | D_RADIO("u16 assoc_id: 0x%x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 896 | le16_to_cpu(rxon->assoc_id)); |
| 897 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 898 | EXPORT_SYMBOL(il_print_rx_config_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 899 | #endif |
| 900 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 901 | * il_irq_handle_error - called for HW or SW error interrupt from card |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 902 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 903 | void il_irq_handle_error(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 904 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 905 | /* Set the FW error flag -- cleared on il_down */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 906 | set_bit(S_FW_ERROR, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 907 | |
| 908 | /* Cancel currently queued command. */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 909 | clear_bit(S_HCMD_ACTIVE, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 910 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 911 | IL_ERR("Loaded firmware version: %s\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 912 | il->hw->wiphy->fw_version); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 913 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 914 | il->cfg->ops->lib->dump_nic_error_log(il); |
| 915 | if (il->cfg->ops->lib->dump_fh) |
| 916 | il->cfg->ops->lib->dump_fh(il, NULL, false); |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 917 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 918 | if (il_get_debug_level(il) & IL_DL_FW_ERRORS) |
| 919 | il_print_rx_config_cmd(il, |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 920 | &il->ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 921 | #endif |
| 922 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 923 | wake_up(&il->wait_command_queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 924 | |
| 925 | /* Keep the restart process from trying to send host |
| 926 | * commands by clearing the INIT status bit */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 927 | clear_bit(S_READY, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 928 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 929 | if (!test_bit(S_EXIT_PENDING, &il->status)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 930 | IL_DBG(IL_DL_FW_ERRORS, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 931 | "Restarting adapter due to uCode error.\n"); |
| 932 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 933 | if (il->cfg->mod_params->restart_fw) |
| 934 | queue_work(il->workqueue, &il->restart); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 935 | } |
| 936 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 937 | EXPORT_SYMBOL(il_irq_handle_error); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 938 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 939 | static int il_apm_stop_master(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 940 | { |
| 941 | int ret = 0; |
| 942 | |
| 943 | /* stop device's busmaster DMA activity */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 944 | il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 945 | |
Stanislaw Gruszka | 142b343 | 2011-08-24 15:22:57 +0200 | [diff] [blame] | 946 | ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 947 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); |
| 948 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 949 | IL_WARN("Master Disable Timed Out, 100 usec\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 950 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 951 | D_INFO("stop master\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 952 | |
| 953 | return ret; |
| 954 | } |
| 955 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 956 | void il_apm_stop(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 957 | { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 958 | D_INFO("Stop card, put in low power state\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 959 | |
| 960 | /* Stop device's DMA activity */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 961 | il_apm_stop_master(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 962 | |
| 963 | /* Reset the entire device */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 964 | il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 965 | |
| 966 | udelay(10); |
| 967 | |
| 968 | /* |
| 969 | * Clear "initialization complete" bit to move adapter from |
| 970 | * D0A* (powered-up Active) --> D0U* (Uninitialized) state. |
| 971 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 972 | il_clear_bit(il, CSR_GP_CNTRL, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 973 | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
| 974 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 975 | EXPORT_SYMBOL(il_apm_stop); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 976 | |
| 977 | |
| 978 | /* |
| 979 | * Start up NIC's basic functionality after it has been reset |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 980 | * (e.g. after platform boot, or shutdown via il_apm_stop()) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 981 | * NOTE: This does not load uCode nor start the embedded processor |
| 982 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 983 | int il_apm_init(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 984 | { |
| 985 | int ret = 0; |
| 986 | u16 lctl; |
| 987 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 988 | D_INFO("Init card's basic functions\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 989 | |
| 990 | /* |
| 991 | * Use "set_bit" below rather than "write", to preserve any hardware |
| 992 | * bits already set by default after reset. |
| 993 | */ |
| 994 | |
| 995 | /* Disable L0S exit timer (platform NMI Work/Around) */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 996 | il_set_bit(il, CSR_GIO_CHICKEN_BITS, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 997 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); |
| 998 | |
| 999 | /* |
| 1000 | * Disable L0s without affecting L1; |
| 1001 | * don't wait for ICH L0s (ICH bug W/A) |
| 1002 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1003 | il_set_bit(il, CSR_GIO_CHICKEN_BITS, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1004 | CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); |
| 1005 | |
| 1006 | /* Set FH wait threshold to maximum (HW error during stress W/A) */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1007 | il_set_bit(il, CSR_DBG_HPET_MEM_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1008 | CSR_DBG_HPET_MEM_REG_VAL); |
| 1009 | |
| 1010 | /* |
| 1011 | * Enable HAP INTA (interrupt from management bus) to |
| 1012 | * wake device's PCI Express link L1a -> L0s |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1013 | * NOTE: This is no-op for 3945 (non-existent bit) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1014 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1015 | il_set_bit(il, CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1016 | CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); |
| 1017 | |
| 1018 | /* |
| 1019 | * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. |
| 1020 | * Check if BIOS (or OS) enabled L1-ASPM on this device. |
| 1021 | * If so (likely), disable L0S, so device moves directly L0->L1; |
| 1022 | * costs negligible amount of power savings. |
| 1023 | * If not (unlikely), enable L0S, so there is at least some |
| 1024 | * power savings, even without L1. |
| 1025 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1026 | if (il->cfg->base_params->set_l0s) { |
| 1027 | lctl = il_pcie_link_ctl(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1028 | if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == |
| 1029 | PCI_CFG_LINK_CTRL_VAL_L1_EN) { |
| 1030 | /* L1-ASPM enabled; disable(!) L0S */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1031 | il_set_bit(il, CSR_GIO_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1032 | CSR_GIO_REG_VAL_L0S_ENABLED); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1033 | D_POWER("L1 Enabled; Disabling L0S\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1034 | } else { |
| 1035 | /* L1-ASPM disabled; enable(!) L0S */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1036 | il_clear_bit(il, CSR_GIO_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1037 | CSR_GIO_REG_VAL_L0S_ENABLED); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1038 | D_POWER("L1 Disabled; Enabling L0S\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | /* Configure analog phase-lock-loop before activating to D0A */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1043 | if (il->cfg->base_params->pll_cfg_val) |
| 1044 | il_set_bit(il, CSR_ANA_PLL_CFG, |
| 1045 | il->cfg->base_params->pll_cfg_val); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1046 | |
| 1047 | /* |
| 1048 | * Set "initialization complete" bit to move adapter from |
| 1049 | * D0U* --> D0A* (powered-up active) state. |
| 1050 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1051 | il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1052 | |
| 1053 | /* |
| 1054 | * Wait for clock stabilization; once stabilized, access to |
Stanislaw Gruszka | db54eb5 | 2011-08-24 21:06:33 +0200 | [diff] [blame] | 1055 | * device-internal resources is supported, e.g. il_wr_prph() |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1056 | * and accesses to uCode SRAM. |
| 1057 | */ |
Stanislaw Gruszka | 142b343 | 2011-08-24 15:22:57 +0200 | [diff] [blame] | 1058 | ret = _il_poll_bit(il, CSR_GP_CNTRL, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1059 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
| 1060 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); |
| 1061 | if (ret < 0) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1062 | D_INFO("Failed to init the card\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1063 | goto out; |
| 1064 | } |
| 1065 | |
| 1066 | /* |
| 1067 | * Enable DMA and BSM (if used) clocks, wait for them to stabilize. |
| 1068 | * BSM (Boostrap State Machine) is only in 3945 and 4965. |
| 1069 | * |
| 1070 | * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits |
| 1071 | * do not disable clocks. This preserves any hardware bits already |
| 1072 | * set by default in "CLK_CTRL_REG" after reset. |
| 1073 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1074 | if (il->cfg->base_params->use_bsm) |
Stanislaw Gruszka | db54eb5 | 2011-08-24 21:06:33 +0200 | [diff] [blame] | 1075 | il_wr_prph(il, APMG_CLK_EN_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1076 | APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); |
| 1077 | else |
Stanislaw Gruszka | db54eb5 | 2011-08-24 21:06:33 +0200 | [diff] [blame] | 1078 | il_wr_prph(il, APMG_CLK_EN_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1079 | APMG_CLK_VAL_DMA_CLK_RQT); |
| 1080 | udelay(20); |
| 1081 | |
| 1082 | /* Disable L1-Active */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1083 | il_set_bits_prph(il, APMG_PCIDEV_STT_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1084 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); |
| 1085 | |
| 1086 | out: |
| 1087 | return ret; |
| 1088 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1089 | EXPORT_SYMBOL(il_apm_init); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1090 | |
| 1091 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1092 | int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1093 | { |
| 1094 | int ret; |
| 1095 | s8 prev_tx_power; |
Stanislaw Gruszka | 43f12d4 | 2011-02-24 14:23:55 +0100 | [diff] [blame] | 1096 | bool defer; |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 1097 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1098 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1099 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1100 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1101 | if (il->tx_power_user_lmt == tx_power && !force) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1102 | return 0; |
| 1103 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1104 | if (!il->cfg->ops->lib->send_tx_power) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1105 | return -EOPNOTSUPP; |
| 1106 | |
Stanislaw Gruszka | 332704a | 2011-04-13 10:56:51 +0200 | [diff] [blame] | 1107 | /* 0 dBm mean 1 milliwatt */ |
| 1108 | if (tx_power < 0) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1109 | IL_WARN( |
Stanislaw Gruszka | 332704a | 2011-04-13 10:56:51 +0200 | [diff] [blame] | 1110 | "Requested user TXPOWER %d below 1 mW.\n", |
| 1111 | tx_power); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1112 | return -EINVAL; |
| 1113 | } |
| 1114 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1115 | if (tx_power > il->tx_power_device_lmt) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1116 | IL_WARN( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1117 | "Requested user TXPOWER %d above upper limit %d.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1118 | tx_power, il->tx_power_device_lmt); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1119 | return -EINVAL; |
| 1120 | } |
| 1121 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1122 | if (!il_is_ready_rf(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1123 | return -EIO; |
| 1124 | |
Stanislaw Gruszka | 43f12d4 | 2011-02-24 14:23:55 +0100 | [diff] [blame] | 1125 | /* scan complete and commit_rxon use tx_power_next value, |
| 1126 | * it always need to be updated for newest request */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1127 | il->tx_power_next = tx_power; |
Stanislaw Gruszka | 43f12d4 | 2011-02-24 14:23:55 +0100 | [diff] [blame] | 1128 | |
| 1129 | /* do not set tx power when scanning or channel changing */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1130 | defer = test_bit(S_SCANNING, &il->status) || |
Stanislaw Gruszka | 43f12d4 | 2011-02-24 14:23:55 +0100 | [diff] [blame] | 1131 | memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); |
| 1132 | if (defer && !force) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1133 | D_INFO("Deferring tx power set\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1134 | return 0; |
| 1135 | } |
| 1136 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1137 | prev_tx_power = il->tx_power_user_lmt; |
| 1138 | il->tx_power_user_lmt = tx_power; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1139 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1140 | ret = il->cfg->ops->lib->send_tx_power(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1141 | |
| 1142 | /* if fail to set tx_power, restore the orig. tx power */ |
| 1143 | if (ret) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1144 | il->tx_power_user_lmt = prev_tx_power; |
| 1145 | il->tx_power_next = prev_tx_power; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1146 | } |
| 1147 | return ret; |
| 1148 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1149 | EXPORT_SYMBOL(il_set_tx_power); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1150 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1151 | void il_send_bt_config(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1152 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1153 | struct il_bt_cmd bt_cmd = { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1154 | .lead_time = BT_LEAD_TIME_DEF, |
| 1155 | .max_kill = BT_MAX_KILL_DEF, |
| 1156 | .kill_ack_mask = 0, |
| 1157 | .kill_cts_mask = 0, |
| 1158 | }; |
| 1159 | |
| 1160 | if (!bt_coex_active) |
| 1161 | bt_cmd.flags = BT_COEX_DISABLE; |
| 1162 | else |
| 1163 | bt_cmd.flags = BT_COEX_ENABLE; |
| 1164 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1165 | D_INFO("BT coex %s\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1166 | (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); |
| 1167 | |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 1168 | if (il_send_cmd_pdu(il, C_BT_CONFIG, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1169 | sizeof(struct il_bt_cmd), &bt_cmd)) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1170 | IL_ERR("failed to send BT Coex Config\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1171 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1172 | EXPORT_SYMBOL(il_send_bt_config); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1173 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1174 | int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1175 | { |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1176 | struct il_stats_cmd stats_cmd = { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1177 | .configuration_flags = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1178 | clear ? IL_STATS_CONF_CLEAR_STATS : 0, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1179 | }; |
| 1180 | |
| 1181 | if (flags & CMD_ASYNC) |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 1182 | return il_send_cmd_pdu_async(il, C_STATS, |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1183 | sizeof(struct il_stats_cmd), |
| 1184 | &stats_cmd, NULL); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1185 | else |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 1186 | return il_send_cmd_pdu(il, C_STATS, |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1187 | sizeof(struct il_stats_cmd), |
| 1188 | &stats_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1189 | } |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1190 | EXPORT_SYMBOL(il_send_stats_request); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1191 | |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 1192 | void il_hdl_pm_sleep(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1193 | struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1194 | { |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1195 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1196 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1197 | struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1198 | D_RX("sleep mode: %d, src: %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1199 | sleep->pm_sleep_mode, sleep->pm_wakeup_src); |
| 1200 | #endif |
| 1201 | } |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 1202 | EXPORT_SYMBOL(il_hdl_pm_sleep); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1203 | |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 1204 | void il_hdl_pm_debug_stats(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1205 | struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1206 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1207 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1208 | u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1209 | D_RADIO("Dumping %d bytes of unhandled " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1210 | "notification for %s:\n", len, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1211 | il_get_cmd_string(pkt->hdr.cmd)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1212 | il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1213 | } |
Stanislaw Gruszka | d2dfb33 | 2011-11-15 13:16:38 +0100 | [diff] [blame] | 1214 | EXPORT_SYMBOL(il_hdl_pm_debug_stats); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1215 | |
Stanislaw Gruszka | 6e9848b4 | 2011-08-30 15:45:31 +0200 | [diff] [blame] | 1216 | void il_hdl_error(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1217 | struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1218 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1219 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1220 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1221 | IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1222 | "seq 0x%04X ser 0x%08X\n", |
| 1223 | le32_to_cpu(pkt->u.err_resp.error_type), |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1224 | il_get_cmd_string(pkt->u.err_resp.cmd_id), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1225 | pkt->u.err_resp.cmd_id, |
| 1226 | le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), |
| 1227 | le32_to_cpu(pkt->u.err_resp.error_info)); |
| 1228 | } |
Stanislaw Gruszka | 6e9848b4 | 2011-08-30 15:45:31 +0200 | [diff] [blame] | 1229 | EXPORT_SYMBOL(il_hdl_error); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1230 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1231 | void il_clear_isr_stats(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1232 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1233 | memset(&il->isr_stats, 0, sizeof(il->isr_stats)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1234 | } |
| 1235 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1236 | int il_mac_conf_tx(struct ieee80211_hw *hw, |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 1237 | struct ieee80211_vif *vif, u16 queue, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1238 | const struct ieee80211_tx_queue_params *params) |
| 1239 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1240 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1241 | unsigned long flags; |
| 1242 | int q; |
| 1243 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1244 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1245 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1246 | if (!il_is_ready_rf(il)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1247 | D_MAC80211("leave - RF not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1248 | return -EIO; |
| 1249 | } |
| 1250 | |
| 1251 | if (queue >= AC_NUM) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1252 | D_MAC80211("leave - queue >= AC_NUM %d\n", queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1253 | return 0; |
| 1254 | } |
| 1255 | |
| 1256 | q = AC_NUM - 1 - queue; |
| 1257 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1258 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1259 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1260 | il->ctx.qos_data.def_qos_parm.ac[q].cw_min = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1261 | cpu_to_le16(params->cw_min); |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1262 | il->ctx.qos_data.def_qos_parm.ac[q].cw_max = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1263 | cpu_to_le16(params->cw_max); |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1264 | il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; |
| 1265 | il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1266 | cpu_to_le16((params->txop * 32)); |
| 1267 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1268 | il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1269 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1270 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1271 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1272 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1273 | return 0; |
| 1274 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1275 | EXPORT_SYMBOL(il_mac_conf_tx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1276 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1277 | int il_mac_tx_last_beacon(struct ieee80211_hw *hw) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1278 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1279 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1280 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1281 | return il->ibss_manager == IL_IBSS_MANAGER; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1282 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1283 | EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1284 | |
| 1285 | static int |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1286 | il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1287 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1288 | il_connection_init_rx_config(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1289 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1290 | if (il->cfg->ops->hcmd->set_rxon_chain) |
| 1291 | il->cfg->ops->hcmd->set_rxon_chain(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1292 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1293 | return il_commit_rxon(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1294 | } |
| 1295 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1296 | static int il_setup_interface(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1297 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1298 | { |
| 1299 | struct ieee80211_vif *vif = ctx->vif; |
| 1300 | int err; |
| 1301 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1302 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1303 | |
| 1304 | /* |
| 1305 | * This variable will be correct only when there's just |
| 1306 | * a single context, but all code using it is for hardware |
| 1307 | * that supports only one context. |
| 1308 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1309 | il->iw_mode = vif->type; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1310 | |
| 1311 | ctx->is_active = true; |
| 1312 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1313 | err = il_set_mode(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1314 | if (err) { |
| 1315 | if (!ctx->always_active) |
| 1316 | ctx->is_active = false; |
| 1317 | return err; |
| 1318 | } |
| 1319 | |
| 1320 | return 0; |
| 1321 | } |
| 1322 | |
| 1323 | int |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1324 | il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1325 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1326 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1327 | struct il_vif_priv *vif_priv = (void *)vif->drv_priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1328 | int err; |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1329 | u32 modes; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1330 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1331 | D_MAC80211("enter: type %d, addr %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1332 | vif->type, vif->addr); |
| 1333 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1334 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1335 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1336 | if (!il_is_ready_rf(il)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1337 | IL_WARN("Try to add interface when device not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1338 | err = -EINVAL; |
| 1339 | goto out; |
| 1340 | } |
| 1341 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1342 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1343 | /* check if busy context is exclusive */ |
| 1344 | if (il->ctx.vif && |
| 1345 | (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { |
| 1346 | err = -EINVAL; |
| 1347 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1348 | } |
| 1349 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1350 | modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; |
| 1351 | if (!(modes & BIT(vif->type))) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1352 | err = -EOPNOTSUPP; |
| 1353 | goto out; |
| 1354 | } |
| 1355 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1356 | vif_priv->ctx = &il->ctx; |
| 1357 | il->ctx.vif = vif; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1358 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1359 | err = il_setup_interface(il, &il->ctx); |
| 1360 | if (err) { |
| 1361 | il->ctx.vif = NULL; |
| 1362 | il->iw_mode = NL80211_IFTYPE_STATION; |
| 1363 | } |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1364 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1365 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1366 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1367 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1368 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1369 | return err; |
| 1370 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1371 | EXPORT_SYMBOL(il_mac_add_interface); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1372 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1373 | static void il_teardown_interface(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1374 | struct ieee80211_vif *vif, |
| 1375 | bool mode_change) |
| 1376 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1377 | struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1378 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1379 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1380 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1381 | if (il->scan_vif == vif) { |
| 1382 | il_scan_cancel_timeout(il, 200); |
| 1383 | il_force_scan_end(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1384 | } |
| 1385 | |
| 1386 | if (!mode_change) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1387 | il_set_mode(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1388 | if (!ctx->always_active) |
| 1389 | ctx->is_active = false; |
| 1390 | } |
| 1391 | } |
| 1392 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1393 | void il_mac_remove_interface(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1394 | struct ieee80211_vif *vif) |
| 1395 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1396 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1397 | struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1398 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1399 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1400 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1401 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1402 | |
| 1403 | WARN_ON(ctx->vif != vif); |
| 1404 | ctx->vif = NULL; |
| 1405 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1406 | il_teardown_interface(il, vif, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1407 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1408 | memset(il->bssid, 0, ETH_ALEN); |
| 1409 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1410 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1411 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1412 | |
| 1413 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1414 | EXPORT_SYMBOL(il_mac_remove_interface); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1415 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1416 | int il_alloc_txq_mem(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1417 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1418 | if (!il->txq) |
| 1419 | il->txq = kzalloc( |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1420 | sizeof(struct il_tx_queue) * |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1421 | il->cfg->base_params->num_of_queues, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1422 | GFP_KERNEL); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1423 | if (!il->txq) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1424 | IL_ERR("Not enough memory for txq\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1425 | return -ENOMEM; |
| 1426 | } |
| 1427 | return 0; |
| 1428 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1429 | EXPORT_SYMBOL(il_alloc_txq_mem); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1430 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1431 | void il_txq_mem(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1432 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1433 | kfree(il->txq); |
| 1434 | il->txq = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1435 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1436 | EXPORT_SYMBOL(il_txq_mem); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1437 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1438 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1439 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1440 | #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1441 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1442 | void il_reset_traffic_log(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1443 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1444 | il->tx_traffic_idx = 0; |
| 1445 | il->rx_traffic_idx = 0; |
| 1446 | if (il->tx_traffic) |
| 1447 | memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); |
| 1448 | if (il->rx_traffic) |
| 1449 | memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1450 | } |
| 1451 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1452 | int il_alloc_traffic_mem(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1453 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1454 | u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1455 | |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1456 | if (il_debug_level & IL_DL_TX) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1457 | if (!il->tx_traffic) { |
| 1458 | il->tx_traffic = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1459 | kzalloc(traffic_size, GFP_KERNEL); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1460 | if (!il->tx_traffic) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1461 | return -ENOMEM; |
| 1462 | } |
| 1463 | } |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1464 | if (il_debug_level & IL_DL_RX) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1465 | if (!il->rx_traffic) { |
| 1466 | il->rx_traffic = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1467 | kzalloc(traffic_size, GFP_KERNEL); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1468 | if (!il->rx_traffic) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1469 | return -ENOMEM; |
| 1470 | } |
| 1471 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1472 | il_reset_traffic_log(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1473 | return 0; |
| 1474 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1475 | EXPORT_SYMBOL(il_alloc_traffic_mem); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1476 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1477 | void il_free_traffic_mem(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1478 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1479 | kfree(il->tx_traffic); |
| 1480 | il->tx_traffic = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1481 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1482 | kfree(il->rx_traffic); |
| 1483 | il->rx_traffic = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1484 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1485 | EXPORT_SYMBOL(il_free_traffic_mem); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1486 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1487 | void il_dbg_log_tx_data_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1488 | u16 length, struct ieee80211_hdr *header) |
| 1489 | { |
| 1490 | __le16 fc; |
| 1491 | u16 len; |
| 1492 | |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1493 | if (likely(!(il_debug_level & IL_DL_TX))) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1494 | return; |
| 1495 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1496 | if (!il->tx_traffic) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1497 | return; |
| 1498 | |
| 1499 | fc = header->frame_control; |
| 1500 | if (ieee80211_is_data(fc)) { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1501 | len = (length > IL_TRAFFIC_ENTRY_SIZE) |
| 1502 | ? IL_TRAFFIC_ENTRY_SIZE : length; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1503 | memcpy((il->tx_traffic + |
| 1504 | (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1505 | header, len); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1506 | il->tx_traffic_idx = |
| 1507 | (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1508 | } |
| 1509 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1510 | EXPORT_SYMBOL(il_dbg_log_tx_data_frame); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1511 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1512 | void il_dbg_log_rx_data_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1513 | u16 length, struct ieee80211_hdr *header) |
| 1514 | { |
| 1515 | __le16 fc; |
| 1516 | u16 len; |
| 1517 | |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1518 | if (likely(!(il_debug_level & IL_DL_RX))) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1519 | return; |
| 1520 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1521 | if (!il->rx_traffic) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1522 | return; |
| 1523 | |
| 1524 | fc = header->frame_control; |
| 1525 | if (ieee80211_is_data(fc)) { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1526 | len = (length > IL_TRAFFIC_ENTRY_SIZE) |
| 1527 | ? IL_TRAFFIC_ENTRY_SIZE : length; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1528 | memcpy((il->rx_traffic + |
| 1529 | (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1530 | header, len); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1531 | il->rx_traffic_idx = |
| 1532 | (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1533 | } |
| 1534 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1535 | EXPORT_SYMBOL(il_dbg_log_rx_data_frame); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1536 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1537 | const char *il_get_mgmt_string(int cmd) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1538 | { |
| 1539 | switch (cmd) { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1540 | IL_CMD(MANAGEMENT_ASSOC_REQ); |
| 1541 | IL_CMD(MANAGEMENT_ASSOC_RESP); |
| 1542 | IL_CMD(MANAGEMENT_REASSOC_REQ); |
| 1543 | IL_CMD(MANAGEMENT_REASSOC_RESP); |
| 1544 | IL_CMD(MANAGEMENT_PROBE_REQ); |
| 1545 | IL_CMD(MANAGEMENT_PROBE_RESP); |
| 1546 | IL_CMD(MANAGEMENT_BEACON); |
| 1547 | IL_CMD(MANAGEMENT_ATIM); |
| 1548 | IL_CMD(MANAGEMENT_DISASSOC); |
| 1549 | IL_CMD(MANAGEMENT_AUTH); |
| 1550 | IL_CMD(MANAGEMENT_DEAUTH); |
| 1551 | IL_CMD(MANAGEMENT_ACTION); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1552 | default: |
| 1553 | return "UNKNOWN"; |
| 1554 | |
| 1555 | } |
| 1556 | } |
| 1557 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1558 | const char *il_get_ctrl_string(int cmd) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1559 | { |
| 1560 | switch (cmd) { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1561 | IL_CMD(CONTROL_BACK_REQ); |
| 1562 | IL_CMD(CONTROL_BACK); |
| 1563 | IL_CMD(CONTROL_PSPOLL); |
| 1564 | IL_CMD(CONTROL_RTS); |
| 1565 | IL_CMD(CONTROL_CTS); |
| 1566 | IL_CMD(CONTROL_ACK); |
| 1567 | IL_CMD(CONTROL_CFEND); |
| 1568 | IL_CMD(CONTROL_CFENDACK); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1569 | default: |
| 1570 | return "UNKNOWN"; |
| 1571 | |
| 1572 | } |
| 1573 | } |
| 1574 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1575 | void il_clear_traffic_stats(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1576 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1577 | memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); |
| 1578 | memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1579 | } |
| 1580 | |
| 1581 | /* |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1582 | * if CONFIG_IWLEGACY_DEBUGFS defined, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1583 | * il_update_stats function will |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1584 | * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1585 | * Use debugFs to display the rx/rx_stats |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1586 | * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1587 | * information will be recorded, but DATA pkt still will be recorded |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1588 | * for the reason of il_led.c need to control the led blinking based on |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1589 | * number of tx and rx data. |
| 1590 | * |
| 1591 | */ |
| 1592 | void |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1593 | il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1594 | { |
| 1595 | struct traffic_stats *stats; |
| 1596 | |
| 1597 | if (is_tx) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1598 | stats = &il->tx_stats; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1599 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1600 | stats = &il->rx_stats; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1601 | |
| 1602 | if (ieee80211_is_mgmt(fc)) { |
| 1603 | switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { |
| 1604 | case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): |
| 1605 | stats->mgmt[MANAGEMENT_ASSOC_REQ]++; |
| 1606 | break; |
| 1607 | case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): |
| 1608 | stats->mgmt[MANAGEMENT_ASSOC_RESP]++; |
| 1609 | break; |
| 1610 | case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): |
| 1611 | stats->mgmt[MANAGEMENT_REASSOC_REQ]++; |
| 1612 | break; |
| 1613 | case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): |
| 1614 | stats->mgmt[MANAGEMENT_REASSOC_RESP]++; |
| 1615 | break; |
| 1616 | case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): |
| 1617 | stats->mgmt[MANAGEMENT_PROBE_REQ]++; |
| 1618 | break; |
| 1619 | case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): |
| 1620 | stats->mgmt[MANAGEMENT_PROBE_RESP]++; |
| 1621 | break; |
| 1622 | case cpu_to_le16(IEEE80211_STYPE_BEACON): |
| 1623 | stats->mgmt[MANAGEMENT_BEACON]++; |
| 1624 | break; |
| 1625 | case cpu_to_le16(IEEE80211_STYPE_ATIM): |
| 1626 | stats->mgmt[MANAGEMENT_ATIM]++; |
| 1627 | break; |
| 1628 | case cpu_to_le16(IEEE80211_STYPE_DISASSOC): |
| 1629 | stats->mgmt[MANAGEMENT_DISASSOC]++; |
| 1630 | break; |
| 1631 | case cpu_to_le16(IEEE80211_STYPE_AUTH): |
| 1632 | stats->mgmt[MANAGEMENT_AUTH]++; |
| 1633 | break; |
| 1634 | case cpu_to_le16(IEEE80211_STYPE_DEAUTH): |
| 1635 | stats->mgmt[MANAGEMENT_DEAUTH]++; |
| 1636 | break; |
| 1637 | case cpu_to_le16(IEEE80211_STYPE_ACTION): |
| 1638 | stats->mgmt[MANAGEMENT_ACTION]++; |
| 1639 | break; |
| 1640 | } |
| 1641 | } else if (ieee80211_is_ctl(fc)) { |
| 1642 | switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { |
| 1643 | case cpu_to_le16(IEEE80211_STYPE_BACK_REQ): |
| 1644 | stats->ctrl[CONTROL_BACK_REQ]++; |
| 1645 | break; |
| 1646 | case cpu_to_le16(IEEE80211_STYPE_BACK): |
| 1647 | stats->ctrl[CONTROL_BACK]++; |
| 1648 | break; |
| 1649 | case cpu_to_le16(IEEE80211_STYPE_PSPOLL): |
| 1650 | stats->ctrl[CONTROL_PSPOLL]++; |
| 1651 | break; |
| 1652 | case cpu_to_le16(IEEE80211_STYPE_RTS): |
| 1653 | stats->ctrl[CONTROL_RTS]++; |
| 1654 | break; |
| 1655 | case cpu_to_le16(IEEE80211_STYPE_CTS): |
| 1656 | stats->ctrl[CONTROL_CTS]++; |
| 1657 | break; |
| 1658 | case cpu_to_le16(IEEE80211_STYPE_ACK): |
| 1659 | stats->ctrl[CONTROL_ACK]++; |
| 1660 | break; |
| 1661 | case cpu_to_le16(IEEE80211_STYPE_CFEND): |
| 1662 | stats->ctrl[CONTROL_CFEND]++; |
| 1663 | break; |
| 1664 | case cpu_to_le16(IEEE80211_STYPE_CFENDACK): |
| 1665 | stats->ctrl[CONTROL_CFENDACK]++; |
| 1666 | break; |
| 1667 | } |
| 1668 | } else { |
| 1669 | /* data */ |
| 1670 | stats->data_cnt++; |
| 1671 | stats->data_bytes += len; |
| 1672 | } |
| 1673 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1674 | EXPORT_SYMBOL(il_update_stats); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1675 | #endif |
| 1676 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1677 | int il_force_reset(struct il_priv *il, bool external) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1678 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1679 | struct il_force_reset *force_reset; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1680 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1681 | if (test_bit(S_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1682 | return -EINVAL; |
| 1683 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1684 | force_reset = &il->force_reset; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1685 | force_reset->reset_request_count++; |
| 1686 | if (!external) { |
| 1687 | if (force_reset->last_force_reset_jiffies && |
| 1688 | time_after(force_reset->last_force_reset_jiffies + |
| 1689 | force_reset->reset_duration, jiffies)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1690 | D_INFO("force reset rejected\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1691 | force_reset->reset_reject_count++; |
| 1692 | return -EAGAIN; |
| 1693 | } |
| 1694 | } |
| 1695 | force_reset->reset_success_count++; |
| 1696 | force_reset->last_force_reset_jiffies = jiffies; |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1697 | |
| 1698 | /* |
| 1699 | * if the request is from external(ex: debugfs), |
| 1700 | * then always perform the request in regardless the module |
| 1701 | * parameter setting |
| 1702 | * if the request is from internal (uCode error or driver |
| 1703 | * detect failure), then fw_restart module parameter |
| 1704 | * need to be check before performing firmware reload |
| 1705 | */ |
| 1706 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1707 | if (!external && !il->cfg->mod_params->restart_fw) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1708 | D_INFO("Cancel firmware reload based on " |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1709 | "module parameter setting\n"); |
| 1710 | return 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1711 | } |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1712 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1713 | IL_ERR("On demand firmware reload\n"); |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1714 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1715 | /* Set the FW error flag -- cleared on il_down */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1716 | set_bit(S_FW_ERROR, &il->status); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1717 | wake_up(&il->wait_command_queue); |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1718 | /* |
| 1719 | * Keep the restart process from trying to send host |
| 1720 | * commands by clearing the INIT status bit |
| 1721 | */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1722 | clear_bit(S_READY, &il->status); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1723 | queue_work(il->workqueue, &il->restart); |
Stanislaw Gruszka | dd6d2a8 | 2011-06-08 15:28:26 +0200 | [diff] [blame] | 1724 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1725 | return 0; |
| 1726 | } |
| 1727 | |
| 1728 | int |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1729 | il_mac_change_interface(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1730 | struct ieee80211_vif *vif, |
| 1731 | enum nl80211_iftype newtype, bool newp2p) |
| 1732 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1733 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1734 | struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1735 | u32 modes; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1736 | int err; |
| 1737 | |
| 1738 | newtype = ieee80211_iftype_p2p(newtype, newp2p); |
| 1739 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1740 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1741 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1742 | if (!ctx->vif || !il_is_ready_rf(il)) { |
Johannes Berg | ffd8c74 | 2011-03-29 15:28:11 +0200 | [diff] [blame] | 1743 | /* |
| 1744 | * Huh? But wait ... this can maybe happen when |
| 1745 | * we're in the middle of a firmware restart! |
| 1746 | */ |
| 1747 | err = -EBUSY; |
| 1748 | goto out; |
| 1749 | } |
| 1750 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1751 | modes = ctx->interface_modes | ctx->exclusive_interface_modes; |
| 1752 | if (!(modes & BIT(newtype))) { |
| 1753 | err = -EOPNOTSUPP; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1754 | goto out; |
| 1755 | } |
| 1756 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 1757 | if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || |
| 1758 | (il->ctx.exclusive_interface_modes & BIT(newtype))) { |
| 1759 | err = -EINVAL; |
| 1760 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1761 | } |
| 1762 | |
| 1763 | /* success */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1764 | il_teardown_interface(il, vif, true); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1765 | vif->type = newtype; |
Johannes Berg | ffd8c74 | 2011-03-29 15:28:11 +0200 | [diff] [blame] | 1766 | vif->p2p = newp2p; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1767 | err = il_setup_interface(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1768 | WARN_ON(err); |
| 1769 | /* |
| 1770 | * We've switched internally, but submitting to the |
| 1771 | * device may have failed for some reason. Mask this |
| 1772 | * error, because otherwise mac80211 will not switch |
| 1773 | * (and set the interface type back) and we'll be |
| 1774 | * out of sync with it. |
| 1775 | */ |
| 1776 | err = 0; |
| 1777 | |
| 1778 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1779 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1780 | return err; |
| 1781 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1782 | EXPORT_SYMBOL(il_mac_change_interface); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1783 | |
| 1784 | /* |
| 1785 | * On every watchdog tick we check (latest) time stamp. If it does not |
| 1786 | * change during timeout period and queue is not empty we reset firmware. |
| 1787 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1788 | static int il_check_stuck_queue(struct il_priv *il, int cnt) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1789 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1790 | struct il_tx_queue *txq = &il->txq[cnt]; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1791 | struct il_queue *q = &txq->q; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1792 | unsigned long timeout; |
| 1793 | int ret; |
| 1794 | |
| 1795 | if (q->read_ptr == q->write_ptr) { |
| 1796 | txq->time_stamp = jiffies; |
| 1797 | return 0; |
| 1798 | } |
| 1799 | |
| 1800 | timeout = txq->time_stamp + |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1801 | msecs_to_jiffies(il->cfg->base_params->wd_timeout); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1802 | |
| 1803 | if (time_after(jiffies, timeout)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1804 | IL_ERR("Queue %d stuck for %u ms.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1805 | q->id, il->cfg->base_params->wd_timeout); |
| 1806 | ret = il_force_reset(il, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1807 | return (ret == -EAGAIN) ? 0 : 1; |
| 1808 | } |
| 1809 | |
| 1810 | return 0; |
| 1811 | } |
| 1812 | |
| 1813 | /* |
| 1814 | * Making watchdog tick be a quarter of timeout assure we will |
| 1815 | * discover the queue hung between timeout and 1.25*timeout |
| 1816 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1817 | #define IL_WD_TICK(timeout) ((timeout) / 4) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1818 | |
| 1819 | /* |
| 1820 | * Watchdog timer callback, we check each tx queue for stuck, if if hung |
| 1821 | * we reset the firmware. If everything is fine just rearm the timer. |
| 1822 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1823 | void il_bg_watchdog(unsigned long data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1824 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1825 | struct il_priv *il = (struct il_priv *)data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1826 | int cnt; |
| 1827 | unsigned long timeout; |
| 1828 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1829 | if (test_bit(S_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1830 | return; |
| 1831 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1832 | timeout = il->cfg->base_params->wd_timeout; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1833 | if (timeout == 0) |
| 1834 | return; |
| 1835 | |
| 1836 | /* monitor and check for stuck cmd queue */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1837 | if (il_check_stuck_queue(il, il->cmd_queue)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1838 | return; |
| 1839 | |
| 1840 | /* monitor and check for other stuck queues */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1841 | if (il_is_any_associated(il)) { |
| 1842 | for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1843 | /* skip as we already checked the command queue */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1844 | if (cnt == il->cmd_queue) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1845 | continue; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1846 | if (il_check_stuck_queue(il, cnt)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1847 | return; |
| 1848 | } |
| 1849 | } |
| 1850 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1851 | mod_timer(&il->watchdog, jiffies + |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1852 | msecs_to_jiffies(IL_WD_TICK(timeout))); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1853 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1854 | EXPORT_SYMBOL(il_bg_watchdog); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1855 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1856 | void il_setup_watchdog(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1857 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1858 | unsigned int timeout = il->cfg->base_params->wd_timeout; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1859 | |
| 1860 | if (timeout) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1861 | mod_timer(&il->watchdog, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1862 | jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1863 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1864 | del_timer(&il->watchdog); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1865 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1866 | EXPORT_SYMBOL(il_setup_watchdog); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1867 | |
| 1868 | /* |
| 1869 | * extended beacon time format |
| 1870 | * time in usec will be changed into a 32-bit value in extended:internal format |
| 1871 | * the extended part is the beacon counts |
| 1872 | * the internal part is the time in usec within one beacon interval |
| 1873 | */ |
| 1874 | u32 |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1875 | il_usecs_to_beacons(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1876 | u32 usec, u32 beacon_interval) |
| 1877 | { |
| 1878 | u32 quot; |
| 1879 | u32 rem; |
| 1880 | u32 interval = beacon_interval * TIME_UNIT; |
| 1881 | |
| 1882 | if (!interval || !usec) |
| 1883 | return 0; |
| 1884 | |
| 1885 | quot = (usec / interval) & |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1886 | (il_beacon_time_mask_high(il, |
| 1887 | il->hw_params.beacon_time_tsf_bits) >> |
| 1888 | il->hw_params.beacon_time_tsf_bits); |
| 1889 | rem = (usec % interval) & il_beacon_time_mask_low(il, |
| 1890 | il->hw_params.beacon_time_tsf_bits); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1891 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1892 | return (quot << il->hw_params.beacon_time_tsf_bits) + rem; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1893 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1894 | EXPORT_SYMBOL(il_usecs_to_beacons); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1895 | |
| 1896 | /* base is usually what we get from ucode with each received frame, |
| 1897 | * the same as HW timer counter counting down |
| 1898 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1899 | __le32 il_add_beacon_time(struct il_priv *il, u32 base, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1900 | u32 addon, u32 beacon_interval) |
| 1901 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1902 | u32 base_low = base & il_beacon_time_mask_low(il, |
| 1903 | il->hw_params.beacon_time_tsf_bits); |
| 1904 | u32 addon_low = addon & il_beacon_time_mask_low(il, |
| 1905 | il->hw_params.beacon_time_tsf_bits); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1906 | u32 interval = beacon_interval * TIME_UNIT; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1907 | u32 res = (base & il_beacon_time_mask_high(il, |
| 1908 | il->hw_params.beacon_time_tsf_bits)) + |
| 1909 | (addon & il_beacon_time_mask_high(il, |
| 1910 | il->hw_params.beacon_time_tsf_bits)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1911 | |
| 1912 | if (base_low > addon_low) |
| 1913 | res += base_low - addon_low; |
| 1914 | else if (base_low < addon_low) { |
| 1915 | res += interval + base_low - addon_low; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1916 | res += (1 << il->hw_params.beacon_time_tsf_bits); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1917 | } else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1918 | res += (1 << il->hw_params.beacon_time_tsf_bits); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1919 | |
| 1920 | return cpu_to_le32(res); |
| 1921 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1922 | EXPORT_SYMBOL(il_add_beacon_time); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1923 | |
| 1924 | #ifdef CONFIG_PM |
| 1925 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1926 | int il_pci_suspend(struct device *device) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1927 | { |
| 1928 | struct pci_dev *pdev = to_pci_dev(device); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1929 | struct il_priv *il = pci_get_drvdata(pdev); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1930 | |
| 1931 | /* |
| 1932 | * This function is called when system goes into suspend state |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1933 | * mac80211 will call il_mac_stop() from the mac80211 suspend function |
| 1934 | * first but since il_mac_stop() has no knowledge of who the caller is, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1935 | * it will not call apm_ops.stop() to stop the DMA operation. |
| 1936 | * Calling apm_ops.stop here to make sure we stop the DMA. |
| 1937 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1938 | il_apm_stop(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1939 | |
| 1940 | return 0; |
| 1941 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1942 | EXPORT_SYMBOL(il_pci_suspend); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1943 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1944 | int il_pci_resume(struct device *device) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1945 | { |
| 1946 | struct pci_dev *pdev = to_pci_dev(device); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1947 | struct il_priv *il = pci_get_drvdata(pdev); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1948 | bool hw_rfkill = false; |
| 1949 | |
| 1950 | /* |
| 1951 | * We disable the RETRY_TIMEOUT register (0x41) to keep |
| 1952 | * PCI Tx retries from interfering with C3 CPU state. |
| 1953 | */ |
| 1954 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); |
| 1955 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1956 | il_enable_interrupts(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1957 | |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1958 | if (!(_il_rd(il, CSR_GP_CNTRL) & |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1959 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) |
| 1960 | hw_rfkill = true; |
| 1961 | |
| 1962 | if (hw_rfkill) |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1963 | set_bit(S_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1964 | else |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1965 | clear_bit(S_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1966 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1967 | wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1968 | |
| 1969 | return 0; |
| 1970 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1971 | EXPORT_SYMBOL(il_pci_resume); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1972 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1973 | const struct dev_pm_ops il_pm_ops = { |
| 1974 | .suspend = il_pci_suspend, |
| 1975 | .resume = il_pci_resume, |
| 1976 | .freeze = il_pci_suspend, |
| 1977 | .thaw = il_pci_resume, |
| 1978 | .poweroff = il_pci_suspend, |
| 1979 | .restore = il_pci_resume, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1980 | }; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1981 | EXPORT_SYMBOL(il_pm_ops); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1982 | |
| 1983 | #endif /* CONFIG_PM */ |
| 1984 | |
| 1985 | static void |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1986 | il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1987 | { |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 1988 | if (test_bit(S_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1989 | return; |
| 1990 | |
| 1991 | if (!ctx->is_active) |
| 1992 | return; |
| 1993 | |
| 1994 | ctx->qos_data.def_qos_parm.qos_flags = 0; |
| 1995 | |
| 1996 | if (ctx->qos_data.qos_active) |
| 1997 | ctx->qos_data.def_qos_parm.qos_flags |= |
| 1998 | QOS_PARAM_FLG_UPDATE_EDCA_MSK; |
| 1999 | |
| 2000 | if (ctx->ht.enabled) |
| 2001 | ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; |
| 2002 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2003 | D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2004 | ctx->qos_data.qos_active, |
| 2005 | ctx->qos_data.def_qos_parm.qos_flags); |
| 2006 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2007 | il_send_cmd_pdu_async(il, ctx->qos_cmd, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2008 | sizeof(struct il_qosparam_cmd), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2009 | &ctx->qos_data.def_qos_parm, NULL); |
| 2010 | } |
| 2011 | |
| 2012 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2013 | * il_mac_config - mac80211 config callback |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2014 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2015 | int il_mac_config(struct ieee80211_hw *hw, u32 changed) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2016 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2017 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2018 | const struct il_channel_info *ch_info; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2019 | struct ieee80211_conf *conf = &hw->conf; |
| 2020 | struct ieee80211_channel *channel = conf->channel; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2021 | struct il_ht_config *ht_conf = &il->current_ht_config; |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2022 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2023 | unsigned long flags = 0; |
| 2024 | int ret = 0; |
| 2025 | u16 ch; |
| 2026 | int scan_active = 0; |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 2027 | bool ht_changed = false; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2028 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2029 | if (WARN_ON(!il->cfg->ops->legacy)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2030 | return -EOPNOTSUPP; |
| 2031 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2032 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2033 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2034 | D_MAC80211("enter to channel %d changed 0x%X\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2035 | channel->hw_value, changed); |
| 2036 | |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 2037 | if (unlikely(test_bit(S_SCANNING, &il->status))) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2038 | scan_active = 1; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2039 | D_MAC80211("scan active\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2040 | } |
| 2041 | |
| 2042 | if (changed & (IEEE80211_CONF_CHANGE_SMPS | |
| 2043 | IEEE80211_CONF_CHANGE_CHANNEL)) { |
| 2044 | /* mac80211 uses static for non-HT which is what we want */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2045 | il->current_ht_config.smps = conf->smps_mode; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2046 | |
| 2047 | /* |
| 2048 | * Recalculate chain counts. |
| 2049 | * |
| 2050 | * If monitor mode is enabled then mac80211 will |
| 2051 | * set up the SM PS mode to OFF if an HT channel is |
| 2052 | * configured. |
| 2053 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2054 | if (il->cfg->ops->hcmd->set_rxon_chain) |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2055 | il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2056 | } |
| 2057 | |
| 2058 | /* during scanning mac80211 will delay channel setting until |
| 2059 | * scan finish with changed = 0 |
| 2060 | */ |
| 2061 | if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2062 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2063 | if (scan_active) |
| 2064 | goto set_ch_out; |
| 2065 | |
| 2066 | ch = channel->hw_value; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2067 | ch_info = il_get_channel_info(il, channel->band, ch); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2068 | if (!il_is_channel_valid(ch_info)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2069 | D_MAC80211("leave - invalid channel\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2070 | ret = -EINVAL; |
| 2071 | goto set_ch_out; |
| 2072 | } |
| 2073 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2074 | if (il->iw_mode == NL80211_IFTYPE_ADHOC && |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2075 | !il_is_channel_ibss(ch_info)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2076 | D_MAC80211("leave - not IBSS channel\n"); |
Stanislaw Gruszka | eb85de3 | 2011-05-07 17:46:21 +0200 | [diff] [blame] | 2077 | ret = -EINVAL; |
| 2078 | goto set_ch_out; |
| 2079 | } |
| 2080 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2081 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2082 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2083 | /* Configure HT40 channels */ |
| 2084 | if (ctx->ht.enabled != conf_is_ht(conf)) { |
| 2085 | ctx->ht.enabled = conf_is_ht(conf); |
| 2086 | ht_changed = true; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2087 | } |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2088 | if (ctx->ht.enabled) { |
| 2089 | if (conf_is_ht40_minus(conf)) { |
| 2090 | ctx->ht.extension_chan_offset = |
| 2091 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; |
| 2092 | ctx->ht.is_40mhz = true; |
| 2093 | } else if (conf_is_ht40_plus(conf)) { |
| 2094 | ctx->ht.extension_chan_offset = |
| 2095 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; |
| 2096 | ctx->ht.is_40mhz = true; |
| 2097 | } else { |
| 2098 | ctx->ht.extension_chan_offset = |
| 2099 | IEEE80211_HT_PARAM_CHA_SEC_NONE; |
| 2100 | ctx->ht.is_40mhz = false; |
| 2101 | } |
| 2102 | } else |
| 2103 | ctx->ht.is_40mhz = false; |
| 2104 | |
| 2105 | /* |
| 2106 | * Default to no protection. Protection mode will |
| 2107 | * later be set from BSS config in il_ht_conf |
| 2108 | */ |
| 2109 | ctx->ht.protection = |
| 2110 | IEEE80211_HT_OP_MODE_PROTECTION_NONE; |
| 2111 | |
| 2112 | /* if we are switching from ht to 2.4 clear flags |
| 2113 | * from any ht related info since 2.4 does not |
| 2114 | * support ht */ |
| 2115 | if ((le16_to_cpu(ctx->staging.channel) != ch)) |
| 2116 | ctx->staging.flags = 0; |
| 2117 | |
| 2118 | il_set_rxon_channel(il, channel, ctx); |
| 2119 | il_set_rxon_ht(il, ht_conf); |
| 2120 | |
| 2121 | il_set_flags_for_band(il, ctx, channel->band, |
| 2122 | ctx->vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2123 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2124 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2125 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2126 | if (il->cfg->ops->legacy->update_bcast_stations) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2127 | ret = |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2128 | il->cfg->ops->legacy->update_bcast_stations(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2129 | |
| 2130 | set_ch_out: |
| 2131 | /* The list of supported rates and rate mask can be different |
| 2132 | * for each band; since the band may have changed, reset |
| 2133 | * the rate mask to what mac80211 lists */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2134 | il_set_rate(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2135 | } |
| 2136 | |
| 2137 | if (changed & (IEEE80211_CONF_CHANGE_PS | |
| 2138 | IEEE80211_CONF_CHANGE_IDLE)) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2139 | ret = il_power_update_mode(il, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2140 | if (ret) |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2141 | D_MAC80211("Error setting sleep level\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2142 | } |
| 2143 | |
| 2144 | if (changed & IEEE80211_CONF_CHANGE_POWER) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2145 | D_MAC80211("TX Power old=%d new=%d\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2146 | il->tx_power_user_lmt, conf->power_level); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2147 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2148 | il_set_tx_power(il, conf->power_level, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2149 | } |
| 2150 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2151 | if (!il_is_ready(il)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2152 | D_MAC80211("leave - not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2153 | goto out; |
| 2154 | } |
| 2155 | |
| 2156 | if (scan_active) |
| 2157 | goto out; |
| 2158 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2159 | if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) |
| 2160 | il_commit_rxon(il, ctx); |
| 2161 | else |
| 2162 | D_INFO("Not re-sending same RXON configuration.\n"); |
| 2163 | if (ht_changed) |
| 2164 | il_update_qos(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2165 | |
| 2166 | out: |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2167 | D_MAC80211("leave\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2168 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2169 | return ret; |
| 2170 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2171 | EXPORT_SYMBOL(il_mac_config); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2172 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2173 | void il_mac_reset_tsf(struct ieee80211_hw *hw, |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 2174 | struct ieee80211_vif *vif) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2175 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2176 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2177 | unsigned long flags; |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 2178 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2179 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2180 | if (WARN_ON(!il->cfg->ops->legacy)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2181 | return; |
| 2182 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2183 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2184 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2185 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2186 | spin_lock_irqsave(&il->lock, flags); |
| 2187 | memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); |
| 2188 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2189 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2190 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2191 | |
| 2192 | /* new association get rid of ibss beacon skb */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2193 | if (il->beacon_skb) |
| 2194 | dev_kfree_skb(il->beacon_skb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2195 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2196 | il->beacon_skb = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2197 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2198 | il->timestamp = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2199 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2200 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2201 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2202 | il_scan_cancel_timeout(il, 100); |
| 2203 | if (!il_is_ready_rf(il)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2204 | D_MAC80211("leave - not ready\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2205 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2206 | return; |
| 2207 | } |
| 2208 | |
| 2209 | /* we are restarting association process |
| 2210 | * clear RXON_FILTER_ASSOC_MSK bit |
| 2211 | */ |
| 2212 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2213 | il_commit_rxon(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2214 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2215 | il_set_rate(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2216 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2217 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2218 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2219 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2220 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2221 | EXPORT_SYMBOL(il_mac_reset_tsf); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2222 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2223 | static void il_ht_conf(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2224 | struct ieee80211_vif *vif) |
| 2225 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2226 | struct il_ht_config *ht_conf = &il->current_ht_config; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2227 | struct ieee80211_sta *sta; |
| 2228 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2229 | struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2230 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2231 | D_ASSOC("enter:\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2232 | |
| 2233 | if (!ctx->ht.enabled) |
| 2234 | return; |
| 2235 | |
| 2236 | ctx->ht.protection = |
| 2237 | bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; |
| 2238 | ctx->ht.non_gf_sta_present = |
| 2239 | !!(bss_conf->ht_operation_mode & |
| 2240 | IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); |
| 2241 | |
| 2242 | ht_conf->single_chain_sufficient = false; |
| 2243 | |
| 2244 | switch (vif->type) { |
| 2245 | case NL80211_IFTYPE_STATION: |
| 2246 | rcu_read_lock(); |
| 2247 | sta = ieee80211_find_sta(vif, bss_conf->bssid); |
| 2248 | if (sta) { |
| 2249 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; |
| 2250 | int maxstreams; |
| 2251 | |
| 2252 | maxstreams = (ht_cap->mcs.tx_params & |
| 2253 | IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) |
| 2254 | >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; |
| 2255 | maxstreams += 1; |
| 2256 | |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 2257 | if (ht_cap->mcs.rx_mask[1] == 0 && |
| 2258 | ht_cap->mcs.rx_mask[2] == 0) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2259 | ht_conf->single_chain_sufficient = true; |
| 2260 | if (maxstreams <= 1) |
| 2261 | ht_conf->single_chain_sufficient = true; |
| 2262 | } else { |
| 2263 | /* |
| 2264 | * If at all, this can only happen through a race |
| 2265 | * when the AP disconnects us while we're still |
| 2266 | * setting up the connection, in that case mac80211 |
| 2267 | * will soon tell us about that. |
| 2268 | */ |
| 2269 | ht_conf->single_chain_sufficient = true; |
| 2270 | } |
| 2271 | rcu_read_unlock(); |
| 2272 | break; |
| 2273 | case NL80211_IFTYPE_ADHOC: |
| 2274 | ht_conf->single_chain_sufficient = true; |
| 2275 | break; |
| 2276 | default: |
| 2277 | break; |
| 2278 | } |
| 2279 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2280 | D_ASSOC("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2281 | } |
| 2282 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2283 | static inline void il_set_no_assoc(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2284 | struct ieee80211_vif *vif) |
| 2285 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2286 | struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2287 | |
| 2288 | /* |
| 2289 | * inform the ucode that there is no longer an |
| 2290 | * association and that no more packets should be |
| 2291 | * sent |
| 2292 | */ |
| 2293 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
| 2294 | ctx->staging.assoc_id = 0; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2295 | il_commit_rxon(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2296 | } |
| 2297 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2298 | static void il_beacon_update(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2299 | struct ieee80211_vif *vif) |
| 2300 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2301 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2302 | unsigned long flags; |
| 2303 | __le64 timestamp; |
| 2304 | struct sk_buff *skb = ieee80211_beacon_get(hw, vif); |
| 2305 | |
| 2306 | if (!skb) |
| 2307 | return; |
| 2308 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2309 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2310 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2311 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2312 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2313 | if (!il->beacon_ctx) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2314 | IL_ERR("update beacon but no beacon context!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2315 | dev_kfree_skb(skb); |
| 2316 | return; |
| 2317 | } |
| 2318 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2319 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2320 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2321 | if (il->beacon_skb) |
| 2322 | dev_kfree_skb(il->beacon_skb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2323 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2324 | il->beacon_skb = skb; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2325 | |
| 2326 | timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2327 | il->timestamp = le64_to_cpu(timestamp); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2328 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2329 | D_MAC80211("leave\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2330 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2331 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2332 | if (!il_is_ready_rf(il)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2333 | D_MAC80211("leave - RF not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2334 | return; |
| 2335 | } |
| 2336 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2337 | il->cfg->ops->legacy->post_associate(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2338 | } |
| 2339 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2340 | void il_mac_bss_info_changed(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2341 | struct ieee80211_vif *vif, |
| 2342 | struct ieee80211_bss_conf *bss_conf, |
| 2343 | u32 changes) |
| 2344 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2345 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2346 | struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2347 | int ret; |
| 2348 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2349 | if (WARN_ON(!il->cfg->ops->legacy)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2350 | return; |
| 2351 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2352 | D_MAC80211("changes = 0x%X\n", changes); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2353 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2354 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2355 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2356 | if (!il_is_alive(il)) { |
| 2357 | mutex_unlock(&il->mutex); |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 2358 | return; |
| 2359 | } |
| 2360 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2361 | if (changes & BSS_CHANGED_QOS) { |
| 2362 | unsigned long flags; |
| 2363 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2364 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2365 | ctx->qos_data.qos_active = bss_conf->qos; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2366 | il_update_qos(il, ctx); |
| 2367 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2368 | } |
| 2369 | |
| 2370 | if (changes & BSS_CHANGED_BEACON_ENABLED) { |
| 2371 | /* |
| 2372 | * the add_interface code must make sure we only ever |
| 2373 | * have a single interface that could be beaconing at |
| 2374 | * any time. |
| 2375 | */ |
| 2376 | if (vif->bss_conf.enable_beacon) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2377 | il->beacon_ctx = ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2378 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2379 | il->beacon_ctx = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | if (changes & BSS_CHANGED_BSSID) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2383 | D_MAC80211("BSSID %pM\n", bss_conf->bssid); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2384 | |
| 2385 | /* |
| 2386 | * If there is currently a HW scan going on in the |
| 2387 | * background then we need to cancel it else the RXON |
| 2388 | * below/in post_associate will fail. |
| 2389 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2390 | if (il_scan_cancel_timeout(il, 100)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2391 | IL_WARN( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2392 | "Aborted scan still in progress after 100ms\n"); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2393 | D_MAC80211( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2394 | "leaving - scan abort failed.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2395 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2396 | return; |
| 2397 | } |
| 2398 | |
| 2399 | /* mac80211 only sets assoc when in STATION mode */ |
| 2400 | if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { |
| 2401 | memcpy(ctx->staging.bssid_addr, |
| 2402 | bss_conf->bssid, ETH_ALEN); |
| 2403 | |
| 2404 | /* currently needed in a few places */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2405 | memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2406 | } else { |
| 2407 | ctx->staging.filter_flags &= |
| 2408 | ~RXON_FILTER_ASSOC_MSK; |
| 2409 | } |
| 2410 | |
| 2411 | } |
| 2412 | |
| 2413 | /* |
| 2414 | * This needs to be after setting the BSSID in case |
| 2415 | * mac80211 decides to do both changes at once because |
| 2416 | * it will invoke post_associate. |
| 2417 | */ |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 2418 | if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2419 | il_beacon_update(hw, vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2420 | |
| 2421 | if (changes & BSS_CHANGED_ERP_PREAMBLE) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2422 | D_MAC80211("ERP_PREAMBLE %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2423 | bss_conf->use_short_preamble); |
| 2424 | if (bss_conf->use_short_preamble) |
| 2425 | ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
| 2426 | else |
| 2427 | ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; |
| 2428 | } |
| 2429 | |
| 2430 | if (changes & BSS_CHANGED_ERP_CTS_PROT) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2431 | D_MAC80211( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2432 | "ERP_CTS %d\n", bss_conf->use_cts_prot); |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 2433 | if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2434 | ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; |
| 2435 | else |
| 2436 | ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; |
| 2437 | if (bss_conf->use_cts_prot) |
| 2438 | ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; |
| 2439 | else |
| 2440 | ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; |
| 2441 | } |
| 2442 | |
| 2443 | if (changes & BSS_CHANGED_BASIC_RATES) { |
| 2444 | /* XXX use this information |
| 2445 | * |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2446 | * To do that, remove code from il_set_rate() and put something |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2447 | * like this here: |
| 2448 | * |
| 2449 | if (A-band) |
| 2450 | ctx->staging.ofdm_basic_rates = |
| 2451 | bss_conf->basic_rates; |
| 2452 | else |
| 2453 | ctx->staging.ofdm_basic_rates = |
| 2454 | bss_conf->basic_rates >> 4; |
| 2455 | ctx->staging.cck_basic_rates = |
| 2456 | bss_conf->basic_rates & 0xF; |
| 2457 | */ |
| 2458 | } |
| 2459 | |
| 2460 | if (changes & BSS_CHANGED_HT) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2461 | il_ht_conf(il, vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2462 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2463 | if (il->cfg->ops->hcmd->set_rxon_chain) |
| 2464 | il->cfg->ops->hcmd->set_rxon_chain(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2465 | } |
| 2466 | |
| 2467 | if (changes & BSS_CHANGED_ASSOC) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2468 | D_MAC80211("ASSOC %d\n", bss_conf->assoc); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2469 | if (bss_conf->assoc) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2470 | il->timestamp = bss_conf->timestamp; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2471 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2472 | if (!il_is_rfkill(il)) |
| 2473 | il->cfg->ops->legacy->post_associate(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2474 | } else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2475 | il_set_no_assoc(il, vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2476 | } |
| 2477 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2478 | if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2479 | D_MAC80211("Changes (%#x) while associated\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2480 | changes); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2481 | ret = il_send_rxon_assoc(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2482 | if (!ret) { |
| 2483 | /* Sync active_rxon with latest change. */ |
| 2484 | memcpy((void *)&ctx->active, |
| 2485 | &ctx->staging, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2486 | sizeof(struct il_rxon_cmd)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2487 | } |
| 2488 | } |
| 2489 | |
| 2490 | if (changes & BSS_CHANGED_BEACON_ENABLED) { |
| 2491 | if (vif->bss_conf.enable_beacon) { |
| 2492 | memcpy(ctx->staging.bssid_addr, |
| 2493 | bss_conf->bssid, ETH_ALEN); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2494 | memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); |
| 2495 | il->cfg->ops->legacy->config_ap(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2496 | } else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2497 | il_set_no_assoc(il, vif); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2498 | } |
| 2499 | |
| 2500 | if (changes & BSS_CHANGED_IBSS) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2501 | ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2502 | bss_conf->ibss_joined); |
| 2503 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2504 | IL_ERR("failed to %s IBSS station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2505 | bss_conf->ibss_joined ? "add" : "remove", |
| 2506 | bss_conf->bssid); |
| 2507 | } |
| 2508 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2509 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2510 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2511 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2512 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2513 | EXPORT_SYMBOL(il_mac_bss_info_changed); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2514 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2515 | irqreturn_t il_isr(int irq, void *data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2516 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2517 | struct il_priv *il = data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2518 | u32 inta, inta_mask; |
| 2519 | u32 inta_fh; |
| 2520 | unsigned long flags; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2521 | if (!il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2522 | return IRQ_NONE; |
| 2523 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2524 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2525 | |
| 2526 | /* Disable (but don't clear!) interrupts here to avoid |
| 2527 | * back-to-back ISRs and sporadic interrupts from our NIC. |
| 2528 | * If we have something to service, the tasklet will re-enable ints. |
| 2529 | * If we *don't* have something, we'll re-enable before leaving here. */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2530 | inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ |
| 2531 | _il_wr(il, CSR_INT_MASK, 0x00000000); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2532 | |
| 2533 | /* Discover which interrupts are active/pending */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2534 | inta = _il_rd(il, CSR_INT); |
| 2535 | inta_fh = _il_rd(il, CSR_FH_INT_STATUS); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2536 | |
| 2537 | /* Ignore interrupt if there's nothing in NIC to service. |
| 2538 | * This may be due to IRQ shared with another device, |
| 2539 | * or due to sporadic interrupts thrown from our NIC. */ |
| 2540 | if (!inta && !inta_fh) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2541 | D_ISR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2542 | "Ignore interrupt, inta == 0, inta_fh == 0\n"); |
| 2543 | goto none; |
| 2544 | } |
| 2545 | |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 2546 | if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2547 | /* Hardware disappeared. It might have already raised |
| 2548 | * an interrupt */ |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2549 | IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2550 | goto unplugged; |
| 2551 | } |
| 2552 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2553 | D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2554 | inta, inta_mask, inta_fh); |
| 2555 | |
| 2556 | inta &= ~CSR_INT_BIT_SCD; |
| 2557 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2558 | /* il_irq_tasklet() will service interrupts and re-enable them */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2559 | if (likely(inta || inta_fh)) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2560 | tasklet_schedule(&il->irq_tasklet); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2561 | |
| 2562 | unplugged: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2563 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2564 | return IRQ_HANDLED; |
| 2565 | |
| 2566 | none: |
| 2567 | /* re-enable interrupts here since we don't have anything to service. */ |
Stanislaw Gruszka | 93fd74e | 2011-04-28 11:51:30 +0200 | [diff] [blame] | 2568 | /* only Re-enable if disabled by irq */ |
Stanislaw Gruszka | a6766cc | 2011-11-15 13:09:01 +0100 | [diff] [blame] | 2569 | if (test_bit(S_INT_ENABLED, &il->status)) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2570 | il_enable_interrupts(il); |
| 2571 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2572 | return IRQ_NONE; |
| 2573 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2574 | EXPORT_SYMBOL(il_isr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2575 | |
| 2576 | /* |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2577 | * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2578 | * function. |
| 2579 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2580 | void il_tx_cmd_protection(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2581 | struct ieee80211_tx_info *info, |
| 2582 | __le16 fc, __le32 *tx_flags) |
| 2583 | { |
| 2584 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { |
| 2585 | *tx_flags |= TX_CMD_FLG_RTS_MSK; |
| 2586 | *tx_flags &= ~TX_CMD_FLG_CTS_MSK; |
| 2587 | *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; |
| 2588 | |
| 2589 | if (!ieee80211_is_mgmt(fc)) |
| 2590 | return; |
| 2591 | |
| 2592 | switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { |
| 2593 | case cpu_to_le16(IEEE80211_STYPE_AUTH): |
| 2594 | case cpu_to_le16(IEEE80211_STYPE_DEAUTH): |
| 2595 | case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): |
| 2596 | case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): |
| 2597 | *tx_flags &= ~TX_CMD_FLG_RTS_MSK; |
| 2598 | *tx_flags |= TX_CMD_FLG_CTS_MSK; |
| 2599 | break; |
| 2600 | } |
| 2601 | } else if (info->control.rates[0].flags & |
| 2602 | IEEE80211_TX_RC_USE_CTS_PROTECT) { |
| 2603 | *tx_flags &= ~TX_CMD_FLG_RTS_MSK; |
| 2604 | *tx_flags |= TX_CMD_FLG_CTS_MSK; |
| 2605 | *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; |
| 2606 | } |
| 2607 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2608 | EXPORT_SYMBOL(il_tx_cmd_protection); |