Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 | * redistributing this file, you may do so under either license. |
| 5 | * |
| 6 | * GPL LICENSE SUMMARY |
| 7 | * |
| 8 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of version 2 of the GNU General Public License as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 22 | * USA |
| 23 | * |
| 24 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 25 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 26 | * |
| 27 | * Contact Information: |
| 28 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 30 | * |
| 31 | * BSD LICENSE |
| 32 | * |
| 33 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. |
| 34 | * All rights reserved. |
| 35 | * |
| 36 | * Redistribution and use in source and binary forms, with or without |
| 37 | * modification, are permitted provided that the following conditions |
| 38 | * are met: |
| 39 | * |
| 40 | * * Redistributions of source code must retain the above copyright |
| 41 | * notice, this list of conditions and the following disclaimer. |
| 42 | * * Redistributions in binary form must reproduce the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer in |
| 44 | * the documentation and/or other materials provided with the |
| 45 | * distribution. |
| 46 | * * Neither the name Intel Corporation nor the names of its |
| 47 | * contributors may be used to endorse or promote products derived |
| 48 | * from this software without specific prior written permission. |
| 49 | * |
| 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 61 | * |
| 62 | *****************************************************************************/ |
| 63 | #include <linux/kernel.h> |
| 64 | #include <linux/slab.h> |
| 65 | #include <linux/skbuff.h> |
| 66 | #include <linux/netdevice.h> |
| 67 | #include <linux/etherdevice.h> |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 68 | #include <linux/ip.h> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 69 | #include <net/mac80211.h> |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 70 | #include <net/tcp.h> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 71 | |
| 72 | #include "iwl-op-mode.h" |
| 73 | #include "iwl-io.h" |
| 74 | #include "mvm.h" |
| 75 | #include "sta.h" |
| 76 | #include "time-event.h" |
| 77 | #include "iwl-eeprom-parse.h" |
| 78 | #include "fw-api-scan.h" |
| 79 | #include "iwl-phy-db.h" |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 80 | #include "testmode.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 81 | |
| 82 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { |
| 83 | { |
| 84 | .max = 1, |
Ilan Peer | 8eb3871 | 2013-06-01 20:17:18 +0300 | [diff] [blame] | 85 | .types = BIT(NL80211_IFTYPE_STATION), |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 86 | }, |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 87 | { |
| 88 | .max = 1, |
Ilan Peer | 8eb3871 | 2013-06-01 20:17:18 +0300 | [diff] [blame] | 89 | .types = BIT(NL80211_IFTYPE_AP) | |
| 90 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 91 | BIT(NL80211_IFTYPE_P2P_GO), |
| 92 | }, |
| 93 | { |
| 94 | .max = 1, |
| 95 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), |
| 96 | }, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { |
| 100 | { |
| 101 | .num_different_channels = 1, |
| 102 | .max_interfaces = 3, |
| 103 | .limits = iwl_mvm_limits, |
| 104 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), |
| 105 | }, |
| 106 | }; |
| 107 | |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 108 | #ifdef CONFIG_PM_SLEEP |
| 109 | static const struct nl80211_wowlan_tcp_data_token_feature |
| 110 | iwl_mvm_wowlan_tcp_token_feature = { |
| 111 | .min_len = 0, |
| 112 | .max_len = 255, |
| 113 | .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS, |
| 114 | }; |
| 115 | |
| 116 | static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = { |
| 117 | .tok = &iwl_mvm_wowlan_tcp_token_feature, |
| 118 | .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN - |
| 119 | sizeof(struct ethhdr) - |
| 120 | sizeof(struct iphdr) - |
| 121 | sizeof(struct tcphdr), |
| 122 | .data_interval_max = 65535, /* __le16 in API */ |
| 123 | .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN - |
| 124 | sizeof(struct ethhdr) - |
| 125 | sizeof(struct iphdr) - |
| 126 | sizeof(struct tcphdr), |
| 127 | .seq = true, |
| 128 | }; |
| 129 | #endif |
| 130 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 131 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
| 132 | { |
| 133 | int i; |
| 134 | |
| 135 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); |
| 136 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 137 | mvm->phy_ctxts[i].id = i; |
| 138 | mvm->phy_ctxts[i].ref = 0; |
| 139 | } |
| 140 | } |
| 141 | |
David Spinadel | 20f1a5d | 2013-08-21 09:14:27 +0300 | [diff] [blame] | 142 | static int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm) |
| 143 | { |
| 144 | /* we create the 802.11 header and SSID element */ |
| 145 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID) |
| 146 | return mvm->fw->ucode_capa.max_probe_length - 24 - 2; |
| 147 | return mvm->fw->ucode_capa.max_probe_length - 24 - 34; |
| 148 | } |
| 149 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 150 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
| 151 | { |
| 152 | struct ieee80211_hw *hw = mvm->hw; |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 153 | int num_mac, ret, i; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 154 | |
| 155 | /* Tell mac80211 our characteristics */ |
| 156 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
| 157 | IEEE80211_HW_SPECTRUM_MGMT | |
| 158 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
| 159 | IEEE80211_HW_QUEUE_CONTROL | |
| 160 | IEEE80211_HW_WANT_MONITOR_VIF | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 161 | IEEE80211_HW_SUPPORTS_PS | |
| 162 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | |
Johannes Berg | d2931bb | 2013-02-05 18:10:04 +0100 | [diff] [blame] | 163 | IEEE80211_HW_AMPDU_AGGREGATION | |
Hila Gonen | d64048e | 2013-03-13 18:00:03 +0200 | [diff] [blame] | 164 | IEEE80211_HW_TIMING_BEACON_ONLY | |
Emmanuel Grumbach | 147fc9b | 2013-07-28 11:00:52 +0300 | [diff] [blame] | 165 | IEEE80211_HW_CONNECTION_MONITOR | |
| 166 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | |
Alexander Bondar | e8e626a | 2013-10-16 00:21:34 +0200 | [diff] [blame] | 167 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 168 | |
Eytan Lifshitz | 19e737c | 2013-09-09 13:30:15 +0200 | [diff] [blame] | 169 | hw->queues = mvm->first_agg_queue; |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 170 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 171 | hw->rate_control_algorithm = "iwl-mvm-rs"; |
| 172 | |
| 173 | /* |
| 174 | * Enable 11w if advertised by firmware and software crypto |
| 175 | * is not enabled (as the firmware will interpret some mgmt |
| 176 | * packets, so enabling it with software crypto isn't safe) |
| 177 | */ |
| 178 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && |
| 179 | !iwlwifi_mod_params.sw_crypto) |
| 180 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; |
| 181 | |
Alexander Bondar | e8e626a | 2013-10-16 00:21:34 +0200 | [diff] [blame] | 182 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT) { |
| 183 | hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD; |
| 184 | hw->uapsd_queues = IWL_UAPSD_AC_INFO; |
| 185 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; |
| 186 | } |
| 187 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 188 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
| 189 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 190 | hw->chanctx_data_size = sizeof(u16); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 191 | |
| 192 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 193 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 194 | BIT(NL80211_IFTYPE_AP) | |
| 195 | BIT(NL80211_IFTYPE_P2P_GO) | |
| 196 | BIT(NL80211_IFTYPE_P2P_DEVICE); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 197 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 198 | /* IBSS has bugs in older versions */ |
| 199 | if (IWL_UCODE_API(mvm->fw->ucode_ver) >= 8) |
| 200 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC); |
| 201 | |
Luis R. Rodriguez | a2f73b6 | 2013-11-11 22:15:29 +0100 | [diff] [blame] | 202 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
| 203 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | |
| 204 | REGULATORY_DISABLE_BEACON_HINTS; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 205 | |
| 206 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
| 207 | hw->wiphy->n_iface_combinations = |
| 208 | ARRAY_SIZE(iwl_mvm_iface_combinations); |
| 209 | |
Ilan Peer | c451e6d | 2013-02-20 08:41:54 +0200 | [diff] [blame] | 210 | hw->wiphy->max_remain_on_channel_duration = 10000; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 211 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
| 212 | |
| 213 | /* Extract MAC address */ |
| 214 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); |
| 215 | hw->wiphy->addresses = mvm->addresses; |
| 216 | hw->wiphy->n_addresses = 1; |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 217 | |
| 218 | /* Extract additional MAC addresses if available */ |
| 219 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? |
| 220 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; |
| 221 | |
| 222 | for (i = 1; i < num_mac; i++) { |
| 223 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 224 | ETH_ALEN); |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 225 | mvm->addresses[i].addr[5]++; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 226 | hw->wiphy->n_addresses++; |
| 227 | } |
| 228 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 229 | iwl_mvm_reset_phy_ctxts(mvm); |
| 230 | |
David Spinadel | 20f1a5d | 2013-08-21 09:14:27 +0300 | [diff] [blame] | 231 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
| 232 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 233 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
| 234 | |
| 235 | if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels) |
| 236 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 237 | &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; |
| 238 | if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels) |
| 239 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 240 | &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; |
| 241 | |
| 242 | hw->wiphy->hw_version = mvm->trans->hw_id; |
| 243 | |
Alexander Bondar | ade5065 | 2013-04-03 16:28:47 +0300 | [diff] [blame] | 244 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 245 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 246 | else |
| 247 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 248 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 249 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SCHED_SCAN) { |
| 250 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 251 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; |
| 252 | hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; |
| 253 | /* we create the 802.11 header and zero length SSID IE. */ |
| 254 | hw->wiphy->max_sched_scan_ie_len = |
| 255 | SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; |
| 256 | } |
| 257 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 258 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
Haim Dreyfuss | 61f6325 | 2013-11-03 23:02:59 +0200 | [diff] [blame] | 259 | NL80211_FEATURE_P2P_GO_OPPPS | |
| 260 | NL80211_FEATURE_LOW_PRIORITY_SCAN; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 261 | |
| 262 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
| 263 | |
| 264 | #ifdef CONFIG_PM_SLEEP |
| 265 | if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && |
| 266 | mvm->trans->ops->d3_suspend && |
| 267 | mvm->trans->ops->d3_resume && |
| 268 | device_can_wakeup(mvm->trans->dev)) { |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 269 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
| 270 | WIPHY_WOWLAN_DISCONNECT | |
| 271 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 272 | WIPHY_WOWLAN_RFKILL_RELEASE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 273 | if (!iwlwifi_mod_params.sw_crypto) |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 274 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 275 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 276 | WIPHY_WOWLAN_4WAY_HANDSHAKE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 277 | |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 278 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; |
| 279 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; |
| 280 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; |
| 281 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; |
| 282 | hw->wiphy->wowlan = &mvm->wowlan; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 283 | } |
| 284 | #endif |
| 285 | |
| 286 | ret = iwl_mvm_leds_init(mvm); |
| 287 | if (ret) |
| 288 | return ret; |
| 289 | |
Emmanuel Grumbach | b7327d8 | 2013-06-24 15:44:03 +0300 | [diff] [blame] | 290 | ret = ieee80211_register_hw(mvm->hw); |
| 291 | if (ret) |
| 292 | iwl_mvm_leds_exit(mvm); |
| 293 | |
| 294 | return ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
| 298 | struct ieee80211_tx_control *control, |
| 299 | struct sk_buff *skb) |
| 300 | { |
| 301 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 302 | |
Eytan Lifshitz | 9ee718a | 2013-05-19 19:14:41 +0300 | [diff] [blame] | 303 | if (iwl_mvm_is_radio_killed(mvm)) { |
| 304 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 305 | goto drop; |
| 306 | } |
| 307 | |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 308 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 309 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) |
| 310 | goto drop; |
| 311 | |
| 312 | if (control->sta) { |
| 313 | if (iwl_mvm_tx_skb(mvm, skb, control->sta)) |
| 314 | goto drop; |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) |
| 319 | goto drop; |
| 320 | return; |
| 321 | drop: |
| 322 | ieee80211_free_txskb(hw, skb); |
| 323 | } |
| 324 | |
| 325 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
| 326 | struct ieee80211_vif *vif, |
| 327 | enum ieee80211_ampdu_mlme_action action, |
| 328 | struct ieee80211_sta *sta, u16 tid, |
| 329 | u16 *ssn, u8 buf_size) |
| 330 | { |
| 331 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 332 | int ret; |
| 333 | |
| 334 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", |
| 335 | sta->addr, tid, action); |
| 336 | |
| 337 | if (!(mvm->nvm_data->sku_cap_11n_enable)) |
| 338 | return -EACCES; |
| 339 | |
| 340 | mutex_lock(&mvm->mutex); |
| 341 | |
| 342 | switch (action) { |
| 343 | case IEEE80211_AMPDU_RX_START: |
| 344 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) { |
| 345 | ret = -EINVAL; |
| 346 | break; |
| 347 | } |
| 348 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); |
| 349 | break; |
| 350 | case IEEE80211_AMPDU_RX_STOP: |
| 351 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); |
| 352 | break; |
| 353 | case IEEE80211_AMPDU_TX_START: |
Emmanuel Grumbach | 5d158ef | 2013-02-19 14:39:58 +0200 | [diff] [blame] | 354 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) { |
| 355 | ret = -EINVAL; |
| 356 | break; |
| 357 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 358 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
| 359 | break; |
| 360 | case IEEE80211_AMPDU_TX_STOP_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 361 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
| 362 | break; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 363 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 364 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 365 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 366 | break; |
| 367 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 368 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); |
| 369 | break; |
| 370 | default: |
| 371 | WARN_ON_ONCE(1); |
| 372 | ret = -EINVAL; |
| 373 | break; |
| 374 | } |
| 375 | mutex_unlock(&mvm->mutex); |
| 376 | |
| 377 | return ret; |
| 378 | } |
| 379 | |
| 380 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, |
| 381 | struct ieee80211_vif *vif) |
| 382 | { |
| 383 | struct iwl_mvm *mvm = data; |
| 384 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 385 | |
| 386 | mvmvif->uploaded = false; |
| 387 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 388 | |
| 389 | /* does this make sense at all? */ |
| 390 | mvmvif->color++; |
| 391 | |
| 392 | spin_lock_bh(&mvm->time_event_lock); |
| 393 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); |
| 394 | spin_unlock_bh(&mvm->time_event_lock); |
| 395 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 396 | mvmvif->phy_ctxt = NULL; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) |
| 400 | { |
| 401 | iwl_trans_stop_device(mvm->trans); |
| 402 | iwl_trans_stop_hw(mvm->trans, false); |
| 403 | |
| 404 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 405 | |
| 406 | /* just in case one was running */ |
| 407 | ieee80211_remain_on_channel_expired(mvm->hw); |
| 408 | |
| 409 | ieee80211_iterate_active_interfaces_atomic( |
| 410 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 411 | iwl_mvm_cleanup_iterator, mvm); |
| 412 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 413 | mvm->p2p_device_vif = NULL; |
| 414 | |
| 415 | iwl_mvm_reset_phy_ctxts(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 416 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
| 417 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); |
| 418 | |
| 419 | ieee80211_wake_queues(mvm->hw); |
| 420 | |
| 421 | mvm->vif_count = 0; |
Emmanuel Grumbach | 113a044 | 2013-07-02 14:16:38 +0300 | [diff] [blame] | 422 | mvm->rx_ba_sessions = 0; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) |
| 426 | { |
| 427 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 428 | int ret; |
| 429 | |
| 430 | mutex_lock(&mvm->mutex); |
| 431 | |
| 432 | /* Clean up some internal and mac80211 state on restart */ |
| 433 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 434 | iwl_mvm_restart_cleanup(mvm); |
| 435 | |
| 436 | ret = iwl_mvm_up(mvm); |
| 437 | mutex_unlock(&mvm->mutex); |
| 438 | |
| 439 | return ret; |
| 440 | } |
| 441 | |
| 442 | static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw) |
| 443 | { |
| 444 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 445 | int ret; |
| 446 | |
| 447 | mutex_lock(&mvm->mutex); |
| 448 | |
| 449 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 450 | ret = iwl_mvm_update_quotas(mvm, NULL); |
| 451 | if (ret) |
| 452 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", |
| 453 | ret); |
| 454 | |
| 455 | mutex_unlock(&mvm->mutex); |
| 456 | } |
| 457 | |
| 458 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) |
| 459 | { |
| 460 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 461 | |
| 462 | flush_work(&mvm->async_handlers_wk); |
| 463 | |
| 464 | mutex_lock(&mvm->mutex); |
| 465 | /* async_handlers_wk is now blocked */ |
| 466 | |
| 467 | /* |
| 468 | * The work item could be running or queued if the |
| 469 | * ROC time event stops just as we get here. |
| 470 | */ |
| 471 | cancel_work_sync(&mvm->roc_done_wk); |
| 472 | |
| 473 | iwl_trans_stop_device(mvm->trans); |
| 474 | iwl_trans_stop_hw(mvm->trans, false); |
| 475 | |
| 476 | iwl_mvm_async_handlers_purge(mvm); |
| 477 | /* async_handlers_list is empty and will stay empty: HW is stopped */ |
| 478 | |
| 479 | /* the fw is stopped, the aux sta is dead: clean up driver state */ |
| 480 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); |
| 481 | |
| 482 | mutex_unlock(&mvm->mutex); |
| 483 | |
| 484 | /* |
| 485 | * The worker might have been waiting for the mutex, let it run and |
| 486 | * discover that its list is now empty. |
| 487 | */ |
| 488 | cancel_work_sync(&mvm->async_handlers_wk); |
| 489 | } |
| 490 | |
| 491 | static void iwl_mvm_pm_disable_iterator(void *data, u8 *mac, |
| 492 | struct ieee80211_vif *vif) |
| 493 | { |
| 494 | struct iwl_mvm *mvm = data; |
| 495 | int ret; |
| 496 | |
| 497 | ret = iwl_mvm_power_disable(mvm, vif); |
| 498 | if (ret) |
| 499 | IWL_ERR(mvm, "failed to disable power management\n"); |
| 500 | } |
| 501 | |
| 502 | static void iwl_mvm_power_update_iterator(void *data, u8 *mac, |
| 503 | struct ieee80211_vif *vif) |
| 504 | { |
| 505 | struct iwl_mvm *mvm = data; |
| 506 | |
| 507 | iwl_mvm_power_update_mode(mvm, vif); |
| 508 | } |
| 509 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 510 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
| 511 | { |
| 512 | u16 i; |
| 513 | |
| 514 | lockdep_assert_held(&mvm->mutex); |
| 515 | |
| 516 | for (i = 0; i < NUM_PHY_CTX; i++) |
| 517 | if (!mvm->phy_ctxts[i].ref) |
| 518 | return &mvm->phy_ctxts[i]; |
| 519 | |
| 520 | IWL_ERR(mvm, "No available PHY context\n"); |
| 521 | return NULL; |
| 522 | } |
| 523 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 524 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
| 525 | struct ieee80211_vif *vif) |
| 526 | { |
| 527 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 528 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 529 | int ret; |
| 530 | |
| 531 | /* |
| 532 | * Not much to do here. The stack will not allow interface |
| 533 | * types or combinations that we didn't advertise, so we |
| 534 | * don't really have to check the types. |
| 535 | */ |
| 536 | |
| 537 | mutex_lock(&mvm->mutex); |
| 538 | |
Eliad Peller | e89044d | 2013-07-16 17:33:26 +0300 | [diff] [blame] | 539 | /* Allocate resources for the MAC context, and add it to the fw */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 540 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
| 541 | if (ret) |
| 542 | goto out_unlock; |
| 543 | |
| 544 | /* |
Ilan Peer | ea183d0 | 2013-07-23 14:41:53 +0300 | [diff] [blame] | 545 | * TODO: remove this temporary code. |
| 546 | * Currently MVM FW supports power management only on single MAC. |
| 547 | * If new interface added, disable PM on existing interface. |
| 548 | * P2P device is a special case, since it is handled by FW similary to |
| 549 | * scan. If P2P deviced is added, PM remains enabled on existing |
| 550 | * interface. |
| 551 | * Note: the method below does not count the new interface being added |
| 552 | * at this moment. |
| 553 | */ |
| 554 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 555 | mvm->vif_count++; |
| 556 | if (mvm->vif_count > 1) { |
| 557 | IWL_DEBUG_MAC80211(mvm, |
| 558 | "Disable power on existing interfaces\n"); |
| 559 | ieee80211_iterate_active_interfaces_atomic( |
| 560 | mvm->hw, |
| 561 | IEEE80211_IFACE_ITER_NORMAL, |
| 562 | iwl_mvm_pm_disable_iterator, mvm); |
| 563 | } |
| 564 | |
| 565 | /* |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 566 | * The AP binding flow can be done only after the beacon |
| 567 | * template is configured (which happens only in the mac80211 |
| 568 | * start_ap() flow), and adding the broadcast station can happen |
| 569 | * only after the binding. |
| 570 | * In addition, since modifying the MAC before adding a bcast |
| 571 | * station is not allowed by the FW, delay the adding of MAC context to |
| 572 | * the point where we can also add the bcast station. |
| 573 | * In short: there's not much we can do at this point, other than |
| 574 | * allocating resources :) |
| 575 | */ |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 576 | if (vif->type == NL80211_IFTYPE_AP || |
| 577 | vif->type == NL80211_IFTYPE_ADHOC) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 578 | u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif); |
| 579 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, |
| 580 | qmask); |
| 581 | if (ret) { |
| 582 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); |
| 583 | goto out_release; |
| 584 | } |
| 585 | |
Emmanuel Grumbach | 77740cb | 2013-06-26 23:51:41 +0300 | [diff] [blame] | 586 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 587 | goto out_unlock; |
| 588 | } |
| 589 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 590 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 591 | if (ret) |
| 592 | goto out_release; |
| 593 | |
| 594 | /* |
| 595 | * Update power state on the new interface. Admittedly, based on |
| 596 | * mac80211 logics this power update will disable power management |
| 597 | */ |
| 598 | iwl_mvm_power_update_mode(mvm, vif); |
| 599 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 600 | /* beacon filtering */ |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 601 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
| 602 | if (ret) |
| 603 | goto out_remove_mac; |
| 604 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 605 | if (!mvm->bf_allowed_vif && |
Hila Gonen | 5dca7c2 | 2013-07-16 11:15:35 +0300 | [diff] [blame] | 606 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
| 607 | mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){ |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 608 | mvm->bf_allowed_vif = mvmvif; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 609 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
| 610 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 611 | } |
| 612 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 613 | /* |
| 614 | * P2P_DEVICE interface does not have a channel context assigned to it, |
| 615 | * so a dedicated PHY context is allocated to it and the corresponding |
| 616 | * MAC context is bound to it at this stage. |
| 617 | */ |
| 618 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 619 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 620 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 621 | if (!mvmvif->phy_ctxt) { |
| 622 | ret = -ENOSPC; |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 623 | goto out_free_bf; |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 624 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 625 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 626 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 627 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 628 | if (ret) |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 629 | goto out_unref_phy; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 630 | |
| 631 | ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta); |
| 632 | if (ret) |
| 633 | goto out_unbind; |
| 634 | |
| 635 | /* Save a pointer to p2p device vif, so it can later be used to |
| 636 | * update the p2p device MAC when a GO is started/stopped */ |
| 637 | mvm->p2p_device_vif = vif; |
| 638 | } |
| 639 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 640 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 641 | goto out_unlock; |
| 642 | |
| 643 | out_unbind: |
| 644 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 645 | out_unref_phy: |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 646 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 647 | out_free_bf: |
| 648 | if (mvm->bf_allowed_vif == mvmvif) { |
| 649 | mvm->bf_allowed_vif = NULL; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 650 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 651 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 652 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 653 | out_remove_mac: |
| 654 | mvmvif->phy_ctxt = NULL; |
| 655 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 656 | out_release: |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 657 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 658 | mvm->vif_count--; |
Alexander Bondar | 4bf881f | 2013-05-29 10:19:50 +0300 | [diff] [blame] | 659 | ieee80211_iterate_active_interfaces( |
| 660 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 661 | iwl_mvm_power_update_iterator, mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 662 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 663 | out_unlock: |
| 664 | mutex_unlock(&mvm->mutex); |
| 665 | |
| 666 | return ret; |
| 667 | } |
| 668 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 669 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
| 670 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 671 | { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 672 | u32 tfd_msk = 0, ac; |
| 673 | |
| 674 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 675 | if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) |
| 676 | tfd_msk |= BIT(vif->hw_queue[ac]); |
| 677 | |
| 678 | if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE) |
| 679 | tfd_msk |= BIT(vif->cab_queue); |
| 680 | |
| 681 | if (tfd_msk) { |
| 682 | mutex_lock(&mvm->mutex); |
| 683 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); |
| 684 | mutex_unlock(&mvm->mutex); |
| 685 | } |
| 686 | |
| 687 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 688 | /* |
| 689 | * Flush the ROC worker which will flush the OFFCHANNEL queue. |
| 690 | * We assume here that all the packets sent to the OFFCHANNEL |
| 691 | * queue are sent in ROC session. |
| 692 | */ |
| 693 | flush_work(&mvm->roc_done_wk); |
| 694 | } else { |
| 695 | /* |
| 696 | * By now, all the AC queues are empty. The AGG queues are |
| 697 | * empty too. We already got all the Tx responses for all the |
| 698 | * packets in the queues. The drain work can have been |
Emmanuel Grumbach | 0742a75 | 2013-06-10 14:10:33 +0300 | [diff] [blame] | 699 | * triggered. Flush it. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 700 | */ |
| 701 | flush_work(&mvm->sta_drained_wk); |
| 702 | } |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, |
| 706 | struct ieee80211_vif *vif) |
| 707 | { |
| 708 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 709 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 710 | |
| 711 | iwl_mvm_prepare_mac_removal(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 712 | |
| 713 | mutex_lock(&mvm->mutex); |
| 714 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 715 | if (mvm->bf_allowed_vif == mvmvif) { |
| 716 | mvm->bf_allowed_vif = NULL; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 717 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 718 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 719 | } |
| 720 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 721 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
| 722 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 723 | /* |
| 724 | * For AP/GO interface, the tear down of the resources allocated to the |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 725 | * interface is be handled as part of the stop_ap flow. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 726 | */ |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 727 | if (vif->type == NL80211_IFTYPE_AP || |
| 728 | vif->type == NL80211_IFTYPE_ADHOC) { |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 729 | #ifdef CONFIG_NL80211_TESTMODE |
| 730 | if (vif == mvm->noa_vif) { |
| 731 | mvm->noa_vif = NULL; |
| 732 | mvm->noa_duration = 0; |
| 733 | } |
| 734 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 735 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); |
| 736 | goto out_release; |
| 737 | } |
| 738 | |
| 739 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 740 | mvm->p2p_device_vif = NULL; |
| 741 | iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 742 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 743 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 744 | mvmvif->phy_ctxt = NULL; |
| 745 | } |
| 746 | |
| 747 | /* |
| 748 | * TODO: remove this temporary code. |
| 749 | * Currently MVM FW supports power management only on single MAC. |
| 750 | * Check if only one additional interface remains after removing |
| 751 | * current one. Update power mode on the remaining interface. |
| 752 | */ |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 753 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 754 | mvm->vif_count--; |
| 755 | IWL_DEBUG_MAC80211(mvm, "Currently %d interfaces active\n", |
| 756 | mvm->vif_count); |
| 757 | if (mvm->vif_count == 1) { |
| 758 | ieee80211_iterate_active_interfaces( |
| 759 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 760 | iwl_mvm_power_update_iterator, mvm); |
| 761 | } |
| 762 | |
| 763 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 764 | |
| 765 | out_release: |
| 766 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 767 | mutex_unlock(&mvm->mutex); |
| 768 | } |
| 769 | |
Matti Gottlieb | 88f2fd7 | 2013-07-09 15:25:46 +0300 | [diff] [blame] | 770 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 771 | s8 tx_power) |
| 772 | { |
| 773 | /* FW is in charge of regulatory enforcement */ |
| 774 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { |
| 775 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, |
| 776 | .pwr_restriction = cpu_to_le16(tx_power), |
| 777 | }; |
| 778 | |
| 779 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, |
| 780 | sizeof(reduce_txpwr_cmd), |
| 781 | &reduce_txpwr_cmd); |
| 782 | } |
| 783 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 784 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
| 785 | { |
| 786 | return 0; |
| 787 | } |
| 788 | |
| 789 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, |
| 790 | unsigned int changed_flags, |
| 791 | unsigned int *total_flags, |
| 792 | u64 multicast) |
| 793 | { |
| 794 | *total_flags = 0; |
| 795 | } |
| 796 | |
Emmanuel Grumbach | 51b6b9e | 2013-05-02 15:01:24 +0300 | [diff] [blame] | 797 | static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm, |
| 798 | struct ieee80211_vif *vif) |
| 799 | { |
| 800 | struct iwl_mcast_filter_cmd mcast_filter_cmd = { |
| 801 | .pass_all = 1, |
| 802 | }; |
| 803 | |
| 804 | memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 805 | |
| 806 | return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC, |
| 807 | sizeof(mcast_filter_cmd), |
| 808 | &mcast_filter_cmd); |
| 809 | } |
| 810 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 811 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
| 812 | struct ieee80211_vif *vif, |
| 813 | struct ieee80211_bss_conf *bss_conf, |
| 814 | u32 changes) |
| 815 | { |
| 816 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 817 | int ret; |
| 818 | |
| 819 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 820 | if (ret) |
| 821 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 822 | |
| 823 | if (changes & BSS_CHANGED_ASSOC) { |
| 824 | if (bss_conf->assoc) { |
| 825 | /* add quota for this interface */ |
| 826 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 827 | if (ret) { |
| 828 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 829 | return; |
| 830 | } |
Emmanuel Grumbach | 51b6b9e | 2013-05-02 15:01:24 +0300 | [diff] [blame] | 831 | iwl_mvm_configure_mcast_filter(mvm, vif); |
Johannes Berg | 016d27e | 2013-05-03 11:16:15 +0200 | [diff] [blame] | 832 | |
| 833 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, |
| 834 | &mvm->status)) { |
| 835 | /* |
| 836 | * If we're restarting then the firmware will |
| 837 | * obviously have lost synchronisation with |
| 838 | * the AP. It will attempt to synchronise by |
| 839 | * itself, but we can make it more reliable by |
| 840 | * scheduling a session protection time event. |
| 841 | * |
| 842 | * The firmware needs to receive a beacon to |
| 843 | * catch up with synchronisation, use 110% of |
| 844 | * the beacon interval. |
| 845 | * |
| 846 | * Set a large maximum delay to allow for more |
| 847 | * than a single interface. |
| 848 | */ |
| 849 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; |
| 850 | iwl_mvm_protect_session(mvm, vif, dur, dur, |
| 851 | 5 * dur); |
| 852 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 853 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
| 854 | /* remove AP station now that the MAC is unassoc */ |
| 855 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); |
| 856 | if (ret) |
| 857 | IWL_ERR(mvm, "failed to remove AP station\n"); |
| 858 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 859 | /* remove quota for this interface */ |
| 860 | ret = iwl_mvm_update_quotas(mvm, NULL); |
| 861 | if (ret) |
| 862 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 863 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 864 | |
| 865 | /* reset rssi values */ |
| 866 | mvmvif->bf_data.ave_beacon_signal = 0; |
| 867 | |
Alexander Bondar | e8e626a | 2013-10-16 00:21:34 +0200 | [diff] [blame] | 868 | if (!(mvm->fw->ucode_capa.flags & |
| 869 | IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT)) { |
Alexander Bondar | e811ada | 2013-03-10 15:29:44 +0200 | [diff] [blame] | 870 | /* Workaround for FW bug, otherwise FW disables device |
| 871 | * power save upon disassociation |
| 872 | */ |
| 873 | ret = iwl_mvm_power_update_mode(mvm, vif); |
| 874 | if (ret) |
| 875 | IWL_ERR(mvm, "failed to update power mode\n"); |
| 876 | } |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 877 | iwl_mvm_bt_coex_vif_change(mvm); |
Alexander Bondar | 989c650 | 2013-05-16 17:34:17 +0300 | [diff] [blame] | 878 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
Johannes Berg | 210a544 | 2013-01-24 23:48:23 +0100 | [diff] [blame] | 879 | /* |
| 880 | * We received a beacon _after_ association so |
| 881 | * remove the session protection. |
| 882 | */ |
| 883 | iwl_mvm_remove_time_event(mvm, mvmvif, |
| 884 | &mvmvif->time_event_data); |
Alexander Bondar | e3c588e | 2013-04-07 14:08:59 +0300 | [diff] [blame] | 885 | } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_QOS)) { |
Alexander Bondar | 4bf881f | 2013-05-29 10:19:50 +0300 | [diff] [blame] | 886 | ret = iwl_mvm_power_update_mode(mvm, vif); |
| 887 | if (ret) |
| 888 | IWL_ERR(mvm, "failed to update power mode\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 889 | } |
Matti Gottlieb | 88f2fd7 | 2013-07-09 15:25:46 +0300 | [diff] [blame] | 890 | if (changes & BSS_CHANGED_TXPOWER) { |
| 891 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", |
| 892 | bss_conf->txpower); |
| 893 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); |
| 894 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 895 | |
| 896 | if (changes & BSS_CHANGED_CQM) { |
| 897 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed"); |
| 898 | /* reset cqm events tracking */ |
| 899 | mvmvif->bf_data.last_cqm_event = 0; |
| 900 | ret = iwl_mvm_update_beacon_filter(mvm, vif); |
| 901 | if (ret) |
| 902 | IWL_ERR(mvm, "failed to update CQM thresholds\n"); |
| 903 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 904 | } |
| 905 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 906 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
| 907 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 908 | { |
| 909 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 910 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 911 | int ret; |
| 912 | |
| 913 | mutex_lock(&mvm->mutex); |
| 914 | |
| 915 | /* Send the beacon template */ |
| 916 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); |
| 917 | if (ret) |
| 918 | goto out_unlock; |
| 919 | |
| 920 | /* Add the mac context */ |
| 921 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 922 | if (ret) |
| 923 | goto out_unlock; |
| 924 | |
| 925 | /* Perform the binding */ |
| 926 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 927 | if (ret) |
| 928 | goto out_remove; |
| 929 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 930 | mvmvif->ap_ibss_active = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 931 | |
| 932 | /* Send the bcast station. At this stage the TBTT and DTIM time events |
| 933 | * are added and applied to the scheduler */ |
| 934 | ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta); |
| 935 | if (ret) |
| 936 | goto out_unbind; |
| 937 | |
| 938 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 939 | if (ret) |
| 940 | goto out_rm_bcast; |
| 941 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 942 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 943 | if (vif->p2p && mvm->p2p_device_vif) |
| 944 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); |
| 945 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 946 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | dac94da | 2013-06-18 07:35:27 +0300 | [diff] [blame] | 947 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 948 | mutex_unlock(&mvm->mutex); |
| 949 | return 0; |
| 950 | |
| 951 | out_rm_bcast: |
| 952 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 953 | out_unbind: |
| 954 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 955 | out_remove: |
| 956 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 957 | out_unlock: |
| 958 | mutex_unlock(&mvm->mutex); |
| 959 | return ret; |
| 960 | } |
| 961 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 962 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
| 963 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 964 | { |
| 965 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 966 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 967 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 968 | iwl_mvm_prepare_mac_removal(mvm, vif); |
| 969 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 970 | mutex_lock(&mvm->mutex); |
| 971 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 972 | mvmvif->ap_ibss_active = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 973 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 974 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | dac94da | 2013-06-18 07:35:27 +0300 | [diff] [blame] | 975 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 976 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 977 | if (vif->p2p && mvm->p2p_device_vif) |
| 978 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); |
| 979 | |
| 980 | iwl_mvm_update_quotas(mvm, NULL); |
| 981 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 982 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 983 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 984 | |
| 985 | mutex_unlock(&mvm->mutex); |
| 986 | } |
| 987 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 988 | static void |
| 989 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, |
| 990 | struct ieee80211_vif *vif, |
| 991 | struct ieee80211_bss_conf *bss_conf, |
| 992 | u32 changes) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 993 | { |
Avri Altman | 8a5e366 | 2013-11-12 19:16:03 +0200 | [diff] [blame] | 994 | enum ieee80211_bss_change ht_change = BSS_CHANGED_ERP_CTS_PROT | |
| 995 | BSS_CHANGED_HT | |
| 996 | BSS_CHANGED_BANDWIDTH; |
| 997 | int ret; |
| 998 | |
| 999 | if (changes & ht_change) { |
| 1000 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 1001 | if (ret) |
| 1002 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 1003 | } |
| 1004 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1005 | /* Need to send a new beacon template to the FW */ |
| 1006 | if (changes & BSS_CHANGED_BEACON) { |
| 1007 | if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) |
| 1008 | IWL_WARN(mvm, "Failed updating beacon data\n"); |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, |
| 1013 | struct ieee80211_vif *vif, |
| 1014 | struct ieee80211_bss_conf *bss_conf, |
| 1015 | u32 changes) |
| 1016 | { |
| 1017 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1018 | |
| 1019 | mutex_lock(&mvm->mutex); |
| 1020 | |
| 1021 | switch (vif->type) { |
| 1022 | case NL80211_IFTYPE_STATION: |
| 1023 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); |
| 1024 | break; |
| 1025 | case NL80211_IFTYPE_AP: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1026 | case NL80211_IFTYPE_ADHOC: |
| 1027 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1028 | break; |
| 1029 | default: |
| 1030 | /* shouldn't happen */ |
| 1031 | WARN_ON_ONCE(1); |
| 1032 | } |
| 1033 | |
| 1034 | mutex_unlock(&mvm->mutex); |
| 1035 | } |
| 1036 | |
| 1037 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, |
| 1038 | struct ieee80211_vif *vif, |
| 1039 | struct cfg80211_scan_request *req) |
| 1040 | { |
| 1041 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1042 | int ret; |
| 1043 | |
| 1044 | if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS) |
| 1045 | return -EINVAL; |
| 1046 | |
| 1047 | mutex_lock(&mvm->mutex); |
| 1048 | |
| 1049 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) |
| 1050 | ret = iwl_mvm_scan_request(mvm, vif, req); |
| 1051 | else |
| 1052 | ret = -EBUSY; |
| 1053 | |
| 1054 | mutex_unlock(&mvm->mutex); |
| 1055 | |
| 1056 | return ret; |
| 1057 | } |
| 1058 | |
| 1059 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, |
| 1060 | struct ieee80211_vif *vif) |
| 1061 | { |
| 1062 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1063 | |
| 1064 | mutex_lock(&mvm->mutex); |
| 1065 | |
| 1066 | iwl_mvm_cancel_scan(mvm); |
| 1067 | |
| 1068 | mutex_unlock(&mvm->mutex); |
| 1069 | } |
| 1070 | |
| 1071 | static void |
| 1072 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, |
| 1073 | struct ieee80211_sta *sta, u16 tid, |
| 1074 | int num_frames, |
| 1075 | enum ieee80211_frame_release_type reason, |
| 1076 | bool more_data) |
| 1077 | { |
| 1078 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1079 | |
| 1080 | /* TODO: how do we tell the fw to send frames for a specific TID */ |
| 1081 | |
| 1082 | /* |
| 1083 | * The fw will send EOSP notification when the last frame will be |
| 1084 | * transmitted. |
| 1085 | */ |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 1086 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
| 1090 | struct ieee80211_vif *vif, |
| 1091 | enum sta_notify_cmd cmd, |
| 1092 | struct ieee80211_sta *sta) |
| 1093 | { |
| 1094 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 5b577a9 | 2013-11-14 18:20:04 +0100 | [diff] [blame] | 1095 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1096 | |
| 1097 | switch (cmd) { |
| 1098 | case STA_NOTIFY_SLEEP: |
Emmanuel Grumbach | e3d4bc8 | 2013-05-07 14:08:24 +0300 | [diff] [blame] | 1099 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1100 | ieee80211_sta_block_awake(hw, sta, true); |
| 1101 | /* |
| 1102 | * The fw updates the STA to be asleep. Tx packets on the Tx |
| 1103 | * queues to this station will not be transmitted. The fw will |
| 1104 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. |
| 1105 | */ |
| 1106 | break; |
| 1107 | case STA_NOTIFY_AWAKE: |
Emmanuel Grumbach | 881acd8 | 2013-03-19 16:16:00 +0200 | [diff] [blame] | 1108 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1109 | break; |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 1110 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1111 | break; |
| 1112 | default: |
| 1113 | break; |
| 1114 | } |
| 1115 | } |
| 1116 | |
Johannes Berg | 1ddbbb0 | 2013-12-04 22:39:17 +0100 | [diff] [blame^] | 1117 | static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, |
| 1118 | struct ieee80211_vif *vif, |
| 1119 | struct ieee80211_sta *sta) |
| 1120 | { |
| 1121 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1122 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; |
| 1123 | |
| 1124 | /* |
| 1125 | * This is called before mac80211 does RCU synchronisation, |
| 1126 | * so here we already invalidate our internal RCU-protected |
| 1127 | * station pointer. The rest of the code will thus no longer |
| 1128 | * be able to find the station this way, and we don't rely |
| 1129 | * on further RCU synchronisation after the sta_state() |
| 1130 | * callback deleted the station. |
| 1131 | */ |
| 1132 | mutex_lock(&mvm->mutex); |
| 1133 | if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id])) |
| 1134 | rcu_assign_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id], |
| 1135 | ERR_PTR(-ENOENT)); |
| 1136 | mutex_unlock(&mvm->mutex); |
| 1137 | } |
| 1138 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1139 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
| 1140 | struct ieee80211_vif *vif, |
| 1141 | struct ieee80211_sta *sta, |
| 1142 | enum ieee80211_sta_state old_state, |
| 1143 | enum ieee80211_sta_state new_state) |
| 1144 | { |
| 1145 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1146 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1147 | int ret; |
| 1148 | |
| 1149 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", |
| 1150 | sta->addr, old_state, new_state); |
| 1151 | |
| 1152 | /* this would be a mac80211 bug ... but don't crash */ |
| 1153 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) |
| 1154 | return -EINVAL; |
| 1155 | |
| 1156 | /* if a STA is being removed, reuse its ID */ |
| 1157 | flush_work(&mvm->sta_drained_wk); |
| 1158 | |
| 1159 | mutex_lock(&mvm->mutex); |
| 1160 | if (old_state == IEEE80211_STA_NOTEXIST && |
| 1161 | new_state == IEEE80211_STA_NONE) { |
Johannes Berg | 48bc130 | 2013-07-04 15:55:29 +0200 | [diff] [blame] | 1162 | /* |
| 1163 | * Firmware bug - it'll crash if the beacon interval is less |
| 1164 | * than 16. We can't avoid connecting at all, so refuse the |
| 1165 | * station state change, this will cause mac80211 to abandon |
| 1166 | * attempts to connect to this AP, and eventually wpa_s will |
| 1167 | * blacklist the AP... |
| 1168 | */ |
| 1169 | if (vif->type == NL80211_IFTYPE_STATION && |
| 1170 | vif->bss_conf.beacon_int < 16) { |
| 1171 | IWL_ERR(mvm, |
| 1172 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", |
| 1173 | sta->addr, vif->bss_conf.beacon_int); |
| 1174 | ret = -EINVAL; |
| 1175 | goto out_unlock; |
| 1176 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1177 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
| 1178 | } else if (old_state == IEEE80211_STA_NONE && |
| 1179 | new_state == IEEE80211_STA_AUTH) { |
| 1180 | ret = 0; |
| 1181 | } else if (old_state == IEEE80211_STA_AUTH && |
| 1182 | new_state == IEEE80211_STA_ASSOC) { |
Johannes Berg | 7a45397 | 2013-02-12 13:10:44 +0100 | [diff] [blame] | 1183 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
| 1184 | if (ret == 0) |
| 1185 | iwl_mvm_rs_rate_init(mvm, sta, |
Eyal Shapira | b87c217 | 2013-11-09 23:37:55 +0200 | [diff] [blame] | 1186 | mvmvif->phy_ctxt->channel->band, |
| 1187 | true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1188 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 1189 | new_state == IEEE80211_STA_AUTHORIZED) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1190 | /* enable beacon filtering */ |
| 1191 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1192 | ret = 0; |
| 1193 | } else if (old_state == IEEE80211_STA_AUTHORIZED && |
| 1194 | new_state == IEEE80211_STA_ASSOC) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1195 | /* disable beacon filtering */ |
| 1196 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1197 | ret = 0; |
| 1198 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 1199 | new_state == IEEE80211_STA_AUTH) { |
| 1200 | ret = 0; |
| 1201 | } else if (old_state == IEEE80211_STA_AUTH && |
| 1202 | new_state == IEEE80211_STA_NONE) { |
| 1203 | ret = 0; |
| 1204 | } else if (old_state == IEEE80211_STA_NONE && |
| 1205 | new_state == IEEE80211_STA_NOTEXIST) { |
| 1206 | ret = iwl_mvm_rm_sta(mvm, vif, sta); |
| 1207 | } else { |
| 1208 | ret = -EIO; |
| 1209 | } |
Johannes Berg | 48bc130 | 2013-07-04 15:55:29 +0200 | [diff] [blame] | 1210 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1211 | mutex_unlock(&mvm->mutex); |
| 1212 | |
| 1213 | return ret; |
| 1214 | } |
| 1215 | |
| 1216 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
| 1217 | { |
| 1218 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1219 | |
| 1220 | mvm->rts_threshold = value; |
| 1221 | |
| 1222 | return 0; |
| 1223 | } |
| 1224 | |
| 1225 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
| 1226 | struct ieee80211_vif *vif, u16 ac, |
| 1227 | const struct ieee80211_tx_queue_params *params) |
| 1228 | { |
| 1229 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1230 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1231 | |
| 1232 | mvmvif->queue_params[ac] = *params; |
| 1233 | |
| 1234 | /* |
| 1235 | * No need to update right away, we'll get BSS_CHANGED_QOS |
| 1236 | * The exception is P2P_DEVICE interface which needs immediate update. |
| 1237 | */ |
| 1238 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1239 | int ret; |
| 1240 | |
| 1241 | mutex_lock(&mvm->mutex); |
| 1242 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 1243 | mutex_unlock(&mvm->mutex); |
| 1244 | return ret; |
| 1245 | } |
| 1246 | return 0; |
| 1247 | } |
| 1248 | |
| 1249 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, |
| 1250 | struct ieee80211_vif *vif) |
| 1251 | { |
| 1252 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1253 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, |
| 1254 | 200 + vif->bss_conf.beacon_int); |
| 1255 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, |
| 1256 | 100 + vif->bss_conf.beacon_int); |
| 1257 | |
| 1258 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) |
| 1259 | return; |
| 1260 | |
| 1261 | mutex_lock(&mvm->mutex); |
| 1262 | /* Try really hard to protect the session and hear a beacon */ |
Johannes Berg | 016d27e | 2013-05-03 11:16:15 +0200 | [diff] [blame] | 1263 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1264 | mutex_unlock(&mvm->mutex); |
| 1265 | } |
| 1266 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 1267 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
| 1268 | struct ieee80211_vif *vif, |
| 1269 | struct cfg80211_sched_scan_request *req, |
| 1270 | struct ieee80211_sched_scan_ies *ies) |
| 1271 | { |
| 1272 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1273 | int ret; |
| 1274 | |
| 1275 | mutex_lock(&mvm->mutex); |
| 1276 | |
| 1277 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { |
| 1278 | IWL_DEBUG_SCAN(mvm, |
| 1279 | "SCHED SCAN request during internal scan - abort\n"); |
| 1280 | ret = -EBUSY; |
| 1281 | goto out; |
| 1282 | } |
| 1283 | |
| 1284 | mvm->scan_status = IWL_MVM_SCAN_SCHED; |
| 1285 | |
| 1286 | ret = iwl_mvm_config_sched_scan(mvm, vif, req, ies); |
| 1287 | if (ret) |
| 1288 | goto err; |
| 1289 | |
| 1290 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); |
| 1291 | if (ret) |
| 1292 | goto err; |
| 1293 | |
| 1294 | ret = iwl_mvm_sched_scan_start(mvm, req); |
| 1295 | if (!ret) |
| 1296 | goto out; |
| 1297 | err: |
| 1298 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 1299 | out: |
| 1300 | mutex_unlock(&mvm->mutex); |
| 1301 | return ret; |
| 1302 | } |
| 1303 | |
| 1304 | static void iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, |
| 1305 | struct ieee80211_vif *vif) |
| 1306 | { |
| 1307 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1308 | |
| 1309 | mutex_lock(&mvm->mutex); |
| 1310 | iwl_mvm_sched_scan_stop(mvm); |
| 1311 | mutex_unlock(&mvm->mutex); |
| 1312 | } |
| 1313 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1314 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
| 1315 | enum set_key_cmd cmd, |
| 1316 | struct ieee80211_vif *vif, |
| 1317 | struct ieee80211_sta *sta, |
| 1318 | struct ieee80211_key_conf *key) |
| 1319 | { |
| 1320 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1321 | int ret; |
| 1322 | |
| 1323 | if (iwlwifi_mod_params.sw_crypto) { |
| 1324 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); |
| 1325 | return -EOPNOTSUPP; |
| 1326 | } |
| 1327 | |
| 1328 | switch (key->cipher) { |
| 1329 | case WLAN_CIPHER_SUITE_TKIP: |
| 1330 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
| 1331 | /* fall-through */ |
| 1332 | case WLAN_CIPHER_SUITE_CCMP: |
| 1333 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
| 1334 | break; |
| 1335 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 1336 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); |
| 1337 | break; |
| 1338 | case WLAN_CIPHER_SUITE_WEP40: |
| 1339 | case WLAN_CIPHER_SUITE_WEP104: |
| 1340 | /* |
| 1341 | * Support for TX only, at least for now, so accept |
| 1342 | * the key and do nothing else. Then mac80211 will |
| 1343 | * pass it for TX but we don't have to use it for RX. |
| 1344 | */ |
| 1345 | return 0; |
| 1346 | default: |
| 1347 | return -EOPNOTSUPP; |
| 1348 | } |
| 1349 | |
| 1350 | mutex_lock(&mvm->mutex); |
| 1351 | |
| 1352 | switch (cmd) { |
| 1353 | case SET_KEY: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1354 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 1355 | vif->type == NL80211_IFTYPE_AP) && !sta) { |
| 1356 | /* |
| 1357 | * GTK on AP interface is a TX-only key, return 0; |
| 1358 | * on IBSS they're per-station and because we're lazy |
| 1359 | * we don't support them for RX, so do the same. |
| 1360 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1361 | ret = 0; |
| 1362 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
| 1363 | break; |
| 1364 | } |
| 1365 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1366 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
| 1367 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); |
| 1368 | if (ret) { |
| 1369 | IWL_WARN(mvm, "set key failed\n"); |
| 1370 | /* |
| 1371 | * can't add key for RX, but we don't need it |
| 1372 | * in the device for TX so still return 0 |
| 1373 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1374 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1375 | ret = 0; |
| 1376 | } |
| 1377 | |
| 1378 | break; |
| 1379 | case DISABLE_KEY: |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1380 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
| 1381 | ret = 0; |
| 1382 | break; |
| 1383 | } |
| 1384 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1385 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
| 1386 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); |
| 1387 | break; |
| 1388 | default: |
| 1389 | ret = -EINVAL; |
| 1390 | } |
| 1391 | |
| 1392 | mutex_unlock(&mvm->mutex); |
| 1393 | return ret; |
| 1394 | } |
| 1395 | |
| 1396 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 1397 | struct ieee80211_vif *vif, |
| 1398 | struct ieee80211_key_conf *keyconf, |
| 1399 | struct ieee80211_sta *sta, |
| 1400 | u32 iv32, u16 *phase1key) |
| 1401 | { |
| 1402 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1403 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1404 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
| 1405 | return; |
| 1406 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1407 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
| 1408 | } |
| 1409 | |
| 1410 | |
| 1411 | static int iwl_mvm_roc(struct ieee80211_hw *hw, |
| 1412 | struct ieee80211_vif *vif, |
| 1413 | struct ieee80211_channel *channel, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 1414 | int duration, |
| 1415 | enum ieee80211_roc_type type) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1416 | { |
| 1417 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1418 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1419 | struct cfg80211_chan_def chandef; |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1420 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
| 1421 | int ret, i; |
| 1422 | |
| 1423 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, |
| 1424 | duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1425 | |
| 1426 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) { |
| 1427 | IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type); |
| 1428 | return -EINVAL; |
| 1429 | } |
| 1430 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1431 | mutex_lock(&mvm->mutex); |
| 1432 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1433 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 1434 | phy_ctxt = &mvm->phy_ctxts[i]; |
| 1435 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) |
| 1436 | continue; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1437 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1438 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { |
| 1439 | /* |
| 1440 | * Unbind the P2P_DEVICE from the current PHY context, |
| 1441 | * and if the PHY context is not used remove it. |
| 1442 | */ |
| 1443 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 1444 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 1445 | goto out_unlock; |
| 1446 | |
| 1447 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 1448 | |
| 1449 | /* Bind the P2P_DEVICE to the current PHY Context */ |
| 1450 | mvmvif->phy_ctxt = phy_ctxt; |
| 1451 | |
| 1452 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1453 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 1454 | goto out_unlock; |
| 1455 | |
| 1456 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 1457 | goto schedule_time_event; |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | /* Need to update the PHY context only if the ROC channel changed */ |
| 1462 | if (channel == mvmvif->phy_ctxt->channel) |
| 1463 | goto schedule_time_event; |
| 1464 | |
| 1465 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
| 1466 | |
| 1467 | /* |
| 1468 | * Change the PHY context configuration as it is currently referenced |
| 1469 | * only by the P2P Device MAC |
| 1470 | */ |
| 1471 | if (mvmvif->phy_ctxt->ref == 1) { |
| 1472 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, |
| 1473 | &chandef, 1, 1); |
| 1474 | if (ret) |
| 1475 | goto out_unlock; |
| 1476 | } else { |
| 1477 | /* |
| 1478 | * The PHY context is shared with other MACs. Need to remove the |
| 1479 | * P2P Device from the binding, allocate an new PHY context and |
| 1480 | * create a new binding |
| 1481 | */ |
| 1482 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1483 | if (!phy_ctxt) { |
| 1484 | ret = -ENOSPC; |
| 1485 | goto out_unlock; |
| 1486 | } |
| 1487 | |
| 1488 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, |
| 1489 | 1, 1); |
| 1490 | if (ret) { |
| 1491 | IWL_ERR(mvm, "Failed to change PHY context\n"); |
| 1492 | goto out_unlock; |
| 1493 | } |
| 1494 | |
| 1495 | /* Unbind the P2P_DEVICE from the current PHY context */ |
| 1496 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 1497 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 1498 | goto out_unlock; |
| 1499 | |
| 1500 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 1501 | |
| 1502 | /* Bind the P2P_DEVICE to the new allocated PHY context */ |
| 1503 | mvmvif->phy_ctxt = phy_ctxt; |
| 1504 | |
| 1505 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1506 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 1507 | goto out_unlock; |
| 1508 | |
| 1509 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 1510 | } |
| 1511 | |
| 1512 | schedule_time_event: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1513 | /* Schedule the time events */ |
Ilan Peer | e635c79 | 2013-02-13 11:05:18 +0200 | [diff] [blame] | 1514 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1515 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1516 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1517 | mutex_unlock(&mvm->mutex); |
| 1518 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1519 | return ret; |
| 1520 | } |
| 1521 | |
| 1522 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) |
| 1523 | { |
| 1524 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1525 | |
| 1526 | IWL_DEBUG_MAC80211(mvm, "enter\n"); |
| 1527 | |
| 1528 | mutex_lock(&mvm->mutex); |
| 1529 | iwl_mvm_stop_p2p_roc(mvm); |
| 1530 | mutex_unlock(&mvm->mutex); |
| 1531 | |
| 1532 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
| 1533 | return 0; |
| 1534 | } |
| 1535 | |
| 1536 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, |
| 1537 | struct ieee80211_chanctx_conf *ctx) |
| 1538 | { |
| 1539 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1540 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1541 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1542 | int ret; |
| 1543 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1544 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1545 | |
| 1546 | mutex_lock(&mvm->mutex); |
| 1547 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1548 | if (!phy_ctxt) { |
| 1549 | ret = -ENOSPC; |
| 1550 | goto out; |
| 1551 | } |
| 1552 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1553 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
| 1554 | ctx->rx_chains_static, |
| 1555 | ctx->rx_chains_dynamic); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1556 | if (ret) { |
| 1557 | IWL_ERR(mvm, "Failed to add PHY context\n"); |
| 1558 | goto out; |
| 1559 | } |
| 1560 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1561 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1562 | *phy_ctxt_id = phy_ctxt->id; |
| 1563 | out: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1564 | mutex_unlock(&mvm->mutex); |
| 1565 | return ret; |
| 1566 | } |
| 1567 | |
| 1568 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
| 1569 | struct ieee80211_chanctx_conf *ctx) |
| 1570 | { |
| 1571 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1572 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1573 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1574 | |
| 1575 | mutex_lock(&mvm->mutex); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1576 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1577 | mutex_unlock(&mvm->mutex); |
| 1578 | } |
| 1579 | |
| 1580 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, |
| 1581 | struct ieee80211_chanctx_conf *ctx, |
| 1582 | u32 changed) |
| 1583 | { |
| 1584 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1585 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1586 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1587 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1588 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
| 1589 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | |
| 1590 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | |
| 1591 | IEEE80211_CHANCTX_CHANGE_RADAR)), |
| 1592 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
| 1593 | phy_ctxt->ref, changed)) |
| 1594 | return; |
| 1595 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1596 | mutex_lock(&mvm->mutex); |
| 1597 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
| 1598 | ctx->rx_chains_static, |
| 1599 | ctx->rx_chains_dynamic); |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 1600 | iwl_mvm_bt_coex_vif_change(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1601 | mutex_unlock(&mvm->mutex); |
| 1602 | } |
| 1603 | |
| 1604 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 1605 | struct ieee80211_vif *vif, |
| 1606 | struct ieee80211_chanctx_conf *ctx) |
| 1607 | { |
| 1608 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1609 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1610 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1611 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1612 | int ret; |
| 1613 | |
| 1614 | mutex_lock(&mvm->mutex); |
| 1615 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1616 | mvmvif->phy_ctxt = phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1617 | |
| 1618 | switch (vif->type) { |
| 1619 | case NL80211_IFTYPE_AP: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1620 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1621 | /* |
| 1622 | * The AP binding flow is handled as part of the start_ap flow |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1623 | * (in bss_info_changed), similarly for IBSS. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1624 | */ |
| 1625 | ret = 0; |
| 1626 | goto out_unlock; |
| 1627 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1628 | case NL80211_IFTYPE_MONITOR: |
| 1629 | break; |
| 1630 | default: |
| 1631 | ret = -EINVAL; |
| 1632 | goto out_unlock; |
| 1633 | } |
| 1634 | |
| 1635 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1636 | if (ret) |
| 1637 | goto out_unlock; |
| 1638 | |
| 1639 | /* |
| 1640 | * Setting the quota at this stage is only required for monitor |
| 1641 | * interfaces. For the other types, the bss_info changed flow |
| 1642 | * will handle quota settings. |
| 1643 | */ |
| 1644 | if (vif->type == NL80211_IFTYPE_MONITOR) { |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1645 | mvmvif->monitor_active = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1646 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 1647 | if (ret) |
| 1648 | goto out_remove_binding; |
| 1649 | } |
| 1650 | |
| 1651 | goto out_unlock; |
| 1652 | |
| 1653 | out_remove_binding: |
| 1654 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 1655 | out_unlock: |
| 1656 | mutex_unlock(&mvm->mutex); |
| 1657 | if (ret) |
| 1658 | mvmvif->phy_ctxt = NULL; |
| 1659 | return ret; |
| 1660 | } |
| 1661 | |
| 1662 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 1663 | struct ieee80211_vif *vif, |
| 1664 | struct ieee80211_chanctx_conf *ctx) |
| 1665 | { |
| 1666 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1667 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1668 | |
| 1669 | mutex_lock(&mvm->mutex); |
| 1670 | |
| 1671 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); |
| 1672 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1673 | switch (vif->type) { |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1674 | case NL80211_IFTYPE_AP: |
| 1675 | case NL80211_IFTYPE_ADHOC: |
| 1676 | goto out_unlock; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1677 | case NL80211_IFTYPE_MONITOR: |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1678 | mvmvif->monitor_active = false; |
| 1679 | iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1680 | break; |
| 1681 | default: |
| 1682 | break; |
| 1683 | } |
| 1684 | |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1685 | iwl_mvm_binding_remove_vif(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1686 | out_unlock: |
| 1687 | mvmvif->phy_ctxt = NULL; |
| 1688 | mutex_unlock(&mvm->mutex); |
| 1689 | } |
| 1690 | |
| 1691 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, |
| 1692 | struct ieee80211_sta *sta, |
| 1693 | bool set) |
| 1694 | { |
| 1695 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1696 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; |
| 1697 | |
| 1698 | if (!mvm_sta || !mvm_sta->vif) { |
| 1699 | IWL_ERR(mvm, "Station is not associated to a vif\n"); |
| 1700 | return -EINVAL; |
| 1701 | } |
| 1702 | |
| 1703 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); |
| 1704 | } |
| 1705 | |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1706 | #ifdef CONFIG_NL80211_TESTMODE |
| 1707 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { |
| 1708 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 1709 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, |
Johannes Berg | f6c6ad4 | 2013-08-01 14:17:15 +0200 | [diff] [blame] | 1710 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1711 | }; |
| 1712 | |
| 1713 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, |
| 1714 | struct ieee80211_vif *vif, |
| 1715 | void *data, int len) |
| 1716 | { |
| 1717 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; |
| 1718 | int err; |
| 1719 | u32 noa_duration; |
| 1720 | |
| 1721 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy); |
| 1722 | if (err) |
| 1723 | return err; |
| 1724 | |
| 1725 | if (!tb[IWL_MVM_TM_ATTR_CMD]) |
| 1726 | return -EINVAL; |
| 1727 | |
| 1728 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { |
| 1729 | case IWL_MVM_TM_CMD_SET_NOA: |
| 1730 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || |
| 1731 | !vif->bss_conf.enable_beacon || |
| 1732 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) |
| 1733 | return -EINVAL; |
| 1734 | |
| 1735 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); |
| 1736 | if (noa_duration >= vif->bss_conf.beacon_int) |
| 1737 | return -EINVAL; |
| 1738 | |
| 1739 | mvm->noa_duration = noa_duration; |
| 1740 | mvm->noa_vif = vif; |
| 1741 | |
| 1742 | return iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | f6c6ad4 | 2013-08-01 14:17:15 +0200 | [diff] [blame] | 1743 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
| 1744 | /* must be associated client vif - ignore authorized */ |
| 1745 | if (!vif || vif->type != NL80211_IFTYPE_STATION || |
| 1746 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || |
| 1747 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) |
| 1748 | return -EINVAL; |
| 1749 | |
| 1750 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) |
| 1751 | return iwl_mvm_enable_beacon_filter(mvm, vif); |
| 1752 | return iwl_mvm_disable_beacon_filter(mvm, vif); |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1753 | } |
| 1754 | |
| 1755 | return -EOPNOTSUPP; |
| 1756 | } |
| 1757 | |
| 1758 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, |
| 1759 | struct ieee80211_vif *vif, |
| 1760 | void *data, int len) |
| 1761 | { |
| 1762 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1763 | int err; |
| 1764 | |
| 1765 | mutex_lock(&mvm->mutex); |
| 1766 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); |
| 1767 | mutex_unlock(&mvm->mutex); |
| 1768 | |
| 1769 | return err; |
| 1770 | } |
| 1771 | #endif |
| 1772 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1773 | struct ieee80211_ops iwl_mvm_hw_ops = { |
| 1774 | .tx = iwl_mvm_mac_tx, |
| 1775 | .ampdu_action = iwl_mvm_mac_ampdu_action, |
| 1776 | .start = iwl_mvm_mac_start, |
| 1777 | .restart_complete = iwl_mvm_mac_restart_complete, |
| 1778 | .stop = iwl_mvm_mac_stop, |
| 1779 | .add_interface = iwl_mvm_mac_add_interface, |
| 1780 | .remove_interface = iwl_mvm_mac_remove_interface, |
| 1781 | .config = iwl_mvm_mac_config, |
| 1782 | .configure_filter = iwl_mvm_configure_filter, |
| 1783 | .bss_info_changed = iwl_mvm_bss_info_changed, |
| 1784 | .hw_scan = iwl_mvm_mac_hw_scan, |
| 1785 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, |
Johannes Berg | 1ddbbb0 | 2013-12-04 22:39:17 +0100 | [diff] [blame^] | 1786 | .sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1787 | .sta_state = iwl_mvm_mac_sta_state, |
| 1788 | .sta_notify = iwl_mvm_mac_sta_notify, |
| 1789 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, |
| 1790 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
| 1791 | .conf_tx = iwl_mvm_mac_conf_tx, |
| 1792 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 1793 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
| 1794 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1795 | .set_key = iwl_mvm_mac_set_key, |
| 1796 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, |
| 1797 | .remain_on_channel = iwl_mvm_roc, |
| 1798 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1799 | .add_chanctx = iwl_mvm_add_chanctx, |
| 1800 | .remove_chanctx = iwl_mvm_remove_chanctx, |
| 1801 | .change_chanctx = iwl_mvm_change_chanctx, |
| 1802 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, |
| 1803 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, |
| 1804 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1805 | .start_ap = iwl_mvm_start_ap_ibss, |
| 1806 | .stop_ap = iwl_mvm_stop_ap_ibss, |
| 1807 | .join_ibss = iwl_mvm_start_ap_ibss, |
| 1808 | .leave_ibss = iwl_mvm_stop_ap_ibss, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1809 | |
| 1810 | .set_tim = iwl_mvm_set_tim, |
| 1811 | |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1812 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
| 1813 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1814 | #ifdef CONFIG_PM_SLEEP |
| 1815 | /* look at d3.c */ |
| 1816 | .suspend = iwl_mvm_suspend, |
| 1817 | .resume = iwl_mvm_resume, |
| 1818 | .set_wakeup = iwl_mvm_set_wakeup, |
| 1819 | .set_rekey_data = iwl_mvm_set_rekey_data, |
| 1820 | #if IS_ENABLED(CONFIG_IPV6) |
| 1821 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, |
| 1822 | #endif |
| 1823 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, |
| 1824 | #endif |
| 1825 | }; |