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 | |
Max Stepanov | e36e543 | 2013-08-27 19:56:13 +0300 | [diff] [blame] | 264 | /* currently FW API supports only one optional cipher scheme */ |
| 265 | if (mvm->fw->cs && mvm->fw->cs->cipher) { |
| 266 | mvm->hw->n_cipher_schemes = 1; |
| 267 | mvm->hw->cipher_schemes = mvm->fw->cs; |
| 268 | } |
| 269 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 270 | #ifdef CONFIG_PM_SLEEP |
| 271 | if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && |
| 272 | mvm->trans->ops->d3_suspend && |
| 273 | mvm->trans->ops->d3_resume && |
| 274 | device_can_wakeup(mvm->trans->dev)) { |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 275 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
| 276 | WIPHY_WOWLAN_DISCONNECT | |
| 277 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 278 | WIPHY_WOWLAN_RFKILL_RELEASE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 279 | if (!iwlwifi_mod_params.sw_crypto) |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 280 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 281 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 282 | WIPHY_WOWLAN_4WAY_HANDSHAKE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 283 | |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 284 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; |
| 285 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; |
| 286 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; |
| 287 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; |
| 288 | hw->wiphy->wowlan = &mvm->wowlan; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 289 | } |
| 290 | #endif |
| 291 | |
| 292 | ret = iwl_mvm_leds_init(mvm); |
| 293 | if (ret) |
| 294 | return ret; |
| 295 | |
Emmanuel Grumbach | b7327d8 | 2013-06-24 15:44:03 +0300 | [diff] [blame] | 296 | ret = ieee80211_register_hw(mvm->hw); |
| 297 | if (ret) |
| 298 | iwl_mvm_leds_exit(mvm); |
| 299 | |
| 300 | return ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
| 304 | struct ieee80211_tx_control *control, |
| 305 | struct sk_buff *skb) |
| 306 | { |
| 307 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 308 | |
Eytan Lifshitz | 9ee718a | 2013-05-19 19:14:41 +0300 | [diff] [blame] | 309 | if (iwl_mvm_is_radio_killed(mvm)) { |
| 310 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 311 | goto drop; |
| 312 | } |
| 313 | |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 314 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 315 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) |
| 316 | goto drop; |
| 317 | |
| 318 | if (control->sta) { |
| 319 | if (iwl_mvm_tx_skb(mvm, skb, control->sta)) |
| 320 | goto drop; |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) |
| 325 | goto drop; |
| 326 | return; |
| 327 | drop: |
| 328 | ieee80211_free_txskb(hw, skb); |
| 329 | } |
| 330 | |
| 331 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
| 332 | struct ieee80211_vif *vif, |
| 333 | enum ieee80211_ampdu_mlme_action action, |
| 334 | struct ieee80211_sta *sta, u16 tid, |
| 335 | u16 *ssn, u8 buf_size) |
| 336 | { |
| 337 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 338 | int ret; |
| 339 | |
| 340 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", |
| 341 | sta->addr, tid, action); |
| 342 | |
| 343 | if (!(mvm->nvm_data->sku_cap_11n_enable)) |
| 344 | return -EACCES; |
| 345 | |
| 346 | mutex_lock(&mvm->mutex); |
| 347 | |
| 348 | switch (action) { |
| 349 | case IEEE80211_AMPDU_RX_START: |
| 350 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) { |
| 351 | ret = -EINVAL; |
| 352 | break; |
| 353 | } |
| 354 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); |
| 355 | break; |
| 356 | case IEEE80211_AMPDU_RX_STOP: |
| 357 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); |
| 358 | break; |
| 359 | case IEEE80211_AMPDU_TX_START: |
Emmanuel Grumbach | 5d158ef | 2013-02-19 14:39:58 +0200 | [diff] [blame] | 360 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) { |
| 361 | ret = -EINVAL; |
| 362 | break; |
| 363 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 364 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
| 365 | break; |
| 366 | case IEEE80211_AMPDU_TX_STOP_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 367 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
| 368 | break; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 369 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 370 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 371 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 372 | break; |
| 373 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 374 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); |
| 375 | break; |
| 376 | default: |
| 377 | WARN_ON_ONCE(1); |
| 378 | ret = -EINVAL; |
| 379 | break; |
| 380 | } |
| 381 | mutex_unlock(&mvm->mutex); |
| 382 | |
| 383 | return ret; |
| 384 | } |
| 385 | |
| 386 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, |
| 387 | struct ieee80211_vif *vif) |
| 388 | { |
| 389 | struct iwl_mvm *mvm = data; |
| 390 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 391 | |
| 392 | mvmvif->uploaded = false; |
| 393 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 394 | |
| 395 | /* does this make sense at all? */ |
| 396 | mvmvif->color++; |
| 397 | |
| 398 | spin_lock_bh(&mvm->time_event_lock); |
| 399 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); |
| 400 | spin_unlock_bh(&mvm->time_event_lock); |
| 401 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 402 | mvmvif->phy_ctxt = NULL; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) |
| 406 | { |
| 407 | iwl_trans_stop_device(mvm->trans); |
| 408 | iwl_trans_stop_hw(mvm->trans, false); |
| 409 | |
| 410 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 411 | |
| 412 | /* just in case one was running */ |
| 413 | ieee80211_remain_on_channel_expired(mvm->hw); |
| 414 | |
| 415 | ieee80211_iterate_active_interfaces_atomic( |
| 416 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 417 | iwl_mvm_cleanup_iterator, mvm); |
| 418 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 419 | mvm->p2p_device_vif = NULL; |
| 420 | |
| 421 | iwl_mvm_reset_phy_ctxts(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 422 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
| 423 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); |
| 424 | |
| 425 | ieee80211_wake_queues(mvm->hw); |
| 426 | |
| 427 | mvm->vif_count = 0; |
Emmanuel Grumbach | 113a044 | 2013-07-02 14:16:38 +0300 | [diff] [blame] | 428 | mvm->rx_ba_sessions = 0; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) |
| 432 | { |
| 433 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 434 | int ret; |
| 435 | |
| 436 | mutex_lock(&mvm->mutex); |
| 437 | |
| 438 | /* Clean up some internal and mac80211 state on restart */ |
| 439 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 440 | iwl_mvm_restart_cleanup(mvm); |
| 441 | |
| 442 | ret = iwl_mvm_up(mvm); |
| 443 | mutex_unlock(&mvm->mutex); |
| 444 | |
| 445 | return ret; |
| 446 | } |
| 447 | |
| 448 | static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw) |
| 449 | { |
| 450 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 451 | int ret; |
| 452 | |
| 453 | mutex_lock(&mvm->mutex); |
| 454 | |
| 455 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 456 | ret = iwl_mvm_update_quotas(mvm, NULL); |
| 457 | if (ret) |
| 458 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", |
| 459 | ret); |
| 460 | |
| 461 | mutex_unlock(&mvm->mutex); |
| 462 | } |
| 463 | |
| 464 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) |
| 465 | { |
| 466 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 467 | |
| 468 | flush_work(&mvm->async_handlers_wk); |
| 469 | |
| 470 | mutex_lock(&mvm->mutex); |
| 471 | /* async_handlers_wk is now blocked */ |
| 472 | |
| 473 | /* |
| 474 | * The work item could be running or queued if the |
| 475 | * ROC time event stops just as we get here. |
| 476 | */ |
| 477 | cancel_work_sync(&mvm->roc_done_wk); |
| 478 | |
| 479 | iwl_trans_stop_device(mvm->trans); |
| 480 | iwl_trans_stop_hw(mvm->trans, false); |
| 481 | |
| 482 | iwl_mvm_async_handlers_purge(mvm); |
| 483 | /* async_handlers_list is empty and will stay empty: HW is stopped */ |
| 484 | |
| 485 | /* the fw is stopped, the aux sta is dead: clean up driver state */ |
| 486 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); |
| 487 | |
| 488 | mutex_unlock(&mvm->mutex); |
| 489 | |
| 490 | /* |
| 491 | * The worker might have been waiting for the mutex, let it run and |
| 492 | * discover that its list is now empty. |
| 493 | */ |
| 494 | cancel_work_sync(&mvm->async_handlers_wk); |
| 495 | } |
| 496 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 497 | static void iwl_mvm_power_update_iterator(void *data, u8 *mac, |
| 498 | struct ieee80211_vif *vif) |
| 499 | { |
| 500 | struct iwl_mvm *mvm = data; |
| 501 | |
| 502 | iwl_mvm_power_update_mode(mvm, vif); |
| 503 | } |
| 504 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 505 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
| 506 | { |
| 507 | u16 i; |
| 508 | |
| 509 | lockdep_assert_held(&mvm->mutex); |
| 510 | |
| 511 | for (i = 0; i < NUM_PHY_CTX; i++) |
| 512 | if (!mvm->phy_ctxts[i].ref) |
| 513 | return &mvm->phy_ctxts[i]; |
| 514 | |
| 515 | IWL_ERR(mvm, "No available PHY context\n"); |
| 516 | return NULL; |
| 517 | } |
| 518 | |
Emmanuel Grumbach | ee9c6cb | 2013-12-04 13:53:39 +0200 | [diff] [blame^] | 519 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 520 | s8 tx_power) |
| 521 | { |
| 522 | /* FW is in charge of regulatory enforcement */ |
| 523 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { |
| 524 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, |
| 525 | .pwr_restriction = cpu_to_le16(tx_power), |
| 526 | }; |
| 527 | |
| 528 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, |
| 529 | sizeof(reduce_txpwr_cmd), |
| 530 | &reduce_txpwr_cmd); |
| 531 | } |
| 532 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 533 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
| 534 | struct ieee80211_vif *vif) |
| 535 | { |
| 536 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 537 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 538 | int ret; |
| 539 | |
| 540 | /* |
| 541 | * Not much to do here. The stack will not allow interface |
| 542 | * types or combinations that we didn't advertise, so we |
| 543 | * don't really have to check the types. |
| 544 | */ |
| 545 | |
| 546 | mutex_lock(&mvm->mutex); |
| 547 | |
Eliad Peller | e89044d | 2013-07-16 17:33:26 +0300 | [diff] [blame] | 548 | /* Allocate resources for the MAC context, and add it to the fw */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 549 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
| 550 | if (ret) |
| 551 | goto out_unlock; |
| 552 | |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 553 | /* Counting number of interfaces is needed for legacy PM */ |
Ilan Peer | ea183d0 | 2013-07-23 14:41:53 +0300 | [diff] [blame] | 554 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 555 | mvm->vif_count++; |
Ilan Peer | ea183d0 | 2013-07-23 14:41:53 +0300 | [diff] [blame] | 556 | |
| 557 | /* |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 558 | * The AP binding flow can be done only after the beacon |
| 559 | * template is configured (which happens only in the mac80211 |
| 560 | * start_ap() flow), and adding the broadcast station can happen |
| 561 | * only after the binding. |
| 562 | * In addition, since modifying the MAC before adding a bcast |
| 563 | * station is not allowed by the FW, delay the adding of MAC context to |
| 564 | * the point where we can also add the bcast station. |
| 565 | * In short: there's not much we can do at this point, other than |
| 566 | * allocating resources :) |
| 567 | */ |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 568 | if (vif->type == NL80211_IFTYPE_AP || |
| 569 | vif->type == NL80211_IFTYPE_ADHOC) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 570 | u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif); |
| 571 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, |
| 572 | qmask); |
| 573 | if (ret) { |
| 574 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); |
| 575 | goto out_release; |
| 576 | } |
| 577 | |
Emmanuel Grumbach | 77740cb | 2013-06-26 23:51:41 +0300 | [diff] [blame] | 578 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 579 | goto out_unlock; |
| 580 | } |
| 581 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 582 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 583 | if (ret) |
| 584 | goto out_release; |
| 585 | |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 586 | iwl_mvm_power_disable(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 587 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 588 | /* beacon filtering */ |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 589 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
| 590 | if (ret) |
| 591 | goto out_remove_mac; |
| 592 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 593 | if (!mvm->bf_allowed_vif && |
Hila Gonen | 5dca7c2 | 2013-07-16 11:15:35 +0300 | [diff] [blame] | 594 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
| 595 | mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){ |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 596 | mvm->bf_allowed_vif = mvmvif; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 597 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
| 598 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 599 | } |
| 600 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 601 | /* |
| 602 | * P2P_DEVICE interface does not have a channel context assigned to it, |
| 603 | * so a dedicated PHY context is allocated to it and the corresponding |
| 604 | * MAC context is bound to it at this stage. |
| 605 | */ |
| 606 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 607 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 608 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 609 | if (!mvmvif->phy_ctxt) { |
| 610 | ret = -ENOSPC; |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 611 | goto out_free_bf; |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 612 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 613 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 614 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 615 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 616 | if (ret) |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 617 | goto out_unref_phy; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 618 | |
| 619 | ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta); |
| 620 | if (ret) |
| 621 | goto out_unbind; |
| 622 | |
| 623 | /* Save a pointer to p2p device vif, so it can later be used to |
| 624 | * update the p2p device MAC when a GO is started/stopped */ |
| 625 | mvm->p2p_device_vif = vif; |
| 626 | } |
| 627 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 628 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 629 | goto out_unlock; |
| 630 | |
| 631 | out_unbind: |
| 632 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 633 | out_unref_phy: |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 634 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 635 | out_free_bf: |
| 636 | if (mvm->bf_allowed_vif == mvmvif) { |
| 637 | mvm->bf_allowed_vif = NULL; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 638 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 639 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 640 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 641 | out_remove_mac: |
| 642 | mvmvif->phy_ctxt = NULL; |
| 643 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 644 | out_release: |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 645 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 646 | mvm->vif_count--; |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 647 | |
| 648 | /* TODO: remove this when legacy PM will be discarded */ |
Alexander Bondar | 4bf881f | 2013-05-29 10:19:50 +0300 | [diff] [blame] | 649 | ieee80211_iterate_active_interfaces( |
| 650 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 651 | iwl_mvm_power_update_iterator, mvm); |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 652 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 653 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 654 | out_unlock: |
| 655 | mutex_unlock(&mvm->mutex); |
| 656 | |
| 657 | return ret; |
| 658 | } |
| 659 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 660 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
| 661 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 662 | { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 663 | u32 tfd_msk = 0, ac; |
| 664 | |
| 665 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 666 | if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) |
| 667 | tfd_msk |= BIT(vif->hw_queue[ac]); |
| 668 | |
| 669 | if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE) |
| 670 | tfd_msk |= BIT(vif->cab_queue); |
| 671 | |
| 672 | if (tfd_msk) { |
| 673 | mutex_lock(&mvm->mutex); |
| 674 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); |
| 675 | mutex_unlock(&mvm->mutex); |
| 676 | } |
| 677 | |
| 678 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 679 | /* |
| 680 | * Flush the ROC worker which will flush the OFFCHANNEL queue. |
| 681 | * We assume here that all the packets sent to the OFFCHANNEL |
| 682 | * queue are sent in ROC session. |
| 683 | */ |
| 684 | flush_work(&mvm->roc_done_wk); |
| 685 | } else { |
| 686 | /* |
| 687 | * By now, all the AC queues are empty. The AGG queues are |
| 688 | * empty too. We already got all the Tx responses for all the |
| 689 | * packets in the queues. The drain work can have been |
Emmanuel Grumbach | 0742a75 | 2013-06-10 14:10:33 +0300 | [diff] [blame] | 690 | * triggered. Flush it. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 691 | */ |
| 692 | flush_work(&mvm->sta_drained_wk); |
| 693 | } |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, |
| 697 | struct ieee80211_vif *vif) |
| 698 | { |
| 699 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 700 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 701 | |
| 702 | iwl_mvm_prepare_mac_removal(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 703 | |
| 704 | mutex_lock(&mvm->mutex); |
| 705 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 706 | if (mvm->bf_allowed_vif == mvmvif) { |
| 707 | mvm->bf_allowed_vif = NULL; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 708 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 709 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 710 | } |
| 711 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 712 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
| 713 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 714 | /* |
| 715 | * 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] | 716 | * interface is be handled as part of the stop_ap flow. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 717 | */ |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 718 | if (vif->type == NL80211_IFTYPE_AP || |
| 719 | vif->type == NL80211_IFTYPE_ADHOC) { |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 720 | #ifdef CONFIG_NL80211_TESTMODE |
| 721 | if (vif == mvm->noa_vif) { |
| 722 | mvm->noa_vif = NULL; |
| 723 | mvm->noa_duration = 0; |
| 724 | } |
| 725 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 726 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); |
| 727 | goto out_release; |
| 728 | } |
| 729 | |
| 730 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 731 | mvm->p2p_device_vif = NULL; |
| 732 | iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 733 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 734 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 735 | mvmvif->phy_ctxt = NULL; |
| 736 | } |
| 737 | |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 738 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 739 | mvm->vif_count--; |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 740 | |
| 741 | /* TODO: remove this when legacy PM will be discarded */ |
| 742 | ieee80211_iterate_active_interfaces( |
| 743 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 744 | iwl_mvm_power_update_iterator, mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 745 | |
| 746 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 747 | |
| 748 | out_release: |
| 749 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 750 | mutex_unlock(&mvm->mutex); |
| 751 | } |
| 752 | |
| 753 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
| 754 | { |
| 755 | return 0; |
| 756 | } |
| 757 | |
| 758 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, |
| 759 | unsigned int changed_flags, |
| 760 | unsigned int *total_flags, |
| 761 | u64 multicast) |
| 762 | { |
| 763 | *total_flags = 0; |
| 764 | } |
| 765 | |
Emmanuel Grumbach | 51b6b9e | 2013-05-02 15:01:24 +0300 | [diff] [blame] | 766 | static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm, |
| 767 | struct ieee80211_vif *vif) |
| 768 | { |
| 769 | struct iwl_mcast_filter_cmd mcast_filter_cmd = { |
| 770 | .pass_all = 1, |
| 771 | }; |
| 772 | |
| 773 | memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 774 | |
| 775 | return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC, |
| 776 | sizeof(mcast_filter_cmd), |
| 777 | &mcast_filter_cmd); |
| 778 | } |
| 779 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 780 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
| 781 | struct ieee80211_vif *vif, |
| 782 | struct ieee80211_bss_conf *bss_conf, |
| 783 | u32 changes) |
| 784 | { |
| 785 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 786 | int ret; |
| 787 | |
| 788 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 789 | if (ret) |
| 790 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 791 | |
| 792 | if (changes & BSS_CHANGED_ASSOC) { |
| 793 | if (bss_conf->assoc) { |
| 794 | /* add quota for this interface */ |
| 795 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 796 | if (ret) { |
| 797 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 798 | return; |
| 799 | } |
Emmanuel Grumbach | 51b6b9e | 2013-05-02 15:01:24 +0300 | [diff] [blame] | 800 | iwl_mvm_configure_mcast_filter(mvm, vif); |
Johannes Berg | 016d27e | 2013-05-03 11:16:15 +0200 | [diff] [blame] | 801 | |
| 802 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, |
| 803 | &mvm->status)) { |
| 804 | /* |
| 805 | * If we're restarting then the firmware will |
| 806 | * obviously have lost synchronisation with |
| 807 | * the AP. It will attempt to synchronise by |
| 808 | * itself, but we can make it more reliable by |
| 809 | * scheduling a session protection time event. |
| 810 | * |
| 811 | * The firmware needs to receive a beacon to |
| 812 | * catch up with synchronisation, use 110% of |
| 813 | * the beacon interval. |
| 814 | * |
| 815 | * Set a large maximum delay to allow for more |
| 816 | * than a single interface. |
| 817 | */ |
| 818 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; |
| 819 | iwl_mvm_protect_session(mvm, vif, dur, dur, |
| 820 | 5 * dur); |
| 821 | } |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 822 | |
| 823 | iwl_mvm_sf_update(mvm, vif, false); |
Alexander Bondar | 175a70b | 2013-04-14 20:59:37 +0300 | [diff] [blame] | 824 | iwl_mvm_power_vif_assoc(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 825 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 826 | /* |
| 827 | * If update fails - SF might be running in associated |
| 828 | * mode while disassociated - which is forbidden. |
| 829 | */ |
| 830 | WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false), |
| 831 | "Failed to update SF upon disassociation\n"); |
| 832 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 833 | /* remove AP station now that the MAC is unassoc */ |
| 834 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); |
| 835 | if (ret) |
| 836 | IWL_ERR(mvm, "failed to remove AP station\n"); |
| 837 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 838 | /* remove quota for this interface */ |
| 839 | ret = iwl_mvm_update_quotas(mvm, NULL); |
| 840 | if (ret) |
| 841 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 842 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 843 | |
| 844 | /* reset rssi values */ |
| 845 | mvmvif->bf_data.ave_beacon_signal = 0; |
| 846 | |
Alexander Bondar | e8e626a | 2013-10-16 00:21:34 +0200 | [diff] [blame] | 847 | if (!(mvm->fw->ucode_capa.flags & |
| 848 | IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT)) { |
Alexander Bondar | e811ada | 2013-03-10 15:29:44 +0200 | [diff] [blame] | 849 | /* Workaround for FW bug, otherwise FW disables device |
| 850 | * power save upon disassociation |
| 851 | */ |
| 852 | ret = iwl_mvm_power_update_mode(mvm, vif); |
| 853 | if (ret) |
| 854 | IWL_ERR(mvm, "failed to update power mode\n"); |
| 855 | } |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 856 | iwl_mvm_bt_coex_vif_change(mvm); |
Alexander Bondar | 989c650 | 2013-05-16 17:34:17 +0300 | [diff] [blame] | 857 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
Johannes Berg | 210a544 | 2013-01-24 23:48:23 +0100 | [diff] [blame] | 858 | /* |
| 859 | * We received a beacon _after_ association so |
| 860 | * remove the session protection. |
| 861 | */ |
| 862 | iwl_mvm_remove_time_event(mvm, mvmvif, |
| 863 | &mvmvif->time_event_data); |
Alexander Bondar | 51498cf | 2013-09-02 17:10:14 +0300 | [diff] [blame] | 864 | } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | |
| 865 | BSS_CHANGED_QOS)) { |
Alexander Bondar | 4bf881f | 2013-05-29 10:19:50 +0300 | [diff] [blame] | 866 | ret = iwl_mvm_power_update_mode(mvm, vif); |
| 867 | if (ret) |
| 868 | IWL_ERR(mvm, "failed to update power mode\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 869 | } |
Matti Gottlieb | 88f2fd7 | 2013-07-09 15:25:46 +0300 | [diff] [blame] | 870 | if (changes & BSS_CHANGED_TXPOWER) { |
| 871 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", |
| 872 | bss_conf->txpower); |
| 873 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); |
| 874 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 875 | |
| 876 | if (changes & BSS_CHANGED_CQM) { |
| 877 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed"); |
| 878 | /* reset cqm events tracking */ |
| 879 | mvmvif->bf_data.last_cqm_event = 0; |
| 880 | ret = iwl_mvm_update_beacon_filter(mvm, vif); |
| 881 | if (ret) |
| 882 | IWL_ERR(mvm, "failed to update CQM thresholds\n"); |
| 883 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 884 | } |
| 885 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 886 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
| 887 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 888 | { |
| 889 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 890 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 891 | int ret; |
| 892 | |
| 893 | mutex_lock(&mvm->mutex); |
| 894 | |
| 895 | /* Send the beacon template */ |
| 896 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); |
| 897 | if (ret) |
| 898 | goto out_unlock; |
| 899 | |
| 900 | /* Add the mac context */ |
| 901 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 902 | if (ret) |
| 903 | goto out_unlock; |
| 904 | |
| 905 | /* Perform the binding */ |
| 906 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 907 | if (ret) |
| 908 | goto out_remove; |
| 909 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 910 | mvmvif->ap_ibss_active = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 911 | |
| 912 | /* Send the bcast station. At this stage the TBTT and DTIM time events |
| 913 | * are added and applied to the scheduler */ |
| 914 | ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta); |
| 915 | if (ret) |
| 916 | goto out_unbind; |
| 917 | |
| 918 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 919 | if (ret) |
| 920 | goto out_rm_bcast; |
| 921 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 922 | /* 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] | 923 | if (vif->p2p && mvm->p2p_device_vif) |
| 924 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); |
| 925 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 926 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | dac94da | 2013-06-18 07:35:27 +0300 | [diff] [blame] | 927 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 928 | mutex_unlock(&mvm->mutex); |
| 929 | return 0; |
| 930 | |
| 931 | out_rm_bcast: |
| 932 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 933 | out_unbind: |
| 934 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 935 | out_remove: |
| 936 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 937 | out_unlock: |
| 938 | mutex_unlock(&mvm->mutex); |
| 939 | return ret; |
| 940 | } |
| 941 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 942 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
| 943 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 944 | { |
| 945 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 946 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 947 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 948 | iwl_mvm_prepare_mac_removal(mvm, vif); |
| 949 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 950 | mutex_lock(&mvm->mutex); |
| 951 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 952 | mvmvif->ap_ibss_active = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 953 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 954 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | dac94da | 2013-06-18 07:35:27 +0300 | [diff] [blame] | 955 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 956 | /* 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] | 957 | if (vif->p2p && mvm->p2p_device_vif) |
| 958 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); |
| 959 | |
| 960 | iwl_mvm_update_quotas(mvm, NULL); |
| 961 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 962 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 963 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 964 | |
| 965 | mutex_unlock(&mvm->mutex); |
| 966 | } |
| 967 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 968 | static void |
| 969 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, |
| 970 | struct ieee80211_vif *vif, |
| 971 | struct ieee80211_bss_conf *bss_conf, |
| 972 | u32 changes) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 973 | { |
Avri Altman | 8a5e366 | 2013-11-12 19:16:03 +0200 | [diff] [blame] | 974 | enum ieee80211_bss_change ht_change = BSS_CHANGED_ERP_CTS_PROT | |
| 975 | BSS_CHANGED_HT | |
| 976 | BSS_CHANGED_BANDWIDTH; |
| 977 | int ret; |
| 978 | |
| 979 | if (changes & ht_change) { |
| 980 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 981 | if (ret) |
| 982 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 983 | } |
| 984 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 985 | /* Need to send a new beacon template to the FW */ |
| 986 | if (changes & BSS_CHANGED_BEACON) { |
| 987 | if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) |
| 988 | IWL_WARN(mvm, "Failed updating beacon data\n"); |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, |
| 993 | struct ieee80211_vif *vif, |
| 994 | struct ieee80211_bss_conf *bss_conf, |
| 995 | u32 changes) |
| 996 | { |
| 997 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 998 | |
| 999 | mutex_lock(&mvm->mutex); |
| 1000 | |
| 1001 | switch (vif->type) { |
| 1002 | case NL80211_IFTYPE_STATION: |
| 1003 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); |
| 1004 | break; |
| 1005 | case NL80211_IFTYPE_AP: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1006 | case NL80211_IFTYPE_ADHOC: |
| 1007 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1008 | break; |
| 1009 | default: |
| 1010 | /* shouldn't happen */ |
| 1011 | WARN_ON_ONCE(1); |
| 1012 | } |
| 1013 | |
| 1014 | mutex_unlock(&mvm->mutex); |
| 1015 | } |
| 1016 | |
| 1017 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, |
| 1018 | struct ieee80211_vif *vif, |
| 1019 | struct cfg80211_scan_request *req) |
| 1020 | { |
| 1021 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1022 | int ret; |
| 1023 | |
| 1024 | if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS) |
| 1025 | return -EINVAL; |
| 1026 | |
| 1027 | mutex_lock(&mvm->mutex); |
| 1028 | |
| 1029 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) |
| 1030 | ret = iwl_mvm_scan_request(mvm, vif, req); |
| 1031 | else |
| 1032 | ret = -EBUSY; |
| 1033 | |
| 1034 | mutex_unlock(&mvm->mutex); |
| 1035 | |
| 1036 | return ret; |
| 1037 | } |
| 1038 | |
| 1039 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, |
| 1040 | struct ieee80211_vif *vif) |
| 1041 | { |
| 1042 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1043 | |
| 1044 | mutex_lock(&mvm->mutex); |
| 1045 | |
| 1046 | iwl_mvm_cancel_scan(mvm); |
| 1047 | |
| 1048 | mutex_unlock(&mvm->mutex); |
| 1049 | } |
| 1050 | |
| 1051 | static void |
| 1052 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, |
| 1053 | struct ieee80211_sta *sta, u16 tid, |
| 1054 | int num_frames, |
| 1055 | enum ieee80211_frame_release_type reason, |
| 1056 | bool more_data) |
| 1057 | { |
| 1058 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1059 | |
| 1060 | /* TODO: how do we tell the fw to send frames for a specific TID */ |
| 1061 | |
| 1062 | /* |
| 1063 | * The fw will send EOSP notification when the last frame will be |
| 1064 | * transmitted. |
| 1065 | */ |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 1066 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
| 1070 | struct ieee80211_vif *vif, |
| 1071 | enum sta_notify_cmd cmd, |
| 1072 | struct ieee80211_sta *sta) |
| 1073 | { |
| 1074 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 5b577a9 | 2013-11-14 18:20:04 +0100 | [diff] [blame] | 1075 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1076 | |
| 1077 | switch (cmd) { |
| 1078 | case STA_NOTIFY_SLEEP: |
Emmanuel Grumbach | e3d4bc8 | 2013-05-07 14:08:24 +0300 | [diff] [blame] | 1079 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1080 | ieee80211_sta_block_awake(hw, sta, true); |
| 1081 | /* |
| 1082 | * The fw updates the STA to be asleep. Tx packets on the Tx |
| 1083 | * queues to this station will not be transmitted. The fw will |
| 1084 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. |
| 1085 | */ |
| 1086 | break; |
| 1087 | case STA_NOTIFY_AWAKE: |
Emmanuel Grumbach | 881acd8 | 2013-03-19 16:16:00 +0200 | [diff] [blame] | 1088 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1089 | break; |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 1090 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1091 | break; |
| 1092 | default: |
| 1093 | break; |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
| 1098 | struct ieee80211_vif *vif, |
| 1099 | struct ieee80211_sta *sta, |
| 1100 | enum ieee80211_sta_state old_state, |
| 1101 | enum ieee80211_sta_state new_state) |
| 1102 | { |
| 1103 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1104 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1105 | int ret; |
| 1106 | |
| 1107 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", |
| 1108 | sta->addr, old_state, new_state); |
| 1109 | |
| 1110 | /* this would be a mac80211 bug ... but don't crash */ |
| 1111 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) |
| 1112 | return -EINVAL; |
| 1113 | |
| 1114 | /* if a STA is being removed, reuse its ID */ |
| 1115 | flush_work(&mvm->sta_drained_wk); |
| 1116 | |
| 1117 | mutex_lock(&mvm->mutex); |
| 1118 | if (old_state == IEEE80211_STA_NOTEXIST && |
| 1119 | new_state == IEEE80211_STA_NONE) { |
Johannes Berg | 48bc130 | 2013-07-04 15:55:29 +0200 | [diff] [blame] | 1120 | /* |
| 1121 | * Firmware bug - it'll crash if the beacon interval is less |
| 1122 | * than 16. We can't avoid connecting at all, so refuse the |
| 1123 | * station state change, this will cause mac80211 to abandon |
| 1124 | * attempts to connect to this AP, and eventually wpa_s will |
| 1125 | * blacklist the AP... |
| 1126 | */ |
| 1127 | if (vif->type == NL80211_IFTYPE_STATION && |
| 1128 | vif->bss_conf.beacon_int < 16) { |
| 1129 | IWL_ERR(mvm, |
| 1130 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", |
| 1131 | sta->addr, vif->bss_conf.beacon_int); |
| 1132 | ret = -EINVAL; |
| 1133 | goto out_unlock; |
| 1134 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1135 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
| 1136 | } else if (old_state == IEEE80211_STA_NONE && |
| 1137 | new_state == IEEE80211_STA_AUTH) { |
| 1138 | ret = 0; |
| 1139 | } else if (old_state == IEEE80211_STA_AUTH && |
| 1140 | new_state == IEEE80211_STA_ASSOC) { |
Johannes Berg | 7a45397 | 2013-02-12 13:10:44 +0100 | [diff] [blame] | 1141 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
| 1142 | if (ret == 0) |
| 1143 | iwl_mvm_rs_rate_init(mvm, sta, |
Eyal Shapira | b87c217 | 2013-11-09 23:37:55 +0200 | [diff] [blame] | 1144 | mvmvif->phy_ctxt->channel->band, |
| 1145 | true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1146 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 1147 | new_state == IEEE80211_STA_AUTHORIZED) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1148 | /* enable beacon filtering */ |
| 1149 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1150 | ret = 0; |
| 1151 | } else if (old_state == IEEE80211_STA_AUTHORIZED && |
| 1152 | new_state == IEEE80211_STA_ASSOC) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1153 | /* disable beacon filtering */ |
| 1154 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1155 | ret = 0; |
| 1156 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 1157 | new_state == IEEE80211_STA_AUTH) { |
| 1158 | ret = 0; |
| 1159 | } else if (old_state == IEEE80211_STA_AUTH && |
| 1160 | new_state == IEEE80211_STA_NONE) { |
| 1161 | ret = 0; |
| 1162 | } else if (old_state == IEEE80211_STA_NONE && |
| 1163 | new_state == IEEE80211_STA_NOTEXIST) { |
| 1164 | ret = iwl_mvm_rm_sta(mvm, vif, sta); |
| 1165 | } else { |
| 1166 | ret = -EIO; |
| 1167 | } |
Johannes Berg | 48bc130 | 2013-07-04 15:55:29 +0200 | [diff] [blame] | 1168 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1169 | mutex_unlock(&mvm->mutex); |
| 1170 | |
| 1171 | return ret; |
| 1172 | } |
| 1173 | |
| 1174 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
| 1175 | { |
| 1176 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1177 | |
| 1178 | mvm->rts_threshold = value; |
| 1179 | |
| 1180 | return 0; |
| 1181 | } |
| 1182 | |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 1183 | static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, |
| 1184 | struct ieee80211_vif *vif, |
| 1185 | struct ieee80211_sta *sta, u32 changed) |
| 1186 | { |
| 1187 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1188 | |
| 1189 | if (vif->type == NL80211_IFTYPE_STATION && |
| 1190 | changed & IEEE80211_RC_NSS_CHANGED) |
| 1191 | iwl_mvm_sf_update(mvm, vif, false); |
| 1192 | } |
| 1193 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1194 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
| 1195 | struct ieee80211_vif *vif, u16 ac, |
| 1196 | const struct ieee80211_tx_queue_params *params) |
| 1197 | { |
| 1198 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1199 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1200 | |
| 1201 | mvmvif->queue_params[ac] = *params; |
| 1202 | |
| 1203 | /* |
| 1204 | * No need to update right away, we'll get BSS_CHANGED_QOS |
| 1205 | * The exception is P2P_DEVICE interface which needs immediate update. |
| 1206 | */ |
| 1207 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1208 | int ret; |
| 1209 | |
| 1210 | mutex_lock(&mvm->mutex); |
| 1211 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 1212 | mutex_unlock(&mvm->mutex); |
| 1213 | return ret; |
| 1214 | } |
| 1215 | return 0; |
| 1216 | } |
| 1217 | |
| 1218 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, |
| 1219 | struct ieee80211_vif *vif) |
| 1220 | { |
| 1221 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1222 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, |
| 1223 | 200 + vif->bss_conf.beacon_int); |
| 1224 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, |
| 1225 | 100 + vif->bss_conf.beacon_int); |
| 1226 | |
| 1227 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) |
| 1228 | return; |
| 1229 | |
| 1230 | mutex_lock(&mvm->mutex); |
| 1231 | /* Try really hard to protect the session and hear a beacon */ |
Johannes Berg | 016d27e | 2013-05-03 11:16:15 +0200 | [diff] [blame] | 1232 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1233 | mutex_unlock(&mvm->mutex); |
| 1234 | } |
| 1235 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 1236 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
| 1237 | struct ieee80211_vif *vif, |
| 1238 | struct cfg80211_sched_scan_request *req, |
| 1239 | struct ieee80211_sched_scan_ies *ies) |
| 1240 | { |
| 1241 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1242 | int ret; |
| 1243 | |
| 1244 | mutex_lock(&mvm->mutex); |
| 1245 | |
| 1246 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { |
| 1247 | IWL_DEBUG_SCAN(mvm, |
| 1248 | "SCHED SCAN request during internal scan - abort\n"); |
| 1249 | ret = -EBUSY; |
| 1250 | goto out; |
| 1251 | } |
| 1252 | |
| 1253 | mvm->scan_status = IWL_MVM_SCAN_SCHED; |
| 1254 | |
| 1255 | ret = iwl_mvm_config_sched_scan(mvm, vif, req, ies); |
| 1256 | if (ret) |
| 1257 | goto err; |
| 1258 | |
| 1259 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); |
| 1260 | if (ret) |
| 1261 | goto err; |
| 1262 | |
| 1263 | ret = iwl_mvm_sched_scan_start(mvm, req); |
| 1264 | if (!ret) |
| 1265 | goto out; |
| 1266 | err: |
| 1267 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 1268 | out: |
| 1269 | mutex_unlock(&mvm->mutex); |
| 1270 | return ret; |
| 1271 | } |
| 1272 | |
| 1273 | static void iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, |
| 1274 | struct ieee80211_vif *vif) |
| 1275 | { |
| 1276 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1277 | |
| 1278 | mutex_lock(&mvm->mutex); |
| 1279 | iwl_mvm_sched_scan_stop(mvm); |
| 1280 | mutex_unlock(&mvm->mutex); |
| 1281 | } |
| 1282 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1283 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
| 1284 | enum set_key_cmd cmd, |
| 1285 | struct ieee80211_vif *vif, |
| 1286 | struct ieee80211_sta *sta, |
| 1287 | struct ieee80211_key_conf *key) |
| 1288 | { |
| 1289 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1290 | int ret; |
| 1291 | |
| 1292 | if (iwlwifi_mod_params.sw_crypto) { |
| 1293 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); |
| 1294 | return -EOPNOTSUPP; |
| 1295 | } |
| 1296 | |
| 1297 | switch (key->cipher) { |
| 1298 | case WLAN_CIPHER_SUITE_TKIP: |
| 1299 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
| 1300 | /* fall-through */ |
| 1301 | case WLAN_CIPHER_SUITE_CCMP: |
| 1302 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
| 1303 | break; |
| 1304 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 1305 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); |
| 1306 | break; |
| 1307 | case WLAN_CIPHER_SUITE_WEP40: |
| 1308 | case WLAN_CIPHER_SUITE_WEP104: |
| 1309 | /* |
| 1310 | * Support for TX only, at least for now, so accept |
| 1311 | * the key and do nothing else. Then mac80211 will |
| 1312 | * pass it for TX but we don't have to use it for RX. |
| 1313 | */ |
| 1314 | return 0; |
| 1315 | default: |
Max Stepanov | e36e543 | 2013-08-27 19:56:13 +0300 | [diff] [blame] | 1316 | /* currently FW supports only one optional cipher scheme */ |
| 1317 | if (hw->n_cipher_schemes && |
| 1318 | hw->cipher_schemes->cipher == key->cipher) |
| 1319 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; |
| 1320 | else |
| 1321 | return -EOPNOTSUPP; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1322 | } |
| 1323 | |
| 1324 | mutex_lock(&mvm->mutex); |
| 1325 | |
| 1326 | switch (cmd) { |
| 1327 | case SET_KEY: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1328 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 1329 | vif->type == NL80211_IFTYPE_AP) && !sta) { |
| 1330 | /* |
| 1331 | * GTK on AP interface is a TX-only key, return 0; |
| 1332 | * on IBSS they're per-station and because we're lazy |
| 1333 | * we don't support them for RX, so do the same. |
| 1334 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1335 | ret = 0; |
| 1336 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
| 1337 | break; |
| 1338 | } |
| 1339 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1340 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
| 1341 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); |
| 1342 | if (ret) { |
| 1343 | IWL_WARN(mvm, "set key failed\n"); |
| 1344 | /* |
| 1345 | * can't add key for RX, but we don't need it |
| 1346 | * in the device for TX so still return 0 |
| 1347 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1348 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1349 | ret = 0; |
| 1350 | } |
| 1351 | |
| 1352 | break; |
| 1353 | case DISABLE_KEY: |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1354 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
| 1355 | ret = 0; |
| 1356 | break; |
| 1357 | } |
| 1358 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1359 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
| 1360 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); |
| 1361 | break; |
| 1362 | default: |
| 1363 | ret = -EINVAL; |
| 1364 | } |
| 1365 | |
| 1366 | mutex_unlock(&mvm->mutex); |
| 1367 | return ret; |
| 1368 | } |
| 1369 | |
| 1370 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 1371 | struct ieee80211_vif *vif, |
| 1372 | struct ieee80211_key_conf *keyconf, |
| 1373 | struct ieee80211_sta *sta, |
| 1374 | u32 iv32, u16 *phase1key) |
| 1375 | { |
| 1376 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1377 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1378 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
| 1379 | return; |
| 1380 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1381 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
| 1382 | } |
| 1383 | |
| 1384 | |
| 1385 | static int iwl_mvm_roc(struct ieee80211_hw *hw, |
| 1386 | struct ieee80211_vif *vif, |
| 1387 | struct ieee80211_channel *channel, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 1388 | int duration, |
| 1389 | enum ieee80211_roc_type type) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1390 | { |
| 1391 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1392 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1393 | struct cfg80211_chan_def chandef; |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1394 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
| 1395 | int ret, i; |
| 1396 | |
| 1397 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, |
| 1398 | duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1399 | |
| 1400 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) { |
| 1401 | IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type); |
| 1402 | return -EINVAL; |
| 1403 | } |
| 1404 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1405 | mutex_lock(&mvm->mutex); |
| 1406 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1407 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 1408 | phy_ctxt = &mvm->phy_ctxts[i]; |
| 1409 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) |
| 1410 | continue; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1411 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1412 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { |
| 1413 | /* |
| 1414 | * Unbind the P2P_DEVICE from the current PHY context, |
| 1415 | * and if the PHY context is not used remove it. |
| 1416 | */ |
| 1417 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 1418 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 1419 | goto out_unlock; |
| 1420 | |
| 1421 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 1422 | |
| 1423 | /* Bind the P2P_DEVICE to the current PHY Context */ |
| 1424 | mvmvif->phy_ctxt = phy_ctxt; |
| 1425 | |
| 1426 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1427 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 1428 | goto out_unlock; |
| 1429 | |
| 1430 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 1431 | goto schedule_time_event; |
| 1432 | } |
| 1433 | } |
| 1434 | |
| 1435 | /* Need to update the PHY context only if the ROC channel changed */ |
| 1436 | if (channel == mvmvif->phy_ctxt->channel) |
| 1437 | goto schedule_time_event; |
| 1438 | |
| 1439 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
| 1440 | |
| 1441 | /* |
| 1442 | * Change the PHY context configuration as it is currently referenced |
| 1443 | * only by the P2P Device MAC |
| 1444 | */ |
| 1445 | if (mvmvif->phy_ctxt->ref == 1) { |
| 1446 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, |
| 1447 | &chandef, 1, 1); |
| 1448 | if (ret) |
| 1449 | goto out_unlock; |
| 1450 | } else { |
| 1451 | /* |
| 1452 | * The PHY context is shared with other MACs. Need to remove the |
| 1453 | * P2P Device from the binding, allocate an new PHY context and |
| 1454 | * create a new binding |
| 1455 | */ |
| 1456 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1457 | if (!phy_ctxt) { |
| 1458 | ret = -ENOSPC; |
| 1459 | goto out_unlock; |
| 1460 | } |
| 1461 | |
| 1462 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, |
| 1463 | 1, 1); |
| 1464 | if (ret) { |
| 1465 | IWL_ERR(mvm, "Failed to change PHY context\n"); |
| 1466 | goto out_unlock; |
| 1467 | } |
| 1468 | |
| 1469 | /* Unbind the P2P_DEVICE from the current PHY context */ |
| 1470 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 1471 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 1472 | goto out_unlock; |
| 1473 | |
| 1474 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 1475 | |
| 1476 | /* Bind the P2P_DEVICE to the new allocated PHY context */ |
| 1477 | mvmvif->phy_ctxt = phy_ctxt; |
| 1478 | |
| 1479 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1480 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 1481 | goto out_unlock; |
| 1482 | |
| 1483 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 1484 | } |
| 1485 | |
| 1486 | schedule_time_event: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1487 | /* Schedule the time events */ |
Ilan Peer | e635c79 | 2013-02-13 11:05:18 +0200 | [diff] [blame] | 1488 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1489 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1490 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1491 | mutex_unlock(&mvm->mutex); |
| 1492 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1493 | return ret; |
| 1494 | } |
| 1495 | |
| 1496 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) |
| 1497 | { |
| 1498 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1499 | |
| 1500 | IWL_DEBUG_MAC80211(mvm, "enter\n"); |
| 1501 | |
| 1502 | mutex_lock(&mvm->mutex); |
| 1503 | iwl_mvm_stop_p2p_roc(mvm); |
| 1504 | mutex_unlock(&mvm->mutex); |
| 1505 | |
| 1506 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
| 1507 | return 0; |
| 1508 | } |
| 1509 | |
| 1510 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, |
| 1511 | struct ieee80211_chanctx_conf *ctx) |
| 1512 | { |
| 1513 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1514 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1515 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1516 | int ret; |
| 1517 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1518 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1519 | |
| 1520 | mutex_lock(&mvm->mutex); |
| 1521 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1522 | if (!phy_ctxt) { |
| 1523 | ret = -ENOSPC; |
| 1524 | goto out; |
| 1525 | } |
| 1526 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1527 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
| 1528 | ctx->rx_chains_static, |
| 1529 | ctx->rx_chains_dynamic); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1530 | if (ret) { |
| 1531 | IWL_ERR(mvm, "Failed to add PHY context\n"); |
| 1532 | goto out; |
| 1533 | } |
| 1534 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1535 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1536 | *phy_ctxt_id = phy_ctxt->id; |
| 1537 | out: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1538 | mutex_unlock(&mvm->mutex); |
| 1539 | return ret; |
| 1540 | } |
| 1541 | |
| 1542 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
| 1543 | struct ieee80211_chanctx_conf *ctx) |
| 1544 | { |
| 1545 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1546 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1547 | 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] | 1548 | |
| 1549 | mutex_lock(&mvm->mutex); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1550 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1551 | mutex_unlock(&mvm->mutex); |
| 1552 | } |
| 1553 | |
| 1554 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, |
| 1555 | struct ieee80211_chanctx_conf *ctx, |
| 1556 | u32 changed) |
| 1557 | { |
| 1558 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1559 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1560 | 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] | 1561 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1562 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
| 1563 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | |
| 1564 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | |
| 1565 | IEEE80211_CHANCTX_CHANGE_RADAR)), |
| 1566 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
| 1567 | phy_ctxt->ref, changed)) |
| 1568 | return; |
| 1569 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1570 | mutex_lock(&mvm->mutex); |
| 1571 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
| 1572 | ctx->rx_chains_static, |
| 1573 | ctx->rx_chains_dynamic); |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 1574 | iwl_mvm_bt_coex_vif_change(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1575 | mutex_unlock(&mvm->mutex); |
| 1576 | } |
| 1577 | |
| 1578 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 1579 | struct ieee80211_vif *vif, |
| 1580 | struct ieee80211_chanctx_conf *ctx) |
| 1581 | { |
| 1582 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1583 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1584 | 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] | 1585 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1586 | int ret; |
| 1587 | |
| 1588 | mutex_lock(&mvm->mutex); |
| 1589 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1590 | mvmvif->phy_ctxt = phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1591 | |
| 1592 | switch (vif->type) { |
| 1593 | case NL80211_IFTYPE_AP: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1594 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1595 | /* |
| 1596 | * 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] | 1597 | * (in bss_info_changed), similarly for IBSS. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1598 | */ |
| 1599 | ret = 0; |
| 1600 | goto out_unlock; |
| 1601 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1602 | case NL80211_IFTYPE_MONITOR: |
| 1603 | break; |
| 1604 | default: |
| 1605 | ret = -EINVAL; |
| 1606 | goto out_unlock; |
| 1607 | } |
| 1608 | |
| 1609 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1610 | if (ret) |
| 1611 | goto out_unlock; |
| 1612 | |
| 1613 | /* |
Alexander Bondar | 92d8556 | 2013-10-23 11:50:34 +0200 | [diff] [blame] | 1614 | * Power state must be updated before quotas, |
| 1615 | * otherwise fw will complain. |
| 1616 | */ |
| 1617 | mvm->bound_vif_cnt++; |
| 1618 | iwl_mvm_power_update_binding(mvm, vif, true); |
| 1619 | |
| 1620 | /* Setting the quota at this stage is only required for monitor |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1621 | * interfaces. For the other types, the bss_info changed flow |
| 1622 | * will handle quota settings. |
| 1623 | */ |
| 1624 | if (vif->type == NL80211_IFTYPE_MONITOR) { |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1625 | mvmvif->monitor_active = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1626 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 1627 | if (ret) |
| 1628 | goto out_remove_binding; |
| 1629 | } |
| 1630 | |
| 1631 | goto out_unlock; |
| 1632 | |
| 1633 | out_remove_binding: |
| 1634 | iwl_mvm_binding_remove_vif(mvm, vif); |
Alexander Bondar | 92d8556 | 2013-10-23 11:50:34 +0200 | [diff] [blame] | 1635 | mvm->bound_vif_cnt--; |
| 1636 | iwl_mvm_power_update_binding(mvm, vif, false); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1637 | out_unlock: |
| 1638 | mutex_unlock(&mvm->mutex); |
| 1639 | if (ret) |
| 1640 | mvmvif->phy_ctxt = NULL; |
| 1641 | return ret; |
| 1642 | } |
| 1643 | |
| 1644 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 1645 | struct ieee80211_vif *vif, |
| 1646 | struct ieee80211_chanctx_conf *ctx) |
| 1647 | { |
| 1648 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1649 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1650 | |
| 1651 | mutex_lock(&mvm->mutex); |
| 1652 | |
| 1653 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); |
| 1654 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1655 | switch (vif->type) { |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1656 | case NL80211_IFTYPE_AP: |
| 1657 | case NL80211_IFTYPE_ADHOC: |
| 1658 | goto out_unlock; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1659 | case NL80211_IFTYPE_MONITOR: |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1660 | mvmvif->monitor_active = false; |
| 1661 | iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1662 | break; |
| 1663 | default: |
| 1664 | break; |
| 1665 | } |
| 1666 | |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1667 | iwl_mvm_binding_remove_vif(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1668 | out_unlock: |
| 1669 | mvmvif->phy_ctxt = NULL; |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 1670 | mvm->bound_vif_cnt--; |
Alexander Bondar | 92d8556 | 2013-10-23 11:50:34 +0200 | [diff] [blame] | 1671 | iwl_mvm_power_update_binding(mvm, vif, false); |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 1672 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1673 | mutex_unlock(&mvm->mutex); |
| 1674 | } |
| 1675 | |
| 1676 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, |
| 1677 | struct ieee80211_sta *sta, |
| 1678 | bool set) |
| 1679 | { |
| 1680 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1681 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; |
| 1682 | |
| 1683 | if (!mvm_sta || !mvm_sta->vif) { |
| 1684 | IWL_ERR(mvm, "Station is not associated to a vif\n"); |
| 1685 | return -EINVAL; |
| 1686 | } |
| 1687 | |
| 1688 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); |
| 1689 | } |
| 1690 | |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1691 | #ifdef CONFIG_NL80211_TESTMODE |
| 1692 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { |
| 1693 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 1694 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, |
Johannes Berg | f6c6ad42 | 2013-08-01 14:17:15 +0200 | [diff] [blame] | 1695 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1696 | }; |
| 1697 | |
| 1698 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, |
| 1699 | struct ieee80211_vif *vif, |
| 1700 | void *data, int len) |
| 1701 | { |
| 1702 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; |
| 1703 | int err; |
| 1704 | u32 noa_duration; |
| 1705 | |
| 1706 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy); |
| 1707 | if (err) |
| 1708 | return err; |
| 1709 | |
| 1710 | if (!tb[IWL_MVM_TM_ATTR_CMD]) |
| 1711 | return -EINVAL; |
| 1712 | |
| 1713 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { |
| 1714 | case IWL_MVM_TM_CMD_SET_NOA: |
| 1715 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || |
| 1716 | !vif->bss_conf.enable_beacon || |
| 1717 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) |
| 1718 | return -EINVAL; |
| 1719 | |
| 1720 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); |
| 1721 | if (noa_duration >= vif->bss_conf.beacon_int) |
| 1722 | return -EINVAL; |
| 1723 | |
| 1724 | mvm->noa_duration = noa_duration; |
| 1725 | mvm->noa_vif = vif; |
| 1726 | |
| 1727 | return iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | f6c6ad42 | 2013-08-01 14:17:15 +0200 | [diff] [blame] | 1728 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
| 1729 | /* must be associated client vif - ignore authorized */ |
| 1730 | if (!vif || vif->type != NL80211_IFTYPE_STATION || |
| 1731 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || |
| 1732 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) |
| 1733 | return -EINVAL; |
| 1734 | |
| 1735 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) |
| 1736 | return iwl_mvm_enable_beacon_filter(mvm, vif); |
| 1737 | return iwl_mvm_disable_beacon_filter(mvm, vif); |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | return -EOPNOTSUPP; |
| 1741 | } |
| 1742 | |
| 1743 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, |
| 1744 | struct ieee80211_vif *vif, |
| 1745 | void *data, int len) |
| 1746 | { |
| 1747 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1748 | int err; |
| 1749 | |
| 1750 | mutex_lock(&mvm->mutex); |
| 1751 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); |
| 1752 | mutex_unlock(&mvm->mutex); |
| 1753 | |
| 1754 | return err; |
| 1755 | } |
| 1756 | #endif |
| 1757 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1758 | struct ieee80211_ops iwl_mvm_hw_ops = { |
| 1759 | .tx = iwl_mvm_mac_tx, |
| 1760 | .ampdu_action = iwl_mvm_mac_ampdu_action, |
| 1761 | .start = iwl_mvm_mac_start, |
| 1762 | .restart_complete = iwl_mvm_mac_restart_complete, |
| 1763 | .stop = iwl_mvm_mac_stop, |
| 1764 | .add_interface = iwl_mvm_mac_add_interface, |
| 1765 | .remove_interface = iwl_mvm_mac_remove_interface, |
| 1766 | .config = iwl_mvm_mac_config, |
| 1767 | .configure_filter = iwl_mvm_configure_filter, |
| 1768 | .bss_info_changed = iwl_mvm_bss_info_changed, |
| 1769 | .hw_scan = iwl_mvm_mac_hw_scan, |
| 1770 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, |
| 1771 | .sta_state = iwl_mvm_mac_sta_state, |
| 1772 | .sta_notify = iwl_mvm_mac_sta_notify, |
| 1773 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, |
| 1774 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 1775 | .sta_rc_update = iwl_mvm_sta_rc_update, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1776 | .conf_tx = iwl_mvm_mac_conf_tx, |
| 1777 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 1778 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
| 1779 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1780 | .set_key = iwl_mvm_mac_set_key, |
| 1781 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, |
| 1782 | .remain_on_channel = iwl_mvm_roc, |
| 1783 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1784 | .add_chanctx = iwl_mvm_add_chanctx, |
| 1785 | .remove_chanctx = iwl_mvm_remove_chanctx, |
| 1786 | .change_chanctx = iwl_mvm_change_chanctx, |
| 1787 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, |
| 1788 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, |
| 1789 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1790 | .start_ap = iwl_mvm_start_ap_ibss, |
| 1791 | .stop_ap = iwl_mvm_stop_ap_ibss, |
| 1792 | .join_ibss = iwl_mvm_start_ap_ibss, |
| 1793 | .leave_ibss = iwl_mvm_stop_ap_ibss, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1794 | |
| 1795 | .set_tim = iwl_mvm_set_tim, |
| 1796 | |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1797 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
| 1798 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1799 | #ifdef CONFIG_PM_SLEEP |
| 1800 | /* look at d3.c */ |
| 1801 | .suspend = iwl_mvm_suspend, |
| 1802 | .resume = iwl_mvm_resume, |
| 1803 | .set_wakeup = iwl_mvm_set_wakeup, |
| 1804 | .set_rekey_data = iwl_mvm_set_rekey_data, |
| 1805 | #if IS_ENABLED(CONFIG_IPV6) |
| 1806 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, |
| 1807 | #endif |
| 1808 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, |
| 1809 | #endif |
| 1810 | }; |