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" |
| 80 | |
| 81 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { |
| 82 | { |
| 83 | .max = 1, |
Ilan Peer | 8eb3871 | 2013-06-01 20:17:18 +0300 | [diff] [blame] | 84 | .types = BIT(NL80211_IFTYPE_STATION), |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 85 | }, |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 86 | { |
| 87 | .max = 1, |
Ilan Peer | 8eb3871 | 2013-06-01 20:17:18 +0300 | [diff] [blame] | 88 | .types = BIT(NL80211_IFTYPE_AP) | |
| 89 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 90 | BIT(NL80211_IFTYPE_P2P_GO), |
| 91 | }, |
| 92 | { |
| 93 | .max = 1, |
| 94 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), |
| 95 | }, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { |
| 99 | { |
| 100 | .num_different_channels = 1, |
| 101 | .max_interfaces = 3, |
| 102 | .limits = iwl_mvm_limits, |
| 103 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), |
| 104 | }, |
| 105 | }; |
| 106 | |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 107 | #ifdef CONFIG_PM_SLEEP |
| 108 | static const struct nl80211_wowlan_tcp_data_token_feature |
| 109 | iwl_mvm_wowlan_tcp_token_feature = { |
| 110 | .min_len = 0, |
| 111 | .max_len = 255, |
| 112 | .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS, |
| 113 | }; |
| 114 | |
| 115 | static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = { |
| 116 | .tok = &iwl_mvm_wowlan_tcp_token_feature, |
| 117 | .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN - |
| 118 | sizeof(struct ethhdr) - |
| 119 | sizeof(struct iphdr) - |
| 120 | sizeof(struct tcphdr), |
| 121 | .data_interval_max = 65535, /* __le16 in API */ |
| 122 | .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN - |
| 123 | sizeof(struct ethhdr) - |
| 124 | sizeof(struct iphdr) - |
| 125 | sizeof(struct tcphdr), |
| 126 | .seq = true, |
| 127 | }; |
| 128 | #endif |
| 129 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 130 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
| 131 | { |
| 132 | int i; |
| 133 | |
| 134 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); |
| 135 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 136 | mvm->phy_ctxts[i].id = i; |
| 137 | mvm->phy_ctxts[i].ref = 0; |
| 138 | } |
| 139 | } |
| 140 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 141 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
| 142 | { |
| 143 | struct ieee80211_hw *hw = mvm->hw; |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 144 | int num_mac, ret, i; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 145 | |
| 146 | /* Tell mac80211 our characteristics */ |
| 147 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
| 148 | IEEE80211_HW_SPECTRUM_MGMT | |
| 149 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
| 150 | IEEE80211_HW_QUEUE_CONTROL | |
| 151 | IEEE80211_HW_WANT_MONITOR_VIF | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 152 | IEEE80211_HW_SUPPORTS_PS | |
| 153 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | |
Johannes Berg | d2931bb | 2013-02-05 18:10:04 +0100 | [diff] [blame] | 154 | IEEE80211_HW_AMPDU_AGGREGATION | |
Hila Gonen | d64048e | 2013-03-13 18:00:03 +0200 | [diff] [blame] | 155 | IEEE80211_HW_TIMING_BEACON_ONLY | |
Emmanuel Grumbach | 147fc9b | 2013-07-28 11:00:52 +0300 | [diff] [blame] | 156 | IEEE80211_HW_CONNECTION_MONITOR | |
| 157 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | |
| 158 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 159 | |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 160 | hw->queues = IWL_MVM_FIRST_AGG_QUEUE; |
| 161 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 162 | hw->rate_control_algorithm = "iwl-mvm-rs"; |
| 163 | |
| 164 | /* |
| 165 | * Enable 11w if advertised by firmware and software crypto |
| 166 | * is not enabled (as the firmware will interpret some mgmt |
| 167 | * packets, so enabling it with software crypto isn't safe) |
| 168 | */ |
| 169 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && |
| 170 | !iwlwifi_mod_params.sw_crypto) |
| 171 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; |
| 172 | |
| 173 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
| 174 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 175 | hw->chanctx_data_size = sizeof(u16); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 176 | |
| 177 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 178 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 179 | BIT(NL80211_IFTYPE_AP) | |
| 180 | BIT(NL80211_IFTYPE_P2P_GO) | |
| 181 | BIT(NL80211_IFTYPE_P2P_DEVICE); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 182 | |
| 183 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | |
| 184 | WIPHY_FLAG_DISABLE_BEACON_HINTS | |
| 185 | WIPHY_FLAG_IBSS_RSN; |
| 186 | |
| 187 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
| 188 | hw->wiphy->n_iface_combinations = |
| 189 | ARRAY_SIZE(iwl_mvm_iface_combinations); |
| 190 | |
Ilan Peer | c451e6d | 2013-02-20 08:41:54 +0200 | [diff] [blame] | 191 | hw->wiphy->max_remain_on_channel_duration = 10000; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 192 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
| 193 | |
| 194 | /* Extract MAC address */ |
| 195 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); |
| 196 | hw->wiphy->addresses = mvm->addresses; |
| 197 | hw->wiphy->n_addresses = 1; |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 198 | |
| 199 | /* Extract additional MAC addresses if available */ |
| 200 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? |
| 201 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; |
| 202 | |
| 203 | for (i = 1; i < num_mac; i++) { |
| 204 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 205 | ETH_ALEN); |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 206 | mvm->addresses[i].addr[5]++; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 207 | hw->wiphy->n_addresses++; |
| 208 | } |
| 209 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 210 | iwl_mvm_reset_phy_ctxts(mvm); |
| 211 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 212 | /* we create the 802.11 header and a max-length SSID element */ |
| 213 | hw->wiphy->max_scan_ie_len = |
| 214 | mvm->fw->ucode_capa.max_probe_length - 24 - 34; |
| 215 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
| 216 | |
| 217 | if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels) |
| 218 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 219 | &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; |
| 220 | if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels) |
| 221 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 222 | &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; |
| 223 | |
| 224 | hw->wiphy->hw_version = mvm->trans->hw_id; |
| 225 | |
Alexander Bondar | ade5065 | 2013-04-03 16:28:47 +0300 | [diff] [blame] | 226 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 227 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 228 | else |
| 229 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 230 | |
| 231 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
| 232 | NL80211_FEATURE_P2P_GO_OPPPS; |
| 233 | |
| 234 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
| 235 | |
| 236 | #ifdef CONFIG_PM_SLEEP |
| 237 | if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && |
| 238 | mvm->trans->ops->d3_suspend && |
| 239 | mvm->trans->ops->d3_resume && |
| 240 | device_can_wakeup(mvm->trans->dev)) { |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 241 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
| 242 | WIPHY_WOWLAN_DISCONNECT | |
| 243 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 244 | WIPHY_WOWLAN_RFKILL_RELEASE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 245 | if (!iwlwifi_mod_params.sw_crypto) |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 246 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 247 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 248 | WIPHY_WOWLAN_4WAY_HANDSHAKE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 249 | |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 250 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; |
| 251 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; |
| 252 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; |
| 253 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; |
| 254 | hw->wiphy->wowlan = &mvm->wowlan; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 255 | } |
| 256 | #endif |
| 257 | |
| 258 | ret = iwl_mvm_leds_init(mvm); |
| 259 | if (ret) |
| 260 | return ret; |
| 261 | |
| 262 | return ieee80211_register_hw(mvm->hw); |
| 263 | } |
| 264 | |
| 265 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
| 266 | struct ieee80211_tx_control *control, |
| 267 | struct sk_buff *skb) |
| 268 | { |
| 269 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 270 | |
Eytan Lifshitz | 9ee718a | 2013-05-19 19:14:41 +0300 | [diff] [blame] | 271 | if (iwl_mvm_is_radio_killed(mvm)) { |
| 272 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 273 | goto drop; |
| 274 | } |
| 275 | |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 276 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 277 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) |
| 278 | goto drop; |
| 279 | |
| 280 | if (control->sta) { |
| 281 | if (iwl_mvm_tx_skb(mvm, skb, control->sta)) |
| 282 | goto drop; |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) |
| 287 | goto drop; |
| 288 | return; |
| 289 | drop: |
| 290 | ieee80211_free_txskb(hw, skb); |
| 291 | } |
| 292 | |
| 293 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
| 294 | struct ieee80211_vif *vif, |
| 295 | enum ieee80211_ampdu_mlme_action action, |
| 296 | struct ieee80211_sta *sta, u16 tid, |
| 297 | u16 *ssn, u8 buf_size) |
| 298 | { |
| 299 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 300 | int ret; |
| 301 | |
| 302 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", |
| 303 | sta->addr, tid, action); |
| 304 | |
| 305 | if (!(mvm->nvm_data->sku_cap_11n_enable)) |
| 306 | return -EACCES; |
| 307 | |
| 308 | mutex_lock(&mvm->mutex); |
| 309 | |
| 310 | switch (action) { |
| 311 | case IEEE80211_AMPDU_RX_START: |
| 312 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) { |
| 313 | ret = -EINVAL; |
| 314 | break; |
| 315 | } |
| 316 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); |
| 317 | break; |
| 318 | case IEEE80211_AMPDU_RX_STOP: |
| 319 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); |
| 320 | break; |
| 321 | case IEEE80211_AMPDU_TX_START: |
Emmanuel Grumbach | 5d158ef | 2013-02-19 14:39:58 +0200 | [diff] [blame] | 322 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) { |
| 323 | ret = -EINVAL; |
| 324 | break; |
| 325 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 326 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
| 327 | break; |
| 328 | case IEEE80211_AMPDU_TX_STOP_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 329 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
| 330 | break; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 331 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 332 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 333 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 334 | break; |
| 335 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 336 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); |
| 337 | break; |
| 338 | default: |
| 339 | WARN_ON_ONCE(1); |
| 340 | ret = -EINVAL; |
| 341 | break; |
| 342 | } |
| 343 | mutex_unlock(&mvm->mutex); |
| 344 | |
| 345 | return ret; |
| 346 | } |
| 347 | |
| 348 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, |
| 349 | struct ieee80211_vif *vif) |
| 350 | { |
| 351 | struct iwl_mvm *mvm = data; |
| 352 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 353 | |
| 354 | mvmvif->uploaded = false; |
| 355 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 356 | |
| 357 | /* does this make sense at all? */ |
| 358 | mvmvif->color++; |
| 359 | |
| 360 | spin_lock_bh(&mvm->time_event_lock); |
| 361 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); |
| 362 | spin_unlock_bh(&mvm->time_event_lock); |
| 363 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 364 | mvmvif->phy_ctxt = NULL; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) |
| 368 | { |
| 369 | iwl_trans_stop_device(mvm->trans); |
| 370 | iwl_trans_stop_hw(mvm->trans, false); |
| 371 | |
| 372 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 373 | |
| 374 | /* just in case one was running */ |
| 375 | ieee80211_remain_on_channel_expired(mvm->hw); |
| 376 | |
| 377 | ieee80211_iterate_active_interfaces_atomic( |
| 378 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 379 | iwl_mvm_cleanup_iterator, mvm); |
| 380 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 381 | mvm->p2p_device_vif = NULL; |
| 382 | |
| 383 | iwl_mvm_reset_phy_ctxts(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 384 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
| 385 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); |
| 386 | |
| 387 | ieee80211_wake_queues(mvm->hw); |
| 388 | |
| 389 | mvm->vif_count = 0; |
| 390 | } |
| 391 | |
| 392 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) |
| 393 | { |
| 394 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 395 | int ret; |
| 396 | |
| 397 | mutex_lock(&mvm->mutex); |
| 398 | |
| 399 | /* Clean up some internal and mac80211 state on restart */ |
| 400 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 401 | iwl_mvm_restart_cleanup(mvm); |
| 402 | |
| 403 | ret = iwl_mvm_up(mvm); |
| 404 | mutex_unlock(&mvm->mutex); |
| 405 | |
| 406 | return ret; |
| 407 | } |
| 408 | |
| 409 | static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw) |
| 410 | { |
| 411 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 412 | int ret; |
| 413 | |
| 414 | mutex_lock(&mvm->mutex); |
| 415 | |
| 416 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 417 | ret = iwl_mvm_update_quotas(mvm, NULL); |
| 418 | if (ret) |
| 419 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", |
| 420 | ret); |
| 421 | |
| 422 | mutex_unlock(&mvm->mutex); |
| 423 | } |
| 424 | |
| 425 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) |
| 426 | { |
| 427 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 428 | |
| 429 | flush_work(&mvm->async_handlers_wk); |
| 430 | |
| 431 | mutex_lock(&mvm->mutex); |
| 432 | /* async_handlers_wk is now blocked */ |
| 433 | |
| 434 | /* |
| 435 | * The work item could be running or queued if the |
| 436 | * ROC time event stops just as we get here. |
| 437 | */ |
| 438 | cancel_work_sync(&mvm->roc_done_wk); |
| 439 | |
| 440 | iwl_trans_stop_device(mvm->trans); |
| 441 | iwl_trans_stop_hw(mvm->trans, false); |
| 442 | |
| 443 | iwl_mvm_async_handlers_purge(mvm); |
| 444 | /* async_handlers_list is empty and will stay empty: HW is stopped */ |
| 445 | |
| 446 | /* the fw is stopped, the aux sta is dead: clean up driver state */ |
| 447 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); |
| 448 | |
| 449 | mutex_unlock(&mvm->mutex); |
| 450 | |
| 451 | /* |
| 452 | * The worker might have been waiting for the mutex, let it run and |
| 453 | * discover that its list is now empty. |
| 454 | */ |
| 455 | cancel_work_sync(&mvm->async_handlers_wk); |
| 456 | } |
| 457 | |
| 458 | static void iwl_mvm_pm_disable_iterator(void *data, u8 *mac, |
| 459 | struct ieee80211_vif *vif) |
| 460 | { |
| 461 | struct iwl_mvm *mvm = data; |
| 462 | int ret; |
| 463 | |
| 464 | ret = iwl_mvm_power_disable(mvm, vif); |
| 465 | if (ret) |
| 466 | IWL_ERR(mvm, "failed to disable power management\n"); |
| 467 | } |
| 468 | |
| 469 | static void iwl_mvm_power_update_iterator(void *data, u8 *mac, |
| 470 | struct ieee80211_vif *vif) |
| 471 | { |
| 472 | struct iwl_mvm *mvm = data; |
| 473 | |
| 474 | iwl_mvm_power_update_mode(mvm, vif); |
| 475 | } |
| 476 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 477 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
| 478 | { |
| 479 | u16 i; |
| 480 | |
| 481 | lockdep_assert_held(&mvm->mutex); |
| 482 | |
| 483 | for (i = 0; i < NUM_PHY_CTX; i++) |
| 484 | if (!mvm->phy_ctxts[i].ref) |
| 485 | return &mvm->phy_ctxts[i]; |
| 486 | |
| 487 | IWL_ERR(mvm, "No available PHY context\n"); |
| 488 | return NULL; |
| 489 | } |
| 490 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 491 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
| 492 | struct ieee80211_vif *vif) |
| 493 | { |
| 494 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 495 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 496 | int ret; |
| 497 | |
| 498 | /* |
| 499 | * Not much to do here. The stack will not allow interface |
| 500 | * types or combinations that we didn't advertise, so we |
| 501 | * don't really have to check the types. |
| 502 | */ |
| 503 | |
| 504 | mutex_lock(&mvm->mutex); |
| 505 | |
Eliad Peller | e89044d | 2013-07-16 17:33:26 +0300 | [diff] [blame] | 506 | /* Allocate resources for the MAC context, and add it to the fw */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 507 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
| 508 | if (ret) |
| 509 | goto out_unlock; |
| 510 | |
| 511 | /* |
| 512 | * The AP binding flow can be done only after the beacon |
| 513 | * template is configured (which happens only in the mac80211 |
| 514 | * start_ap() flow), and adding the broadcast station can happen |
| 515 | * only after the binding. |
| 516 | * In addition, since modifying the MAC before adding a bcast |
| 517 | * station is not allowed by the FW, delay the adding of MAC context to |
| 518 | * the point where we can also add the bcast station. |
| 519 | * In short: there's not much we can do at this point, other than |
| 520 | * allocating resources :) |
| 521 | */ |
| 522 | if (vif->type == NL80211_IFTYPE_AP) { |
| 523 | u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif); |
| 524 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, |
| 525 | qmask); |
| 526 | if (ret) { |
| 527 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); |
| 528 | goto out_release; |
| 529 | } |
| 530 | |
Emmanuel Grumbach | 77740cb | 2013-06-26 23:51:41 +0300 | [diff] [blame] | 531 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 532 | goto out_unlock; |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 | * TODO: remove this temporary code. |
| 537 | * Currently MVM FW supports power management only on single MAC. |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 538 | * If new interface added, disable PM on existing interface. |
| 539 | * P2P device is a special case, since it is handled by FW similary to |
| 540 | * scan. If P2P deviced is added, PM remains enabled on existing |
| 541 | * interface. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 542 | * Note: the method below does not count the new interface being added |
| 543 | * at this moment. |
| 544 | */ |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 545 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 546 | mvm->vif_count++; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 547 | if (mvm->vif_count > 1) { |
| 548 | IWL_DEBUG_MAC80211(mvm, |
| 549 | "Disable power on existing interfaces\n"); |
Emmanuel Grumbach | 5360cfb | 2013-02-11 15:56:01 +0200 | [diff] [blame] | 550 | ieee80211_iterate_active_interfaces_atomic( |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 551 | mvm->hw, |
| 552 | IEEE80211_IFACE_ITER_NORMAL, |
| 553 | iwl_mvm_pm_disable_iterator, mvm); |
| 554 | } |
| 555 | |
| 556 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 557 | if (ret) |
| 558 | goto out_release; |
| 559 | |
| 560 | /* |
| 561 | * Update power state on the new interface. Admittedly, based on |
| 562 | * mac80211 logics this power update will disable power management |
| 563 | */ |
| 564 | iwl_mvm_power_update_mode(mvm, vif); |
| 565 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 566 | /* beacon filtering */ |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame^] | 567 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
| 568 | if (ret) |
| 569 | goto out_remove_mac; |
| 570 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 571 | if (!mvm->bf_allowed_vif && |
Hila Gonen | 5dca7c2 | 2013-07-16 11:15:35 +0300 | [diff] [blame] | 572 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
| 573 | mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){ |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 574 | mvm->bf_allowed_vif = mvmvif; |
| 575 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; |
| 576 | } |
| 577 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 578 | /* |
| 579 | * P2P_DEVICE interface does not have a channel context assigned to it, |
| 580 | * so a dedicated PHY context is allocated to it and the corresponding |
| 581 | * MAC context is bound to it at this stage. |
| 582 | */ |
| 583 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 584 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 585 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 586 | if (!mvmvif->phy_ctxt) { |
| 587 | ret = -ENOSPC; |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame^] | 588 | goto out_free_bf; |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 589 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 590 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 591 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 592 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 593 | if (ret) |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 594 | goto out_unref_phy; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 595 | |
| 596 | ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta); |
| 597 | if (ret) |
| 598 | goto out_unbind; |
| 599 | |
| 600 | /* Save a pointer to p2p device vif, so it can later be used to |
| 601 | * update the p2p device MAC when a GO is started/stopped */ |
| 602 | mvm->p2p_device_vif = vif; |
| 603 | } |
| 604 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 605 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 606 | goto out_unlock; |
| 607 | |
| 608 | out_unbind: |
| 609 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 610 | out_unref_phy: |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 611 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame^] | 612 | out_free_bf: |
| 613 | if (mvm->bf_allowed_vif == mvmvif) { |
| 614 | mvm->bf_allowed_vif = NULL; |
| 615 | vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; |
| 616 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 617 | out_remove_mac: |
| 618 | mvmvif->phy_ctxt = NULL; |
| 619 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 620 | out_release: |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 621 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 622 | mvm->vif_count--; |
Alexander Bondar | 4bf881f | 2013-05-29 10:19:50 +0300 | [diff] [blame] | 623 | ieee80211_iterate_active_interfaces( |
| 624 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 625 | iwl_mvm_power_update_iterator, mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 626 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 627 | out_unlock: |
| 628 | mutex_unlock(&mvm->mutex); |
| 629 | |
| 630 | return ret; |
| 631 | } |
| 632 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 633 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
| 634 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 635 | { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 636 | u32 tfd_msk = 0, ac; |
| 637 | |
| 638 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 639 | if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) |
| 640 | tfd_msk |= BIT(vif->hw_queue[ac]); |
| 641 | |
| 642 | if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE) |
| 643 | tfd_msk |= BIT(vif->cab_queue); |
| 644 | |
| 645 | if (tfd_msk) { |
| 646 | mutex_lock(&mvm->mutex); |
| 647 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); |
| 648 | mutex_unlock(&mvm->mutex); |
| 649 | } |
| 650 | |
| 651 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 652 | /* |
| 653 | * Flush the ROC worker which will flush the OFFCHANNEL queue. |
| 654 | * We assume here that all the packets sent to the OFFCHANNEL |
| 655 | * queue are sent in ROC session. |
| 656 | */ |
| 657 | flush_work(&mvm->roc_done_wk); |
| 658 | } else { |
| 659 | /* |
| 660 | * By now, all the AC queues are empty. The AGG queues are |
| 661 | * empty too. We already got all the Tx responses for all the |
| 662 | * packets in the queues. The drain work can have been |
Emmanuel Grumbach | 0742a75 | 2013-06-10 14:10:33 +0300 | [diff] [blame] | 663 | * triggered. Flush it. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 664 | */ |
| 665 | flush_work(&mvm->sta_drained_wk); |
| 666 | } |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, |
| 670 | struct ieee80211_vif *vif) |
| 671 | { |
| 672 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 673 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 674 | |
| 675 | iwl_mvm_prepare_mac_removal(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 676 | |
| 677 | mutex_lock(&mvm->mutex); |
| 678 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 679 | if (mvm->bf_allowed_vif == mvmvif) { |
| 680 | mvm->bf_allowed_vif = NULL; |
| 681 | vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; |
| 682 | } |
| 683 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 684 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
| 685 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 686 | /* |
| 687 | * 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] | 688 | * interface is be handled as part of the stop_ap flow. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 689 | */ |
| 690 | if (vif->type == NL80211_IFTYPE_AP) { |
| 691 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); |
| 692 | goto out_release; |
| 693 | } |
| 694 | |
| 695 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 696 | mvm->p2p_device_vif = NULL; |
| 697 | iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 698 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 699 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 700 | mvmvif->phy_ctxt = NULL; |
| 701 | } |
| 702 | |
| 703 | /* |
| 704 | * TODO: remove this temporary code. |
| 705 | * Currently MVM FW supports power management only on single MAC. |
| 706 | * Check if only one additional interface remains after removing |
| 707 | * current one. Update power mode on the remaining interface. |
| 708 | */ |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 709 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 710 | mvm->vif_count--; |
| 711 | IWL_DEBUG_MAC80211(mvm, "Currently %d interfaces active\n", |
| 712 | mvm->vif_count); |
| 713 | if (mvm->vif_count == 1) { |
| 714 | ieee80211_iterate_active_interfaces( |
| 715 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 716 | iwl_mvm_power_update_iterator, mvm); |
| 717 | } |
| 718 | |
| 719 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 720 | |
| 721 | out_release: |
| 722 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 723 | mutex_unlock(&mvm->mutex); |
| 724 | } |
| 725 | |
Matti Gottlieb | 88f2fd7 | 2013-07-09 15:25:46 +0300 | [diff] [blame] | 726 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 727 | s8 tx_power) |
| 728 | { |
| 729 | /* FW is in charge of regulatory enforcement */ |
| 730 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { |
| 731 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, |
| 732 | .pwr_restriction = cpu_to_le16(tx_power), |
| 733 | }; |
| 734 | |
| 735 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, |
| 736 | sizeof(reduce_txpwr_cmd), |
| 737 | &reduce_txpwr_cmd); |
| 738 | } |
| 739 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 740 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
| 741 | { |
| 742 | return 0; |
| 743 | } |
| 744 | |
| 745 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, |
| 746 | unsigned int changed_flags, |
| 747 | unsigned int *total_flags, |
| 748 | u64 multicast) |
| 749 | { |
| 750 | *total_flags = 0; |
| 751 | } |
| 752 | |
Emmanuel Grumbach | 51b6b9e | 2013-05-02 15:01:24 +0300 | [diff] [blame] | 753 | static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm, |
| 754 | struct ieee80211_vif *vif) |
| 755 | { |
| 756 | struct iwl_mcast_filter_cmd mcast_filter_cmd = { |
| 757 | .pass_all = 1, |
| 758 | }; |
| 759 | |
| 760 | memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 761 | |
| 762 | return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC, |
| 763 | sizeof(mcast_filter_cmd), |
| 764 | &mcast_filter_cmd); |
| 765 | } |
| 766 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 767 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
| 768 | struct ieee80211_vif *vif, |
| 769 | struct ieee80211_bss_conf *bss_conf, |
| 770 | u32 changes) |
| 771 | { |
| 772 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 773 | int ret; |
| 774 | |
| 775 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 776 | if (ret) |
| 777 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 778 | |
| 779 | if (changes & BSS_CHANGED_ASSOC) { |
| 780 | if (bss_conf->assoc) { |
| 781 | /* add quota for this interface */ |
| 782 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 783 | if (ret) { |
| 784 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 785 | return; |
| 786 | } |
Emmanuel Grumbach | 51b6b9e | 2013-05-02 15:01:24 +0300 | [diff] [blame] | 787 | iwl_mvm_configure_mcast_filter(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 788 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
| 789 | /* remove AP station now that the MAC is unassoc */ |
| 790 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); |
| 791 | if (ret) |
| 792 | IWL_ERR(mvm, "failed to remove AP station\n"); |
| 793 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 794 | /* remove quota for this interface */ |
| 795 | ret = iwl_mvm_update_quotas(mvm, NULL); |
| 796 | if (ret) |
| 797 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 798 | } |
Alexander Bondar | e811ada | 2013-03-10 15:29:44 +0200 | [diff] [blame] | 799 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD)) { |
| 800 | /* Workaround for FW bug, otherwise FW disables device |
| 801 | * power save upon disassociation |
| 802 | */ |
| 803 | ret = iwl_mvm_power_update_mode(mvm, vif); |
| 804 | if (ret) |
| 805 | IWL_ERR(mvm, "failed to update power mode\n"); |
| 806 | } |
Emmanuel Grumbach | 41069b4 | 2013-06-25 21:49:19 +0300 | [diff] [blame] | 807 | iwl_mvm_bt_coex_vif_assoc(mvm, vif); |
Alexander Bondar | 989c650 | 2013-05-16 17:34:17 +0300 | [diff] [blame] | 808 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
Johannes Berg | 210a544 | 2013-01-24 23:48:23 +0100 | [diff] [blame] | 809 | /* |
| 810 | * We received a beacon _after_ association so |
| 811 | * remove the session protection. |
| 812 | */ |
| 813 | iwl_mvm_remove_time_event(mvm, mvmvif, |
| 814 | &mvmvif->time_event_data); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 815 | } else if (changes & BSS_CHANGED_PS) { |
Alexander Bondar | 4bf881f | 2013-05-29 10:19:50 +0300 | [diff] [blame] | 816 | ret = iwl_mvm_power_update_mode(mvm, vif); |
| 817 | if (ret) |
| 818 | IWL_ERR(mvm, "failed to update power mode\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 819 | } |
Matti Gottlieb | 88f2fd7 | 2013-07-09 15:25:46 +0300 | [diff] [blame] | 820 | if (changes & BSS_CHANGED_TXPOWER) { |
| 821 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", |
| 822 | bss_conf->txpower); |
| 823 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); |
| 824 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 828 | { |
| 829 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 830 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 831 | int ret; |
| 832 | |
| 833 | mutex_lock(&mvm->mutex); |
| 834 | |
| 835 | /* Send the beacon template */ |
| 836 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); |
| 837 | if (ret) |
| 838 | goto out_unlock; |
| 839 | |
| 840 | /* Add the mac context */ |
| 841 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 842 | if (ret) |
| 843 | goto out_unlock; |
| 844 | |
| 845 | /* Perform the binding */ |
| 846 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 847 | if (ret) |
| 848 | goto out_remove; |
| 849 | |
| 850 | mvmvif->ap_active = true; |
| 851 | |
| 852 | /* Send the bcast station. At this stage the TBTT and DTIM time events |
| 853 | * are added and applied to the scheduler */ |
| 854 | ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta); |
| 855 | if (ret) |
| 856 | goto out_unbind; |
| 857 | |
| 858 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 859 | if (ret) |
| 860 | goto out_rm_bcast; |
| 861 | |
| 862 | /* Need to update the P2P Device MAC */ |
| 863 | if (vif->p2p && mvm->p2p_device_vif) |
| 864 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); |
| 865 | |
| 866 | mutex_unlock(&mvm->mutex); |
| 867 | return 0; |
| 868 | |
| 869 | out_rm_bcast: |
| 870 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 871 | out_unbind: |
| 872 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 873 | out_remove: |
| 874 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 875 | out_unlock: |
| 876 | mutex_unlock(&mvm->mutex); |
| 877 | return ret; |
| 878 | } |
| 879 | |
| 880 | static void iwl_mvm_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 881 | { |
| 882 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 883 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 884 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 885 | iwl_mvm_prepare_mac_removal(mvm, vif); |
| 886 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 887 | mutex_lock(&mvm->mutex); |
| 888 | |
| 889 | mvmvif->ap_active = false; |
| 890 | |
| 891 | /* Need to update the P2P Device MAC */ |
| 892 | if (vif->p2p && mvm->p2p_device_vif) |
| 893 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); |
| 894 | |
| 895 | iwl_mvm_update_quotas(mvm, NULL); |
| 896 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
| 897 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 898 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 899 | |
| 900 | mutex_unlock(&mvm->mutex); |
| 901 | } |
| 902 | |
| 903 | static void iwl_mvm_bss_info_changed_ap(struct iwl_mvm *mvm, |
| 904 | struct ieee80211_vif *vif, |
| 905 | struct ieee80211_bss_conf *bss_conf, |
| 906 | u32 changes) |
| 907 | { |
| 908 | /* Need to send a new beacon template to the FW */ |
| 909 | if (changes & BSS_CHANGED_BEACON) { |
| 910 | if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) |
| 911 | IWL_WARN(mvm, "Failed updating beacon data\n"); |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, |
| 916 | struct ieee80211_vif *vif, |
| 917 | struct ieee80211_bss_conf *bss_conf, |
| 918 | u32 changes) |
| 919 | { |
| 920 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 921 | |
| 922 | mutex_lock(&mvm->mutex); |
| 923 | |
| 924 | switch (vif->type) { |
| 925 | case NL80211_IFTYPE_STATION: |
| 926 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); |
| 927 | break; |
| 928 | case NL80211_IFTYPE_AP: |
| 929 | iwl_mvm_bss_info_changed_ap(mvm, vif, bss_conf, changes); |
| 930 | break; |
| 931 | default: |
| 932 | /* shouldn't happen */ |
| 933 | WARN_ON_ONCE(1); |
| 934 | } |
| 935 | |
| 936 | mutex_unlock(&mvm->mutex); |
| 937 | } |
| 938 | |
| 939 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, |
| 940 | struct ieee80211_vif *vif, |
| 941 | struct cfg80211_scan_request *req) |
| 942 | { |
| 943 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 944 | int ret; |
| 945 | |
| 946 | if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS) |
| 947 | return -EINVAL; |
| 948 | |
| 949 | mutex_lock(&mvm->mutex); |
| 950 | |
| 951 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) |
| 952 | ret = iwl_mvm_scan_request(mvm, vif, req); |
| 953 | else |
| 954 | ret = -EBUSY; |
| 955 | |
| 956 | mutex_unlock(&mvm->mutex); |
| 957 | |
| 958 | return ret; |
| 959 | } |
| 960 | |
| 961 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, |
| 962 | struct ieee80211_vif *vif) |
| 963 | { |
| 964 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 965 | |
| 966 | mutex_lock(&mvm->mutex); |
| 967 | |
| 968 | iwl_mvm_cancel_scan(mvm); |
| 969 | |
| 970 | mutex_unlock(&mvm->mutex); |
| 971 | } |
| 972 | |
| 973 | static void |
| 974 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, |
| 975 | struct ieee80211_sta *sta, u16 tid, |
| 976 | int num_frames, |
| 977 | enum ieee80211_frame_release_type reason, |
| 978 | bool more_data) |
| 979 | { |
| 980 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 981 | |
| 982 | /* TODO: how do we tell the fw to send frames for a specific TID */ |
| 983 | |
| 984 | /* |
| 985 | * The fw will send EOSP notification when the last frame will be |
| 986 | * transmitted. |
| 987 | */ |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 988 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
| 992 | struct ieee80211_vif *vif, |
| 993 | enum sta_notify_cmd cmd, |
| 994 | struct ieee80211_sta *sta) |
| 995 | { |
| 996 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 997 | struct iwl_mvm_sta *mvmsta = (void *)sta->drv_priv; |
| 998 | |
| 999 | switch (cmd) { |
| 1000 | case STA_NOTIFY_SLEEP: |
Emmanuel Grumbach | e3d4bc8 | 2013-05-07 14:08:24 +0300 | [diff] [blame] | 1001 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1002 | ieee80211_sta_block_awake(hw, sta, true); |
| 1003 | /* |
| 1004 | * The fw updates the STA to be asleep. Tx packets on the Tx |
| 1005 | * queues to this station will not be transmitted. The fw will |
| 1006 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. |
| 1007 | */ |
| 1008 | break; |
| 1009 | case STA_NOTIFY_AWAKE: |
Emmanuel Grumbach | 881acd8 | 2013-03-19 16:16:00 +0200 | [diff] [blame] | 1010 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1011 | break; |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 1012 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1013 | break; |
| 1014 | default: |
| 1015 | break; |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
| 1020 | struct ieee80211_vif *vif, |
| 1021 | struct ieee80211_sta *sta, |
| 1022 | enum ieee80211_sta_state old_state, |
| 1023 | enum ieee80211_sta_state new_state) |
| 1024 | { |
| 1025 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1026 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1027 | int ret; |
| 1028 | |
| 1029 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", |
| 1030 | sta->addr, old_state, new_state); |
| 1031 | |
| 1032 | /* this would be a mac80211 bug ... but don't crash */ |
| 1033 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) |
| 1034 | return -EINVAL; |
| 1035 | |
| 1036 | /* if a STA is being removed, reuse its ID */ |
| 1037 | flush_work(&mvm->sta_drained_wk); |
| 1038 | |
| 1039 | mutex_lock(&mvm->mutex); |
| 1040 | if (old_state == IEEE80211_STA_NOTEXIST && |
| 1041 | new_state == IEEE80211_STA_NONE) { |
| 1042 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
| 1043 | } else if (old_state == IEEE80211_STA_NONE && |
| 1044 | new_state == IEEE80211_STA_AUTH) { |
| 1045 | ret = 0; |
| 1046 | } else if (old_state == IEEE80211_STA_AUTH && |
| 1047 | new_state == IEEE80211_STA_ASSOC) { |
Johannes Berg | 7a45397 | 2013-02-12 13:10:44 +0100 | [diff] [blame] | 1048 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
| 1049 | if (ret == 0) |
| 1050 | iwl_mvm_rs_rate_init(mvm, sta, |
| 1051 | mvmvif->phy_ctxt->channel->band); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1052 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 1053 | new_state == IEEE80211_STA_AUTHORIZED) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1054 | /* enable beacon filtering */ |
| 1055 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1056 | ret = 0; |
| 1057 | } else if (old_state == IEEE80211_STA_AUTHORIZED && |
| 1058 | new_state == IEEE80211_STA_ASSOC) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1059 | /* disable beacon filtering */ |
| 1060 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1061 | ret = 0; |
| 1062 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 1063 | new_state == IEEE80211_STA_AUTH) { |
| 1064 | ret = 0; |
| 1065 | } else if (old_state == IEEE80211_STA_AUTH && |
| 1066 | new_state == IEEE80211_STA_NONE) { |
| 1067 | ret = 0; |
| 1068 | } else if (old_state == IEEE80211_STA_NONE && |
| 1069 | new_state == IEEE80211_STA_NOTEXIST) { |
| 1070 | ret = iwl_mvm_rm_sta(mvm, vif, sta); |
| 1071 | } else { |
| 1072 | ret = -EIO; |
| 1073 | } |
| 1074 | mutex_unlock(&mvm->mutex); |
| 1075 | |
| 1076 | return ret; |
| 1077 | } |
| 1078 | |
| 1079 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
| 1080 | { |
| 1081 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1082 | |
| 1083 | mvm->rts_threshold = value; |
| 1084 | |
| 1085 | return 0; |
| 1086 | } |
| 1087 | |
| 1088 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
| 1089 | struct ieee80211_vif *vif, u16 ac, |
| 1090 | const struct ieee80211_tx_queue_params *params) |
| 1091 | { |
| 1092 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1093 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1094 | |
| 1095 | mvmvif->queue_params[ac] = *params; |
| 1096 | |
| 1097 | /* |
| 1098 | * No need to update right away, we'll get BSS_CHANGED_QOS |
| 1099 | * The exception is P2P_DEVICE interface which needs immediate update. |
| 1100 | */ |
| 1101 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1102 | int ret; |
| 1103 | |
| 1104 | mutex_lock(&mvm->mutex); |
| 1105 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
| 1106 | mutex_unlock(&mvm->mutex); |
| 1107 | return ret; |
| 1108 | } |
| 1109 | return 0; |
| 1110 | } |
| 1111 | |
| 1112 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, |
| 1113 | struct ieee80211_vif *vif) |
| 1114 | { |
| 1115 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1116 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, |
| 1117 | 200 + vif->bss_conf.beacon_int); |
| 1118 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, |
| 1119 | 100 + vif->bss_conf.beacon_int); |
| 1120 | |
| 1121 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) |
| 1122 | return; |
| 1123 | |
| 1124 | mutex_lock(&mvm->mutex); |
| 1125 | /* Try really hard to protect the session and hear a beacon */ |
| 1126 | iwl_mvm_protect_session(mvm, vif, duration, min_duration); |
| 1127 | mutex_unlock(&mvm->mutex); |
| 1128 | } |
| 1129 | |
| 1130 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
| 1131 | enum set_key_cmd cmd, |
| 1132 | struct ieee80211_vif *vif, |
| 1133 | struct ieee80211_sta *sta, |
| 1134 | struct ieee80211_key_conf *key) |
| 1135 | { |
| 1136 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1137 | int ret; |
| 1138 | |
| 1139 | if (iwlwifi_mod_params.sw_crypto) { |
| 1140 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); |
| 1141 | return -EOPNOTSUPP; |
| 1142 | } |
| 1143 | |
| 1144 | switch (key->cipher) { |
| 1145 | case WLAN_CIPHER_SUITE_TKIP: |
| 1146 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
| 1147 | /* fall-through */ |
| 1148 | case WLAN_CIPHER_SUITE_CCMP: |
| 1149 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
| 1150 | break; |
| 1151 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 1152 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); |
| 1153 | break; |
| 1154 | case WLAN_CIPHER_SUITE_WEP40: |
| 1155 | case WLAN_CIPHER_SUITE_WEP104: |
| 1156 | /* |
| 1157 | * Support for TX only, at least for now, so accept |
| 1158 | * the key and do nothing else. Then mac80211 will |
| 1159 | * pass it for TX but we don't have to use it for RX. |
| 1160 | */ |
| 1161 | return 0; |
| 1162 | default: |
| 1163 | return -EOPNOTSUPP; |
| 1164 | } |
| 1165 | |
| 1166 | mutex_lock(&mvm->mutex); |
| 1167 | |
| 1168 | switch (cmd) { |
| 1169 | case SET_KEY: |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1170 | if (vif->type == NL80211_IFTYPE_AP && !sta) { |
| 1171 | /* GTK on AP interface is a TX-only key, return 0 */ |
| 1172 | ret = 0; |
| 1173 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
| 1174 | break; |
| 1175 | } |
| 1176 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1177 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
| 1178 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); |
| 1179 | if (ret) { |
| 1180 | IWL_WARN(mvm, "set key failed\n"); |
| 1181 | /* |
| 1182 | * can't add key for RX, but we don't need it |
| 1183 | * in the device for TX so still return 0 |
| 1184 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1185 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1186 | ret = 0; |
| 1187 | } |
| 1188 | |
| 1189 | break; |
| 1190 | case DISABLE_KEY: |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 1191 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
| 1192 | ret = 0; |
| 1193 | break; |
| 1194 | } |
| 1195 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1196 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
| 1197 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); |
| 1198 | break; |
| 1199 | default: |
| 1200 | ret = -EINVAL; |
| 1201 | } |
| 1202 | |
| 1203 | mutex_unlock(&mvm->mutex); |
| 1204 | return ret; |
| 1205 | } |
| 1206 | |
| 1207 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 1208 | struct ieee80211_vif *vif, |
| 1209 | struct ieee80211_key_conf *keyconf, |
| 1210 | struct ieee80211_sta *sta, |
| 1211 | u32 iv32, u16 *phase1key) |
| 1212 | { |
| 1213 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1214 | |
| 1215 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
| 1216 | } |
| 1217 | |
| 1218 | |
| 1219 | static int iwl_mvm_roc(struct ieee80211_hw *hw, |
| 1220 | struct ieee80211_vif *vif, |
| 1221 | struct ieee80211_channel *channel, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 1222 | int duration, |
| 1223 | enum ieee80211_roc_type type) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1224 | { |
| 1225 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1226 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1227 | struct cfg80211_chan_def chandef; |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1228 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
| 1229 | int ret, i; |
| 1230 | |
| 1231 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, |
| 1232 | duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1233 | |
| 1234 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) { |
| 1235 | IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type); |
| 1236 | return -EINVAL; |
| 1237 | } |
| 1238 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1239 | mutex_lock(&mvm->mutex); |
| 1240 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1241 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 1242 | phy_ctxt = &mvm->phy_ctxts[i]; |
| 1243 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) |
| 1244 | continue; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1245 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1246 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { |
| 1247 | /* |
| 1248 | * Unbind the P2P_DEVICE from the current PHY context, |
| 1249 | * and if the PHY context is not used remove it. |
| 1250 | */ |
| 1251 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 1252 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 1253 | goto out_unlock; |
| 1254 | |
| 1255 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 1256 | |
| 1257 | /* Bind the P2P_DEVICE to the current PHY Context */ |
| 1258 | mvmvif->phy_ctxt = phy_ctxt; |
| 1259 | |
| 1260 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1261 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 1262 | goto out_unlock; |
| 1263 | |
| 1264 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 1265 | goto schedule_time_event; |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | /* Need to update the PHY context only if the ROC channel changed */ |
| 1270 | if (channel == mvmvif->phy_ctxt->channel) |
| 1271 | goto schedule_time_event; |
| 1272 | |
| 1273 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
| 1274 | |
| 1275 | /* |
| 1276 | * Change the PHY context configuration as it is currently referenced |
| 1277 | * only by the P2P Device MAC |
| 1278 | */ |
| 1279 | if (mvmvif->phy_ctxt->ref == 1) { |
| 1280 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, |
| 1281 | &chandef, 1, 1); |
| 1282 | if (ret) |
| 1283 | goto out_unlock; |
| 1284 | } else { |
| 1285 | /* |
| 1286 | * The PHY context is shared with other MACs. Need to remove the |
| 1287 | * P2P Device from the binding, allocate an new PHY context and |
| 1288 | * create a new binding |
| 1289 | */ |
| 1290 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1291 | if (!phy_ctxt) { |
| 1292 | ret = -ENOSPC; |
| 1293 | goto out_unlock; |
| 1294 | } |
| 1295 | |
| 1296 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, |
| 1297 | 1, 1); |
| 1298 | if (ret) { |
| 1299 | IWL_ERR(mvm, "Failed to change PHY context\n"); |
| 1300 | goto out_unlock; |
| 1301 | } |
| 1302 | |
| 1303 | /* Unbind the P2P_DEVICE from the current PHY context */ |
| 1304 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 1305 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 1306 | goto out_unlock; |
| 1307 | |
| 1308 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 1309 | |
| 1310 | /* Bind the P2P_DEVICE to the new allocated PHY context */ |
| 1311 | mvmvif->phy_ctxt = phy_ctxt; |
| 1312 | |
| 1313 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1314 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 1315 | goto out_unlock; |
| 1316 | |
| 1317 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 1318 | } |
| 1319 | |
| 1320 | schedule_time_event: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1321 | /* Schedule the time events */ |
Ilan Peer | e635c79 | 2013-02-13 11:05:18 +0200 | [diff] [blame] | 1322 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1323 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1324 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1325 | mutex_unlock(&mvm->mutex); |
| 1326 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1327 | return ret; |
| 1328 | } |
| 1329 | |
| 1330 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) |
| 1331 | { |
| 1332 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1333 | |
| 1334 | IWL_DEBUG_MAC80211(mvm, "enter\n"); |
| 1335 | |
| 1336 | mutex_lock(&mvm->mutex); |
| 1337 | iwl_mvm_stop_p2p_roc(mvm); |
| 1338 | mutex_unlock(&mvm->mutex); |
| 1339 | |
| 1340 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
| 1341 | return 0; |
| 1342 | } |
| 1343 | |
| 1344 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, |
| 1345 | struct ieee80211_chanctx_conf *ctx) |
| 1346 | { |
| 1347 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1348 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1349 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1350 | int ret; |
| 1351 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1352 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1353 | |
| 1354 | mutex_lock(&mvm->mutex); |
| 1355 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1356 | if (!phy_ctxt) { |
| 1357 | ret = -ENOSPC; |
| 1358 | goto out; |
| 1359 | } |
| 1360 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1361 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
| 1362 | ctx->rx_chains_static, |
| 1363 | ctx->rx_chains_dynamic); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1364 | if (ret) { |
| 1365 | IWL_ERR(mvm, "Failed to add PHY context\n"); |
| 1366 | goto out; |
| 1367 | } |
| 1368 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1369 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1370 | *phy_ctxt_id = phy_ctxt->id; |
| 1371 | out: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1372 | mutex_unlock(&mvm->mutex); |
| 1373 | return ret; |
| 1374 | } |
| 1375 | |
| 1376 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
| 1377 | struct ieee80211_chanctx_conf *ctx) |
| 1378 | { |
| 1379 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1380 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1381 | 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] | 1382 | |
| 1383 | mutex_lock(&mvm->mutex); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1384 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1385 | mutex_unlock(&mvm->mutex); |
| 1386 | } |
| 1387 | |
| 1388 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, |
| 1389 | struct ieee80211_chanctx_conf *ctx, |
| 1390 | u32 changed) |
| 1391 | { |
| 1392 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1393 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1394 | 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] | 1395 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 1396 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
| 1397 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | |
| 1398 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | |
| 1399 | IEEE80211_CHANCTX_CHANGE_RADAR)), |
| 1400 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
| 1401 | phy_ctxt->ref, changed)) |
| 1402 | return; |
| 1403 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1404 | mutex_lock(&mvm->mutex); |
| 1405 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
| 1406 | ctx->rx_chains_static, |
| 1407 | ctx->rx_chains_dynamic); |
| 1408 | mutex_unlock(&mvm->mutex); |
| 1409 | } |
| 1410 | |
| 1411 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 1412 | struct ieee80211_vif *vif, |
| 1413 | struct ieee80211_chanctx_conf *ctx) |
| 1414 | { |
| 1415 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1416 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 1417 | 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] | 1418 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1419 | int ret; |
| 1420 | |
| 1421 | mutex_lock(&mvm->mutex); |
| 1422 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1423 | mvmvif->phy_ctxt = phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1424 | |
| 1425 | switch (vif->type) { |
| 1426 | case NL80211_IFTYPE_AP: |
| 1427 | /* |
| 1428 | * The AP binding flow is handled as part of the start_ap flow |
| 1429 | * (in bss_info_changed). |
| 1430 | */ |
| 1431 | ret = 0; |
| 1432 | goto out_unlock; |
| 1433 | case NL80211_IFTYPE_STATION: |
| 1434 | case NL80211_IFTYPE_ADHOC: |
| 1435 | case NL80211_IFTYPE_MONITOR: |
| 1436 | break; |
| 1437 | default: |
| 1438 | ret = -EINVAL; |
| 1439 | goto out_unlock; |
| 1440 | } |
| 1441 | |
| 1442 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1443 | if (ret) |
| 1444 | goto out_unlock; |
| 1445 | |
| 1446 | /* |
| 1447 | * Setting the quota at this stage is only required for monitor |
| 1448 | * interfaces. For the other types, the bss_info changed flow |
| 1449 | * will handle quota settings. |
| 1450 | */ |
| 1451 | if (vif->type == NL80211_IFTYPE_MONITOR) { |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1452 | mvmvif->monitor_active = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1453 | ret = iwl_mvm_update_quotas(mvm, vif); |
| 1454 | if (ret) |
| 1455 | goto out_remove_binding; |
| 1456 | } |
| 1457 | |
| 1458 | goto out_unlock; |
| 1459 | |
| 1460 | out_remove_binding: |
| 1461 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 1462 | out_unlock: |
| 1463 | mutex_unlock(&mvm->mutex); |
| 1464 | if (ret) |
| 1465 | mvmvif->phy_ctxt = NULL; |
| 1466 | return ret; |
| 1467 | } |
| 1468 | |
| 1469 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 1470 | struct ieee80211_vif *vif, |
| 1471 | struct ieee80211_chanctx_conf *ctx) |
| 1472 | { |
| 1473 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1474 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1475 | |
| 1476 | mutex_lock(&mvm->mutex); |
| 1477 | |
| 1478 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); |
| 1479 | |
| 1480 | if (vif->type == NL80211_IFTYPE_AP) |
| 1481 | goto out_unlock; |
| 1482 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1483 | switch (vif->type) { |
| 1484 | case NL80211_IFTYPE_MONITOR: |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1485 | mvmvif->monitor_active = false; |
| 1486 | iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1487 | break; |
| 1488 | default: |
| 1489 | break; |
| 1490 | } |
| 1491 | |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 1492 | iwl_mvm_binding_remove_vif(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1493 | out_unlock: |
| 1494 | mvmvif->phy_ctxt = NULL; |
| 1495 | mutex_unlock(&mvm->mutex); |
| 1496 | } |
| 1497 | |
| 1498 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, |
| 1499 | struct ieee80211_sta *sta, |
| 1500 | bool set) |
| 1501 | { |
| 1502 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1503 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; |
| 1504 | |
| 1505 | if (!mvm_sta || !mvm_sta->vif) { |
| 1506 | IWL_ERR(mvm, "Station is not associated to a vif\n"); |
| 1507 | return -EINVAL; |
| 1508 | } |
| 1509 | |
| 1510 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); |
| 1511 | } |
| 1512 | |
Emmanuel Grumbach | 2b76ef1 | 2013-01-24 10:35:13 +0200 | [diff] [blame] | 1513 | static void iwl_mvm_mac_rssi_callback(struct ieee80211_hw *hw, |
| 1514 | struct ieee80211_vif *vif, |
| 1515 | enum ieee80211_rssi_event rssi_event) |
| 1516 | { |
| 1517 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1518 | |
| 1519 | iwl_mvm_bt_rssi_event(mvm, vif, rssi_event); |
| 1520 | } |
| 1521 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1522 | struct ieee80211_ops iwl_mvm_hw_ops = { |
| 1523 | .tx = iwl_mvm_mac_tx, |
| 1524 | .ampdu_action = iwl_mvm_mac_ampdu_action, |
| 1525 | .start = iwl_mvm_mac_start, |
| 1526 | .restart_complete = iwl_mvm_mac_restart_complete, |
| 1527 | .stop = iwl_mvm_mac_stop, |
| 1528 | .add_interface = iwl_mvm_mac_add_interface, |
| 1529 | .remove_interface = iwl_mvm_mac_remove_interface, |
| 1530 | .config = iwl_mvm_mac_config, |
| 1531 | .configure_filter = iwl_mvm_configure_filter, |
| 1532 | .bss_info_changed = iwl_mvm_bss_info_changed, |
| 1533 | .hw_scan = iwl_mvm_mac_hw_scan, |
| 1534 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, |
| 1535 | .sta_state = iwl_mvm_mac_sta_state, |
| 1536 | .sta_notify = iwl_mvm_mac_sta_notify, |
| 1537 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, |
| 1538 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
| 1539 | .conf_tx = iwl_mvm_mac_conf_tx, |
| 1540 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, |
| 1541 | .set_key = iwl_mvm_mac_set_key, |
| 1542 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, |
| 1543 | .remain_on_channel = iwl_mvm_roc, |
| 1544 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, |
Emmanuel Grumbach | 2b76ef1 | 2013-01-24 10:35:13 +0200 | [diff] [blame] | 1545 | .rssi_callback = iwl_mvm_mac_rssi_callback, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1546 | |
| 1547 | .add_chanctx = iwl_mvm_add_chanctx, |
| 1548 | .remove_chanctx = iwl_mvm_remove_chanctx, |
| 1549 | .change_chanctx = iwl_mvm_change_chanctx, |
| 1550 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, |
| 1551 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, |
| 1552 | |
| 1553 | .start_ap = iwl_mvm_start_ap, |
| 1554 | .stop_ap = iwl_mvm_stop_ap, |
| 1555 | |
| 1556 | .set_tim = iwl_mvm_set_tim, |
| 1557 | |
| 1558 | #ifdef CONFIG_PM_SLEEP |
| 1559 | /* look at d3.c */ |
| 1560 | .suspend = iwl_mvm_suspend, |
| 1561 | .resume = iwl_mvm_resume, |
| 1562 | .set_wakeup = iwl_mvm_set_wakeup, |
| 1563 | .set_rekey_data = iwl_mvm_set_rekey_data, |
| 1564 | #if IS_ENABLED(CONFIG_IPV6) |
| 1565 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, |
| 1566 | #endif |
| 1567 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, |
| 1568 | #endif |
| 1569 | }; |