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 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Johannes Berg | 8b4139d | 2014-07-24 14:05:26 +0200 | [diff] [blame] | 9 | * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of version 2 of the GNU General Public License as |
| 13 | * published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 23 | * USA |
| 24 | * |
| 25 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 26 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 27 | * |
| 28 | * Contact Information: |
| 29 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 30 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 31 | * |
| 32 | * BSD LICENSE |
| 33 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 34 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Johannes Berg | 8b4139d | 2014-07-24 14:05:26 +0200 | [diff] [blame] | 35 | * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 36 | * All rights reserved. |
| 37 | * |
| 38 | * Redistribution and use in source and binary forms, with or without |
| 39 | * modification, are permitted provided that the following conditions |
| 40 | * are met: |
| 41 | * |
| 42 | * * Redistributions of source code must retain the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer. |
| 44 | * * Redistributions in binary form must reproduce the above copyright |
| 45 | * notice, this list of conditions and the following disclaimer in |
| 46 | * the documentation and/or other materials provided with the |
| 47 | * distribution. |
| 48 | * * Neither the name Intel Corporation nor the names of its |
| 49 | * contributors may be used to endorse or promote products derived |
| 50 | * from this software without specific prior written permission. |
| 51 | * |
| 52 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 53 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 54 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 55 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 56 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 57 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 58 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 59 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 60 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 61 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 62 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 63 | * |
| 64 | *****************************************************************************/ |
| 65 | #include <linux/kernel.h> |
| 66 | #include <linux/slab.h> |
| 67 | #include <linux/skbuff.h> |
| 68 | #include <linux/netdevice.h> |
| 69 | #include <linux/etherdevice.h> |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 70 | #include <linux/ip.h> |
Eliad Peller | 2ee8f02 | 2014-01-13 19:07:09 +0200 | [diff] [blame] | 71 | #include <linux/if_arp.h> |
Johannes Berg | aadede6 | 2014-10-09 17:01:36 +0200 | [diff] [blame] | 72 | #include <linux/devcoredump.h> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 73 | #include <net/mac80211.h> |
Emmanuel Grumbach | 7b1dd04 | 2014-02-04 15:32:43 +0200 | [diff] [blame] | 74 | #include <net/ieee80211_radiotap.h> |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 75 | #include <net/tcp.h> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 76 | |
| 77 | #include "iwl-op-mode.h" |
| 78 | #include "iwl-io.h" |
| 79 | #include "mvm.h" |
| 80 | #include "sta.h" |
| 81 | #include "time-event.h" |
| 82 | #include "iwl-eeprom-parse.h" |
| 83 | #include "fw-api-scan.h" |
| 84 | #include "iwl-phy-db.h" |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 85 | #include "testmode.h" |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 86 | #include "iwl-fw-error-dump.h" |
| 87 | #include "iwl-prph.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 88 | |
| 89 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { |
| 90 | { |
| 91 | .max = 1, |
Ilan Peer | 8eb3871 | 2013-06-01 20:17:18 +0300 | [diff] [blame] | 92 | .types = BIT(NL80211_IFTYPE_STATION), |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 93 | }, |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 94 | { |
| 95 | .max = 1, |
Ilan Peer | 8eb3871 | 2013-06-01 20:17:18 +0300 | [diff] [blame] | 96 | .types = BIT(NL80211_IFTYPE_AP) | |
| 97 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 98 | BIT(NL80211_IFTYPE_P2P_GO), |
| 99 | }, |
| 100 | { |
| 101 | .max = 1, |
| 102 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), |
| 103 | }, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { |
| 107 | { |
| 108 | .num_different_channels = 1, |
| 109 | .max_interfaces = 3, |
| 110 | .limits = iwl_mvm_limits, |
| 111 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), |
| 112 | }, |
| 113 | }; |
| 114 | |
Johannes Berg | f0c2646 | 2013-01-22 20:41:58 +0100 | [diff] [blame] | 115 | #ifdef CONFIG_PM_SLEEP |
| 116 | static const struct nl80211_wowlan_tcp_data_token_feature |
| 117 | iwl_mvm_wowlan_tcp_token_feature = { |
| 118 | .min_len = 0, |
| 119 | .max_len = 255, |
| 120 | .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS, |
| 121 | }; |
| 122 | |
| 123 | static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = { |
| 124 | .tok = &iwl_mvm_wowlan_tcp_token_feature, |
| 125 | .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN - |
| 126 | sizeof(struct ethhdr) - |
| 127 | sizeof(struct iphdr) - |
| 128 | sizeof(struct tcphdr), |
| 129 | .data_interval_max = 65535, /* __le16 in API */ |
| 130 | .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN - |
| 131 | sizeof(struct ethhdr) - |
| 132 | sizeof(struct iphdr) - |
| 133 | sizeof(struct tcphdr), |
| 134 | .seq = true, |
| 135 | }; |
| 136 | #endif |
| 137 | |
Eliad Peller | 7773692 | 2014-01-14 12:35:49 +0200 | [diff] [blame] | 138 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
Eliad Peller | 2ee8f02 | 2014-01-13 19:07:09 +0200 | [diff] [blame] | 139 | /* |
| 140 | * Use the reserved field to indicate magic values. |
| 141 | * these values will only be used internally by the driver, |
| 142 | * and won't make it to the fw (reserved will be 0). |
| 143 | * BC_FILTER_MAGIC_IP - configure the val of this attribute to |
| 144 | * be the vif's ip address. in case there is not a single |
| 145 | * ip address (0, or more than 1), this attribute will |
| 146 | * be skipped. |
| 147 | * BC_FILTER_MAGIC_MAC - set the val of this attribute to |
| 148 | * the LSB bytes of the vif's mac address |
| 149 | */ |
| 150 | enum { |
| 151 | BC_FILTER_MAGIC_NONE = 0, |
| 152 | BC_FILTER_MAGIC_IP, |
| 153 | BC_FILTER_MAGIC_MAC, |
| 154 | }; |
| 155 | |
Eliad Peller | 7773692 | 2014-01-14 12:35:49 +0200 | [diff] [blame] | 156 | static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters[] = { |
| 157 | { |
| 158 | /* arp */ |
| 159 | .discard = 0, |
| 160 | .frame_type = BCAST_FILTER_FRAME_TYPE_ALL, |
| 161 | .attrs = { |
| 162 | { |
| 163 | /* frame type - arp, hw type - ethernet */ |
| 164 | .offset_type = |
| 165 | BCAST_FILTER_OFFSET_PAYLOAD_START, |
| 166 | .offset = sizeof(rfc1042_header), |
| 167 | .val = cpu_to_be32(0x08060001), |
| 168 | .mask = cpu_to_be32(0xffffffff), |
| 169 | }, |
Eliad Peller | 2ee8f02 | 2014-01-13 19:07:09 +0200 | [diff] [blame] | 170 | { |
| 171 | /* arp dest ip */ |
| 172 | .offset_type = |
| 173 | BCAST_FILTER_OFFSET_PAYLOAD_START, |
| 174 | .offset = sizeof(rfc1042_header) + 2 + |
| 175 | sizeof(struct arphdr) + |
| 176 | ETH_ALEN + sizeof(__be32) + |
| 177 | ETH_ALEN, |
| 178 | .mask = cpu_to_be32(0xffffffff), |
| 179 | /* mark it as special field */ |
| 180 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_IP), |
| 181 | }, |
| 182 | }, |
| 183 | }, |
| 184 | { |
| 185 | /* dhcp offer bcast */ |
| 186 | .discard = 0, |
| 187 | .frame_type = BCAST_FILTER_FRAME_TYPE_IPV4, |
| 188 | .attrs = { |
| 189 | { |
| 190 | /* udp dest port - 68 (bootp client)*/ |
| 191 | .offset_type = BCAST_FILTER_OFFSET_IP_END, |
| 192 | .offset = offsetof(struct udphdr, dest), |
| 193 | .val = cpu_to_be32(0x00440000), |
| 194 | .mask = cpu_to_be32(0xffff0000), |
| 195 | }, |
| 196 | { |
| 197 | /* dhcp - lsb bytes of client hw address */ |
| 198 | .offset_type = BCAST_FILTER_OFFSET_IP_END, |
| 199 | .offset = 38, |
| 200 | .mask = cpu_to_be32(0xffffffff), |
| 201 | /* mark it as special field */ |
| 202 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_MAC), |
| 203 | }, |
Eliad Peller | 7773692 | 2014-01-14 12:35:49 +0200 | [diff] [blame] | 204 | }, |
| 205 | }, |
| 206 | /* last filter must be empty */ |
| 207 | {}, |
| 208 | }; |
| 209 | #endif |
| 210 | |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 211 | void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
| 212 | { |
Eliad Peller | 7bb426e | 2014-02-24 12:54:37 +0200 | [diff] [blame] | 213 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 214 | return; |
| 215 | |
| 216 | IWL_DEBUG_RPM(mvm, "Take mvm reference - type %d\n", ref_type); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 217 | spin_lock_bh(&mvm->refs_lock); |
| 218 | mvm->refs[ref_type]++; |
| 219 | spin_unlock_bh(&mvm->refs_lock); |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 220 | iwl_trans_ref(mvm->trans); |
| 221 | } |
| 222 | |
| 223 | void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
| 224 | { |
Eliad Peller | 7bb426e | 2014-02-24 12:54:37 +0200 | [diff] [blame] | 225 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 226 | return; |
| 227 | |
| 228 | IWL_DEBUG_RPM(mvm, "Leave mvm reference - type %d\n", ref_type); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 229 | spin_lock_bh(&mvm->refs_lock); |
| 230 | WARN_ON(!mvm->refs[ref_type]--); |
| 231 | spin_unlock_bh(&mvm->refs_lock); |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 232 | iwl_trans_unref(mvm->trans); |
| 233 | } |
| 234 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 235 | static void iwl_mvm_unref_all_except(struct iwl_mvm *mvm, |
| 236 | enum iwl_mvm_ref_type except_ref) |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 237 | { |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 238 | int i, j; |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 239 | |
Eliad Peller | 7bb426e | 2014-02-24 12:54:37 +0200 | [diff] [blame] | 240 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 241 | return; |
| 242 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 243 | spin_lock_bh(&mvm->refs_lock); |
| 244 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) { |
| 245 | if (except_ref == i || !mvm->refs[i]) |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 246 | continue; |
| 247 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 248 | IWL_DEBUG_RPM(mvm, "Cleanup: remove mvm ref type %d (%d)\n", |
| 249 | i, mvm->refs[i]); |
| 250 | for (j = 0; j < mvm->refs[i]; j++) |
| 251 | iwl_trans_unref(mvm->trans); |
| 252 | mvm->refs[i] = 0; |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 253 | } |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 254 | spin_unlock_bh(&mvm->refs_lock); |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 255 | } |
| 256 | |
Eliad Peller | f4cf868 | 2014-11-04 16:57:06 +0200 | [diff] [blame] | 257 | bool iwl_mvm_ref_taken(struct iwl_mvm *mvm) |
| 258 | { |
| 259 | int i; |
| 260 | bool taken = false; |
| 261 | |
| 262 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
| 263 | return true; |
| 264 | |
| 265 | spin_lock_bh(&mvm->refs_lock); |
| 266 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) { |
| 267 | if (mvm->refs[i]) { |
| 268 | taken = true; |
| 269 | break; |
| 270 | } |
| 271 | } |
| 272 | spin_unlock_bh(&mvm->refs_lock); |
| 273 | |
| 274 | return taken; |
| 275 | } |
| 276 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 277 | int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
Gregory Greenman | d40fc48 | 2014-06-25 14:08:50 +0200 | [diff] [blame] | 278 | { |
| 279 | iwl_mvm_ref(mvm, ref_type); |
| 280 | |
| 281 | if (!wait_event_timeout(mvm->d0i3_exit_waitq, |
| 282 | !test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status), |
| 283 | HZ)) { |
| 284 | WARN_ON_ONCE(1); |
| 285 | iwl_mvm_unref(mvm, ref_type); |
| 286 | return -EIO; |
| 287 | } |
| 288 | |
| 289 | return 0; |
| 290 | } |
| 291 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 292 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
| 293 | { |
| 294 | int i; |
| 295 | |
| 296 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); |
| 297 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 298 | mvm->phy_ctxts[i].id = i; |
| 299 | mvm->phy_ctxts[i].ref = 0; |
| 300 | } |
| 301 | } |
| 302 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 303 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
| 304 | { |
| 305 | struct ieee80211_hw *hw = mvm->hw; |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 306 | int num_mac, ret, i; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 307 | |
| 308 | /* Tell mac80211 our characteristics */ |
| 309 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
| 310 | IEEE80211_HW_SPECTRUM_MGMT | |
| 311 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
| 312 | IEEE80211_HW_QUEUE_CONTROL | |
| 313 | IEEE80211_HW_WANT_MONITOR_VIF | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 314 | IEEE80211_HW_SUPPORTS_PS | |
| 315 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | |
Johannes Berg | d2931bb | 2013-02-05 18:10:04 +0100 | [diff] [blame] | 316 | IEEE80211_HW_AMPDU_AGGREGATION | |
Hila Gonen | d64048e | 2013-03-13 18:00:03 +0200 | [diff] [blame] | 317 | IEEE80211_HW_TIMING_BEACON_ONLY | |
Emmanuel Grumbach | 147fc9b | 2013-07-28 11:00:52 +0300 | [diff] [blame] | 318 | IEEE80211_HW_CONNECTION_MONITOR | |
Ido Yariv | b71d9c8 | 2014-07-23 09:31:14 -0400 | [diff] [blame] | 319 | IEEE80211_HW_CHANCTX_STA_CSA | |
| 320 | IEEE80211_HW_SUPPORTS_CLONED_SKBS; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 321 | |
Eytan Lifshitz | 19e737c | 2013-09-09 13:30:15 +0200 | [diff] [blame] | 322 | hw->queues = mvm->first_agg_queue; |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 323 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
Emmanuel Grumbach | 7b1dd04 | 2014-02-04 15:32:43 +0200 | [diff] [blame] | 324 | hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC | |
| 325 | IEEE80211_RADIOTAP_MCS_HAVE_STBC; |
| 326 | hw->radiotap_vht_details |= IEEE80211_RADIOTAP_VHT_KNOWN_STBC; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 327 | hw->rate_control_algorithm = "iwl-mvm-rs"; |
| 328 | |
| 329 | /* |
| 330 | * Enable 11w if advertised by firmware and software crypto |
| 331 | * is not enabled (as the firmware will interpret some mgmt |
| 332 | * packets, so enabling it with software crypto isn't safe) |
| 333 | */ |
| 334 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && |
| 335 | !iwlwifi_mod_params.sw_crypto) |
| 336 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; |
| 337 | |
Matt Chen | 1504f48 | 2014-04-24 18:43:18 +0800 | [diff] [blame] | 338 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT && |
| 339 | IWL_UCODE_API(mvm->fw->ucode_ver) >= 9 && |
| 340 | !iwlwifi_mod_params.uapsd_disable) { |
| 341 | hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD; |
Eliad Peller | 4cb832d | 2014-08-06 10:52:27 +0300 | [diff] [blame] | 342 | hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES; |
Matt Chen | 1504f48 | 2014-04-24 18:43:18 +0800 | [diff] [blame] | 343 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; |
| 344 | } |
Alexander Bondar | e8e626a | 2013-10-16 00:21:34 +0200 | [diff] [blame] | 345 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 346 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) |
| 347 | hw->flags |= IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS; |
| 348 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 349 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
| 350 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 351 | hw->chanctx_data_size = sizeof(u16); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 352 | |
| 353 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
Johannes Berg | 3c15a0f | 2013-05-31 10:17:19 +0200 | [diff] [blame] | 354 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 355 | BIT(NL80211_IFTYPE_AP) | |
| 356 | BIT(NL80211_IFTYPE_P2P_GO) | |
Emmanuel Grumbach | c13b172 | 2014-03-27 19:12:12 +0200 | [diff] [blame] | 357 | BIT(NL80211_IFTYPE_P2P_DEVICE) | |
| 358 | BIT(NL80211_IFTYPE_ADHOC); |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 359 | |
Luis R. Rodriguez | a2f73b6 | 2013-11-11 22:15:29 +0100 | [diff] [blame] | 360 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
| 361 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | |
| 362 | REGULATORY_DISABLE_BEACON_HINTS; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 363 | |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 364 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD) |
| 365 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; |
| 366 | |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 367 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_CSA_FLOW) |
| 368 | hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
| 369 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 370 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
| 371 | hw->wiphy->n_iface_combinations = |
| 372 | ARRAY_SIZE(iwl_mvm_iface_combinations); |
| 373 | |
Ilan Peer | c451e6d | 2013-02-20 08:41:54 +0200 | [diff] [blame] | 374 | hw->wiphy->max_remain_on_channel_duration = 10000; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 375 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
| 376 | |
| 377 | /* Extract MAC address */ |
| 378 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); |
| 379 | hw->wiphy->addresses = mvm->addresses; |
| 380 | hw->wiphy->n_addresses = 1; |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 381 | |
| 382 | /* Extract additional MAC addresses if available */ |
| 383 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? |
| 384 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; |
| 385 | |
| 386 | for (i = 1; i < num_mac; i++) { |
| 387 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 388 | ETH_ALEN); |
Ilan Peer | 831e85f | 2013-02-07 17:09:09 +0200 | [diff] [blame] | 389 | mvm->addresses[i].addr[5]++; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 390 | hw->wiphy->n_addresses++; |
| 391 | } |
| 392 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 393 | iwl_mvm_reset_phy_ctxts(mvm); |
| 394 | |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 395 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm, false); |
David Spinadel | 20f1a5d | 2013-08-21 09:14:27 +0300 | [diff] [blame] | 396 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 397 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
| 398 | |
| 399 | if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels) |
| 400 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 401 | &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; |
| 402 | if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels) |
| 403 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 404 | &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; |
| 405 | |
| 406 | hw->wiphy->hw_version = mvm->trans->hw_id; |
| 407 | |
Alexander Bondar | ade5065 | 2013-04-03 16:28:47 +0300 | [diff] [blame] | 408 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 409 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 410 | else |
| 411 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 412 | |
Emmanuel Grumbach | 6efaaf3 | 2014-09-01 10:03:21 +0300 | [diff] [blame] | 413 | if (IWL_UCODE_API(mvm->fw->ucode_ver) >= 10) { |
| 414 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 415 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; |
| 416 | hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; |
| 417 | /* we create the 802.11 header and zero length SSID IE. */ |
| 418 | hw->wiphy->max_sched_scan_ie_len = |
| 419 | SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; |
| 420 | } |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 421 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 422 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
Johannes Berg | ab48003 | 2014-06-04 10:13:50 +0200 | [diff] [blame] | 423 | NL80211_FEATURE_LOW_PRIORITY_SCAN | |
Eliad Peller | 0d8614b | 2014-09-10 14:07:36 +0300 | [diff] [blame] | 424 | NL80211_FEATURE_P2P_GO_OPPPS | |
| 425 | NL80211_FEATURE_DYNAMIC_SMPS | |
Emmanuel Grumbach | 9b5452f | 2014-10-07 10:38:53 +0300 | [diff] [blame^] | 426 | NL80211_FEATURE_STATIC_SMPS | |
| 427 | NL80211_FEATURE_SUPPORTS_WMM_ADMISSION; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 428 | |
Andrei Otcheretianski | f1daa00 | 2014-07-01 12:54:25 +0300 | [diff] [blame] | 429 | if (mvm->fw->ucode_capa.capa[0] & |
| 430 | IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT) |
| 431 | hw->wiphy->features |= NL80211_FEATURE_TX_POWER_INSERTION; |
Assaf Krauss | 226bcd4 | 2014-03-13 08:12:15 +0200 | [diff] [blame] | 432 | if (mvm->fw->ucode_capa.capa[0] & |
| 433 | IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT) |
| 434 | hw->wiphy->features |= NL80211_FEATURE_QUIET; |
Andrei Otcheretianski | f1daa00 | 2014-07-01 12:54:25 +0300 | [diff] [blame] | 435 | |
Andrei Otcheretianski | 73897bd | 2014-07-09 18:59:14 +0300 | [diff] [blame] | 436 | if (mvm->fw->ucode_capa.capa[0] & |
| 437 | IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT) |
| 438 | hw->wiphy->features |= |
| 439 | NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES; |
| 440 | |
| 441 | if (mvm->fw->ucode_capa.capa[0] & |
| 442 | IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT) |
| 443 | hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES; |
| 444 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 445 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
| 446 | |
Max Stepanov | e36e543 | 2013-08-27 19:56:13 +0300 | [diff] [blame] | 447 | /* currently FW API supports only one optional cipher scheme */ |
Johannes Berg | 9ddca86 | 2014-01-06 09:29:40 +0100 | [diff] [blame] | 448 | if (mvm->fw->cs[0].cipher) { |
Max Stepanov | e36e543 | 2013-08-27 19:56:13 +0300 | [diff] [blame] | 449 | mvm->hw->n_cipher_schemes = 1; |
Johannes Berg | 9ddca86 | 2014-01-06 09:29:40 +0100 | [diff] [blame] | 450 | mvm->hw->cipher_schemes = &mvm->fw->cs[0]; |
Max Stepanov | e36e543 | 2013-08-27 19:56:13 +0300 | [diff] [blame] | 451 | } |
| 452 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 453 | #ifdef CONFIG_PM_SLEEP |
Eliad Peller | d15a747 | 2014-03-27 18:53:12 +0200 | [diff] [blame] | 454 | if (iwl_mvm_is_d0i3_supported(mvm) && |
| 455 | device_can_wakeup(mvm->trans->dev)) { |
| 456 | mvm->wowlan.flags = WIPHY_WOWLAN_ANY; |
| 457 | hw->wiphy->wowlan = &mvm->wowlan; |
| 458 | } else if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 459 | mvm->trans->ops->d3_suspend && |
| 460 | mvm->trans->ops->d3_resume && |
| 461 | device_can_wakeup(mvm->trans->dev)) { |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 462 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
| 463 | WIPHY_WOWLAN_DISCONNECT | |
| 464 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 465 | WIPHY_WOWLAN_RFKILL_RELEASE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 466 | if (!iwlwifi_mod_params.sw_crypto) |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 467 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 468 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 469 | WIPHY_WOWLAN_4WAY_HANDSHAKE; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 470 | |
Johannes Berg | 964dc9e | 2013-06-03 17:25:34 +0200 | [diff] [blame] | 471 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; |
| 472 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; |
| 473 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; |
| 474 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; |
| 475 | hw->wiphy->wowlan = &mvm->wowlan; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 476 | } |
| 477 | #endif |
| 478 | |
Eliad Peller | 7773692 | 2014-01-14 12:35:49 +0200 | [diff] [blame] | 479 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 480 | /* assign default bcast filtering configuration */ |
| 481 | mvm->bcast_filters = iwl_mvm_default_bcast_filters; |
| 482 | #endif |
| 483 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 484 | ret = iwl_mvm_leds_init(mvm); |
| 485 | if (ret) |
| 486 | return ret; |
| 487 | |
Emmanuel Grumbach | b7327d8 | 2013-06-24 15:44:03 +0300 | [diff] [blame] | 488 | ret = ieee80211_register_hw(mvm->hw); |
| 489 | if (ret) |
| 490 | iwl_mvm_leds_exit(mvm); |
| 491 | |
| 492 | return ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 493 | } |
| 494 | |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 495 | static bool iwl_mvm_defer_tx(struct iwl_mvm *mvm, |
| 496 | struct ieee80211_sta *sta, |
| 497 | struct sk_buff *skb) |
| 498 | { |
| 499 | struct iwl_mvm_sta *mvmsta; |
| 500 | bool defer = false; |
| 501 | |
| 502 | /* |
| 503 | * double check the IN_D0I3 flag both before and after |
| 504 | * taking the spinlock, in order to prevent taking |
| 505 | * the spinlock when not needed. |
| 506 | */ |
| 507 | if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status))) |
| 508 | return false; |
| 509 | |
| 510 | spin_lock(&mvm->d0i3_tx_lock); |
| 511 | /* |
| 512 | * testing the flag again ensures the skb dequeue |
| 513 | * loop (on d0i3 exit) hasn't run yet. |
| 514 | */ |
| 515 | if (!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status)) |
| 516 | goto out; |
| 517 | |
| 518 | mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 519 | if (mvmsta->sta_id == IWL_MVM_STATION_COUNT || |
| 520 | mvmsta->sta_id != mvm->d0i3_ap_sta_id) |
| 521 | goto out; |
| 522 | |
| 523 | __skb_queue_tail(&mvm->d0i3_tx, skb); |
| 524 | ieee80211_stop_queues(mvm->hw); |
| 525 | |
| 526 | /* trigger wakeup */ |
| 527 | iwl_mvm_ref(mvm, IWL_MVM_REF_TX); |
| 528 | iwl_mvm_unref(mvm, IWL_MVM_REF_TX); |
| 529 | |
| 530 | defer = true; |
| 531 | out: |
| 532 | spin_unlock(&mvm->d0i3_tx_lock); |
| 533 | return defer; |
| 534 | } |
| 535 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 536 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
| 537 | struct ieee80211_tx_control *control, |
| 538 | struct sk_buff *skb) |
| 539 | { |
| 540 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 541 | struct ieee80211_sta *sta = control->sta; |
| 542 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 543 | struct ieee80211_hdr *hdr = (void *)skb->data; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 544 | |
Eytan Lifshitz | 9ee718a | 2013-05-19 19:14:41 +0300 | [diff] [blame] | 545 | if (iwl_mvm_is_radio_killed(mvm)) { |
| 546 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 547 | goto drop; |
| 548 | } |
| 549 | |
Ilan Peer | 398e8c6 | 2013-03-13 15:20:35 +0200 | [diff] [blame] | 550 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
Matti Gottlieb | a6cc516 | 2014-09-29 11:46:04 +0300 | [diff] [blame] | 551 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) && |
| 552 | !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 553 | goto drop; |
| 554 | |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 555 | /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */ |
| 556 | if (unlikely(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER && |
| 557 | ieee80211_is_mgmt(hdr->frame_control) && |
| 558 | !ieee80211_is_deauth(hdr->frame_control) && |
| 559 | !ieee80211_is_disassoc(hdr->frame_control) && |
| 560 | !ieee80211_is_action(hdr->frame_control))) |
| 561 | sta = NULL; |
| 562 | |
| 563 | if (sta) { |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 564 | if (iwl_mvm_defer_tx(mvm, sta, skb)) |
| 565 | return; |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 566 | if (iwl_mvm_tx_skb(mvm, skb, sta)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 567 | goto drop; |
| 568 | return; |
| 569 | } |
| 570 | |
| 571 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) |
| 572 | goto drop; |
| 573 | return; |
| 574 | drop: |
| 575 | ieee80211_free_txskb(hw, skb); |
| 576 | } |
| 577 | |
Emmanuel Grumbach | 205e221 | 2014-02-12 15:15:05 +0200 | [diff] [blame] | 578 | static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg) |
| 579 | { |
| 580 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) |
| 581 | return false; |
| 582 | return true; |
| 583 | } |
| 584 | |
| 585 | static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg) |
| 586 | { |
| 587 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) |
| 588 | return false; |
| 589 | if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG) |
| 590 | return true; |
| 591 | |
| 592 | /* enabled by default */ |
| 593 | return true; |
| 594 | } |
| 595 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 596 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
| 597 | struct ieee80211_vif *vif, |
| 598 | enum ieee80211_ampdu_mlme_action action, |
| 599 | struct ieee80211_sta *sta, u16 tid, |
| 600 | u16 *ssn, u8 buf_size) |
| 601 | { |
| 602 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 603 | int ret; |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 604 | bool tx_agg_ref = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 605 | |
| 606 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", |
| 607 | sta->addr, tid, action); |
| 608 | |
| 609 | if (!(mvm->nvm_data->sku_cap_11n_enable)) |
| 610 | return -EACCES; |
| 611 | |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 612 | /* return from D0i3 before starting a new Tx aggregation */ |
Eliad Peller | 9256c20 | 2014-04-22 13:33:29 +0300 | [diff] [blame] | 613 | switch (action) { |
| 614 | case IEEE80211_AMPDU_TX_START: |
| 615 | case IEEE80211_AMPDU_TX_STOP_CONT: |
| 616 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 617 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
| 618 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 619 | /* |
Eliad Peller | 9256c20 | 2014-04-22 13:33:29 +0300 | [diff] [blame] | 620 | * for tx start, wait synchronously until D0i3 exit to |
| 621 | * get the correct sequence number for the tid. |
| 622 | * additionally, some other ampdu actions use direct |
| 623 | * target access, which is not handled automatically |
| 624 | * by the trans layer (unlike commands), so wait for |
| 625 | * d0i3 exit in these cases as well. |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 626 | */ |
Gregory Greenman | d40fc48 | 2014-06-25 14:08:50 +0200 | [diff] [blame] | 627 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_TX_AGG); |
| 628 | if (ret) |
| 629 | return ret; |
| 630 | |
| 631 | tx_agg_ref = true; |
Eliad Peller | 9256c20 | 2014-04-22 13:33:29 +0300 | [diff] [blame] | 632 | break; |
| 633 | default: |
| 634 | break; |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 635 | } |
| 636 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 637 | mutex_lock(&mvm->mutex); |
| 638 | |
| 639 | switch (action) { |
| 640 | case IEEE80211_AMPDU_RX_START: |
Emmanuel Grumbach | 205e221 | 2014-02-12 15:15:05 +0200 | [diff] [blame] | 641 | if (!iwl_enable_rx_ampdu(mvm->cfg)) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 642 | ret = -EINVAL; |
| 643 | break; |
| 644 | } |
| 645 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); |
| 646 | break; |
| 647 | case IEEE80211_AMPDU_RX_STOP: |
| 648 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); |
| 649 | break; |
| 650 | case IEEE80211_AMPDU_TX_START: |
Emmanuel Grumbach | 205e221 | 2014-02-12 15:15:05 +0200 | [diff] [blame] | 651 | if (!iwl_enable_tx_ampdu(mvm->cfg)) { |
Emmanuel Grumbach | 5d158ef | 2013-02-19 14:39:58 +0200 | [diff] [blame] | 652 | ret = -EINVAL; |
| 653 | break; |
| 654 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 655 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
| 656 | break; |
| 657 | case IEEE80211_AMPDU_TX_STOP_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 658 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
| 659 | break; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 660 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 661 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
Emmanuel Grumbach | e3d9e7c | 2013-02-19 16:13:53 +0200 | [diff] [blame] | 662 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 663 | break; |
| 664 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 665 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); |
| 666 | break; |
| 667 | default: |
| 668 | WARN_ON_ONCE(1); |
| 669 | ret = -EINVAL; |
| 670 | break; |
| 671 | } |
| 672 | mutex_unlock(&mvm->mutex); |
| 673 | |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 674 | /* |
| 675 | * If the tid is marked as started, we won't use it for offloaded |
| 676 | * traffic on the next D0i3 entry. It's safe to unref. |
| 677 | */ |
| 678 | if (tx_agg_ref) |
| 679 | iwl_mvm_unref(mvm, IWL_MVM_REF_TX_AGG); |
| 680 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 681 | return ret; |
| 682 | } |
| 683 | |
| 684 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, |
| 685 | struct ieee80211_vif *vif) |
| 686 | { |
| 687 | struct iwl_mvm *mvm = data; |
| 688 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 689 | |
| 690 | mvmvif->uploaded = false; |
| 691 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 692 | |
| 693 | /* does this make sense at all? */ |
| 694 | mvmvif->color++; |
| 695 | |
| 696 | spin_lock_bh(&mvm->time_event_lock); |
| 697 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); |
| 698 | spin_unlock_bh(&mvm->time_event_lock); |
| 699 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 700 | mvmvif->phy_ctxt = NULL; |
Emmanuel Grumbach | 8a275ba | 2014-07-13 09:12:11 +0300 | [diff] [blame] | 701 | memset(&mvmvif->bf_data, 0, sizeof(mvmvif->bf_data)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 702 | } |
| 703 | |
Johannes Berg | aadede6 | 2014-10-09 17:01:36 +0200 | [diff] [blame] | 704 | static ssize_t iwl_mvm_read_coredump(char *buffer, loff_t offset, size_t count, |
| 705 | const void *data, size_t datalen) |
| 706 | { |
| 707 | const struct iwl_mvm_dump_ptrs *dump_ptrs = data; |
| 708 | ssize_t bytes_read; |
| 709 | ssize_t bytes_read_trans; |
| 710 | |
| 711 | if (offset < dump_ptrs->op_mode_len) { |
| 712 | bytes_read = min_t(ssize_t, count, |
| 713 | dump_ptrs->op_mode_len - offset); |
| 714 | memcpy(buffer, (u8 *)dump_ptrs->op_mode_ptr + offset, |
| 715 | bytes_read); |
| 716 | offset += bytes_read; |
| 717 | count -= bytes_read; |
| 718 | |
| 719 | if (count == 0) |
| 720 | return bytes_read; |
| 721 | } else { |
| 722 | bytes_read = 0; |
| 723 | } |
| 724 | |
| 725 | if (!dump_ptrs->trans_ptr) |
| 726 | return bytes_read; |
| 727 | |
| 728 | offset -= dump_ptrs->op_mode_len; |
| 729 | bytes_read_trans = min_t(ssize_t, count, |
| 730 | dump_ptrs->trans_ptr->len - offset); |
| 731 | memcpy(buffer + bytes_read, |
| 732 | (u8 *)dump_ptrs->trans_ptr->data + offset, |
| 733 | bytes_read_trans); |
| 734 | |
| 735 | return bytes_read + bytes_read_trans; |
| 736 | } |
| 737 | |
| 738 | static void iwl_mvm_free_coredump(const void *data) |
| 739 | { |
| 740 | const struct iwl_mvm_dump_ptrs *fw_error_dump = data; |
| 741 | |
| 742 | vfree(fw_error_dump->op_mode_ptr); |
| 743 | vfree(fw_error_dump->trans_ptr); |
| 744 | kfree(fw_error_dump); |
| 745 | } |
| 746 | |
Emmanuel Grumbach | 4bfa47f | 2014-09-11 16:19:43 +0300 | [diff] [blame] | 747 | void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm) |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 748 | { |
| 749 | struct iwl_fw_error_dump_file *dump_file; |
| 750 | struct iwl_fw_error_dump_data *dump_data; |
| 751 | struct iwl_fw_error_dump_info *dump_info; |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 752 | struct iwl_mvm_dump_ptrs *fw_error_dump; |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 753 | const struct fw_img *img; |
| 754 | u32 sram_len, sram_ofs; |
| 755 | u32 file_len, rxf_len; |
| 756 | unsigned long flags; |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 757 | int reg_val; |
| 758 | |
| 759 | lockdep_assert_held(&mvm->mutex); |
| 760 | |
Johannes Berg | aadede6 | 2014-10-09 17:01:36 +0200 | [diff] [blame] | 761 | fw_error_dump = kzalloc(sizeof(*fw_error_dump), GFP_KERNEL); |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 762 | if (!fw_error_dump) |
| 763 | return; |
| 764 | |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 765 | img = &mvm->fw->img[mvm->cur_ucode]; |
| 766 | sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 767 | sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 768 | |
| 769 | /* reading buffer size */ |
| 770 | reg_val = iwl_trans_read_prph(mvm->trans, RXF_SIZE_ADDR); |
| 771 | rxf_len = (reg_val & RXF_SIZE_BYTE_CNT_MSK) >> RXF_SIZE_BYTE_CND_POS; |
| 772 | |
| 773 | /* the register holds the value divided by 128 */ |
| 774 | rxf_len = rxf_len << 7; |
| 775 | |
| 776 | file_len = sizeof(*dump_file) + |
| 777 | sizeof(*dump_data) * 3 + |
| 778 | sram_len + |
| 779 | rxf_len + |
| 780 | sizeof(*dump_info); |
| 781 | |
Emmanuel Grumbach | 5bfe6f5 | 2014-06-25 16:21:43 +0300 | [diff] [blame] | 782 | dump_file = vzalloc(file_len); |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 783 | if (!dump_file) { |
| 784 | kfree(fw_error_dump); |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 785 | return; |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 786 | } |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 787 | |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 788 | fw_error_dump->op_mode_ptr = dump_file; |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 789 | |
| 790 | dump_file->barker = cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER); |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 791 | dump_data = (void *)dump_file->data; |
| 792 | |
| 793 | dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_DEV_FW_INFO); |
| 794 | dump_data->len = cpu_to_le32(sizeof(*dump_info)); |
| 795 | dump_info = (void *) dump_data->data; |
| 796 | dump_info->device_family = |
| 797 | mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000 ? |
| 798 | cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_7) : |
| 799 | cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_8); |
| 800 | memcpy(dump_info->fw_human_readable, mvm->fw->human_readable, |
| 801 | sizeof(dump_info->fw_human_readable)); |
| 802 | strncpy(dump_info->dev_human_readable, mvm->cfg->name, |
| 803 | sizeof(dump_info->dev_human_readable)); |
| 804 | strncpy(dump_info->bus_human_readable, mvm->dev->bus->name, |
| 805 | sizeof(dump_info->bus_human_readable)); |
| 806 | |
| 807 | dump_data = iwl_fw_error_next_data(dump_data); |
| 808 | dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RXF); |
| 809 | dump_data->len = cpu_to_le32(rxf_len); |
| 810 | |
| 811 | if (iwl_trans_grab_nic_access(mvm->trans, false, &flags)) { |
| 812 | u32 *rxf = (void *)dump_data->data; |
| 813 | int i; |
| 814 | |
| 815 | for (i = 0; i < (rxf_len / sizeof(u32)); i++) { |
| 816 | iwl_trans_write_prph(mvm->trans, |
| 817 | RXF_LD_FENCE_OFFSET_ADDR, |
| 818 | i * sizeof(u32)); |
| 819 | rxf[i] = iwl_trans_read_prph(mvm->trans, |
| 820 | RXF_FIFO_RD_FENCE_ADDR); |
| 821 | } |
| 822 | iwl_trans_release_nic_access(mvm->trans, &flags); |
| 823 | } |
| 824 | |
| 825 | dump_data = iwl_fw_error_next_data(dump_data); |
| 826 | dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_SRAM); |
| 827 | dump_data->len = cpu_to_le32(sram_len); |
| 828 | iwl_trans_read_mem_bytes(mvm->trans, sram_ofs, dump_data->data, |
| 829 | sram_len); |
| 830 | |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 831 | fw_error_dump->trans_ptr = iwl_trans_dump_data(mvm->trans); |
| 832 | fw_error_dump->op_mode_len = file_len; |
| 833 | if (fw_error_dump->trans_ptr) |
| 834 | file_len += fw_error_dump->trans_ptr->len; |
| 835 | dump_file->file_len = cpu_to_le32(file_len); |
Emmanuel Grumbach | 4bfa47f | 2014-09-11 16:19:43 +0300 | [diff] [blame] | 836 | |
Johannes Berg | aadede6 | 2014-10-09 17:01:36 +0200 | [diff] [blame] | 837 | dev_coredumpm(mvm->trans->dev, THIS_MODULE, fw_error_dump, 0, |
| 838 | GFP_KERNEL, iwl_mvm_read_coredump, iwl_mvm_free_coredump); |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 839 | } |
Emmanuel Grumbach | 655e6d6 | 2014-06-25 14:08:58 +0300 | [diff] [blame] | 840 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 841 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) |
| 842 | { |
Johannes Berg | 58629d9 | 2014-11-06 09:40:50 +0100 | [diff] [blame] | 843 | /* clear the D3 reconfig, we only need it to avoid dumping a |
| 844 | * firmware coredump on reconfiguration, we shouldn't do that |
| 845 | * on D3->D0 transition |
| 846 | */ |
| 847 | if (!test_and_clear_bit(IWL_MVM_STATUS_D3_RECONFIG, &mvm->status)) |
| 848 | iwl_mvm_fw_error_dump(mvm); |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 849 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 850 | iwl_trans_stop_device(mvm->trans); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 851 | |
| 852 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
Luciano Coelho | b187330 | 2014-08-08 17:12:07 +0300 | [diff] [blame] | 853 | mvm->ps_disabled = false; |
Emmanuel Grumbach | 31b8b34 | 2014-11-02 15:48:09 +0200 | [diff] [blame] | 854 | mvm->calibrating = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 855 | |
| 856 | /* just in case one was running */ |
| 857 | ieee80211_remain_on_channel_expired(mvm->hw); |
| 858 | |
| 859 | ieee80211_iterate_active_interfaces_atomic( |
| 860 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, |
| 861 | iwl_mvm_cleanup_iterator, mvm); |
| 862 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 863 | mvm->p2p_device_vif = NULL; |
Eliad Peller | 37577fe | 2013-12-05 17:19:39 +0200 | [diff] [blame] | 864 | mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT; |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 865 | |
| 866 | iwl_mvm_reset_phy_ctxts(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 867 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
| 868 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); |
Emmanuel Grumbach | 8a275ba | 2014-07-13 09:12:11 +0300 | [diff] [blame] | 869 | memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); |
| 870 | memset(&mvm->last_bt_notif_old, 0, sizeof(mvm->last_bt_notif_old)); |
| 871 | memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd)); |
| 872 | memset(&mvm->last_bt_ci_cmd_old, 0, sizeof(mvm->last_bt_ci_cmd_old)); |
| 873 | memset(&mvm->bt_ack_kill_msk, 0, sizeof(mvm->bt_ack_kill_msk)); |
| 874 | memset(&mvm->bt_cts_kill_msk, 0, sizeof(mvm->bt_cts_kill_msk)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 875 | |
| 876 | ieee80211_wake_queues(mvm->hw); |
| 877 | |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 878 | /* cleanup all stale references (scan, roc), but keep the |
| 879 | * ucode_down ref until reconfig is complete */ |
| 880 | iwl_mvm_unref_all_except(mvm, IWL_MVM_REF_UCODE_DOWN); |
| 881 | |
Eliad Peller | 228670b | 2014-08-10 17:00:15 +0300 | [diff] [blame] | 882 | /* clear any stale d0i3 state */ |
| 883 | clear_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status); |
| 884 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 885 | mvm->vif_count = 0; |
Emmanuel Grumbach | 113a044 | 2013-07-02 14:16:38 +0300 | [diff] [blame] | 886 | mvm->rx_ba_sessions = 0; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 887 | } |
| 888 | |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 889 | int __iwl_mvm_mac_start(struct iwl_mvm *mvm) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 890 | { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 891 | int ret; |
| 892 | |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 893 | lockdep_assert_held(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 894 | |
| 895 | /* Clean up some internal and mac80211 state on restart */ |
| 896 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) |
| 897 | iwl_mvm_restart_cleanup(mvm); |
| 898 | |
| 899 | ret = iwl_mvm_up(mvm); |
Johannes Berg | c47af22 | 2014-04-30 16:34:45 +0200 | [diff] [blame] | 900 | |
| 901 | if (ret && test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { |
| 902 | /* Something went wrong - we need to finish some cleanup |
| 903 | * that normally iwl_mvm_mac_restart_complete() below |
| 904 | * would do. |
| 905 | */ |
| 906 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
| 907 | iwl_mvm_d0i3_enable_tx(mvm, NULL); |
| 908 | } |
| 909 | |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 910 | return ret; |
| 911 | } |
| 912 | |
| 913 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) |
| 914 | { |
| 915 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 916 | int ret; |
| 917 | |
| 918 | mutex_lock(&mvm->mutex); |
| 919 | ret = __iwl_mvm_mac_start(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 920 | mutex_unlock(&mvm->mutex); |
| 921 | |
| 922 | return ret; |
| 923 | } |
| 924 | |
Eliad Peller | cf2c92d | 2014-11-04 11:43:54 +0200 | [diff] [blame] | 925 | static void iwl_mvm_restart_complete(struct iwl_mvm *mvm) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 926 | { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 927 | int ret; |
| 928 | |
| 929 | mutex_lock(&mvm->mutex); |
| 930 | |
| 931 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); |
Arik Nemtsov | b249250 | 2014-03-13 12:21:50 +0200 | [diff] [blame] | 932 | iwl_mvm_d0i3_enable_tx(mvm, NULL); |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 933 | ret = iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 934 | if (ret) |
| 935 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", |
| 936 | ret); |
| 937 | |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 938 | /* allow transport/FW low power modes */ |
| 939 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); |
| 940 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 941 | mutex_unlock(&mvm->mutex); |
| 942 | } |
| 943 | |
Eliad Peller | cf2c92d | 2014-11-04 11:43:54 +0200 | [diff] [blame] | 944 | static void |
| 945 | iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw, |
| 946 | enum ieee80211_reconfig_type reconfig_type) |
| 947 | { |
| 948 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 949 | |
| 950 | switch (reconfig_type) { |
| 951 | case IEEE80211_RECONFIG_TYPE_RESTART: |
| 952 | iwl_mvm_restart_complete(mvm); |
| 953 | break; |
| 954 | case IEEE80211_RECONFIG_TYPE_SUSPEND: |
| 955 | break; |
| 956 | } |
| 957 | } |
| 958 | |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 959 | void __iwl_mvm_mac_stop(struct iwl_mvm *mvm) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 960 | { |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 961 | lockdep_assert_held(&mvm->mutex); |
Eliad Peller | 7498cf4 | 2014-01-16 17:10:44 +0200 | [diff] [blame] | 962 | |
| 963 | /* disallow low power states when the FW is down */ |
| 964 | iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); |
| 965 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 966 | /* async_handlers_wk is now blocked */ |
| 967 | |
| 968 | /* |
| 969 | * The work item could be running or queued if the |
| 970 | * ROC time event stops just as we get here. |
| 971 | */ |
| 972 | cancel_work_sync(&mvm->roc_done_wk); |
| 973 | |
| 974 | iwl_trans_stop_device(mvm->trans); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 975 | |
| 976 | iwl_mvm_async_handlers_purge(mvm); |
| 977 | /* async_handlers_list is empty and will stay empty: HW is stopped */ |
| 978 | |
| 979 | /* the fw is stopped, the aux sta is dead: clean up driver state */ |
Johannes Berg | 712b24a | 2014-08-04 14:14:14 +0200 | [diff] [blame] | 980 | iwl_mvm_del_aux_sta(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 981 | |
Luciano Coelho | bc44886 | 2014-08-20 11:49:11 +0300 | [diff] [blame] | 982 | mvm->ucode_loaded = false; |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 983 | } |
Luciano Coelho | bc44886 | 2014-08-20 11:49:11 +0300 | [diff] [blame] | 984 | |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 985 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) |
| 986 | { |
| 987 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 988 | |
| 989 | flush_work(&mvm->d0i3_exit_work); |
| 990 | flush_work(&mvm->async_handlers_wk); |
Emmanuel Grumbach | 4bfa47f | 2014-09-11 16:19:43 +0300 | [diff] [blame] | 991 | flush_work(&mvm->fw_error_dump_wk); |
Luciano Coelho | a0a0924 | 2014-09-04 12:29:15 +0300 | [diff] [blame] | 992 | |
| 993 | mutex_lock(&mvm->mutex); |
| 994 | __iwl_mvm_mac_stop(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 995 | mutex_unlock(&mvm->mutex); |
| 996 | |
| 997 | /* |
| 998 | * The worker might have been waiting for the mutex, let it run and |
| 999 | * discover that its list is now empty. |
| 1000 | */ |
| 1001 | cancel_work_sync(&mvm->async_handlers_wk); |
| 1002 | } |
| 1003 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1004 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
| 1005 | { |
| 1006 | u16 i; |
| 1007 | |
| 1008 | lockdep_assert_held(&mvm->mutex); |
| 1009 | |
| 1010 | for (i = 0; i < NUM_PHY_CTX; i++) |
| 1011 | if (!mvm->phy_ctxts[i].ref) |
| 1012 | return &mvm->phy_ctxts[i]; |
| 1013 | |
| 1014 | IWL_ERR(mvm, "No available PHY context\n"); |
| 1015 | return NULL; |
| 1016 | } |
| 1017 | |
Emmanuel Grumbach | ee9c6cb | 2013-12-04 13:53:39 +0200 | [diff] [blame] | 1018 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 1019 | s8 tx_power) |
| 1020 | { |
| 1021 | /* FW is in charge of regulatory enforcement */ |
| 1022 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { |
| 1023 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, |
| 1024 | .pwr_restriction = cpu_to_le16(tx_power), |
| 1025 | }; |
| 1026 | |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1027 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, |
Emmanuel Grumbach | ee9c6cb | 2013-12-04 13:53:39 +0200 | [diff] [blame] | 1028 | sizeof(reduce_txpwr_cmd), |
| 1029 | &reduce_txpwr_cmd); |
| 1030 | } |
| 1031 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1032 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
| 1033 | struct ieee80211_vif *vif) |
| 1034 | { |
| 1035 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1036 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1037 | int ret; |
| 1038 | |
| 1039 | /* |
Gregory Greenman | d40fc48 | 2014-06-25 14:08:50 +0200 | [diff] [blame] | 1040 | * make sure D0i3 exit is completed, otherwise a target access |
| 1041 | * during tx queue configuration could be done when still in |
| 1042 | * D0i3 state. |
| 1043 | */ |
| 1044 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_ADD_IF); |
| 1045 | if (ret) |
| 1046 | return ret; |
| 1047 | |
| 1048 | /* |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1049 | * Not much to do here. The stack will not allow interface |
| 1050 | * types or combinations that we didn't advertise, so we |
| 1051 | * don't really have to check the types. |
| 1052 | */ |
| 1053 | |
| 1054 | mutex_lock(&mvm->mutex); |
| 1055 | |
Eliad Peller | e89044d | 2013-07-16 17:33:26 +0300 | [diff] [blame] | 1056 | /* Allocate resources for the MAC context, and add it to the fw */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1057 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
| 1058 | if (ret) |
| 1059 | goto out_unlock; |
| 1060 | |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 1061 | /* Counting number of interfaces is needed for legacy PM */ |
Ilan Peer | ea183d0 | 2013-07-23 14:41:53 +0300 | [diff] [blame] | 1062 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 1063 | mvm->vif_count++; |
Ilan Peer | ea183d0 | 2013-07-23 14:41:53 +0300 | [diff] [blame] | 1064 | |
| 1065 | /* |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1066 | * The AP binding flow can be done only after the beacon |
| 1067 | * template is configured (which happens only in the mac80211 |
| 1068 | * start_ap() flow), and adding the broadcast station can happen |
| 1069 | * only after the binding. |
| 1070 | * In addition, since modifying the MAC before adding a bcast |
| 1071 | * station is not allowed by the FW, delay the adding of MAC context to |
| 1072 | * the point where we can also add the bcast station. |
| 1073 | * In short: there's not much we can do at this point, other than |
| 1074 | * allocating resources :) |
| 1075 | */ |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1076 | if (vif->type == NL80211_IFTYPE_AP || |
| 1077 | vif->type == NL80211_IFTYPE_ADHOC) { |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1078 | ret = iwl_mvm_alloc_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1079 | if (ret) { |
| 1080 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); |
| 1081 | goto out_release; |
| 1082 | } |
| 1083 | |
Emmanuel Grumbach | 77740cb | 2013-06-26 23:51:41 +0300 | [diff] [blame] | 1084 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1085 | goto out_unlock; |
| 1086 | } |
| 1087 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1088 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 1089 | if (ret) |
| 1090 | goto out_release; |
| 1091 | |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 1092 | ret = iwl_mvm_power_update_mac(mvm); |
Emmanuel Grumbach | e5e7aa8 | 2014-01-27 16:57:33 +0200 | [diff] [blame] | 1093 | if (ret) |
| 1094 | goto out_release; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1095 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1096 | /* beacon filtering */ |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1097 | ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 1098 | if (ret) |
| 1099 | goto out_remove_mac; |
| 1100 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1101 | if (!mvm->bf_allowed_vif && |
Emmanuel Grumbach | 73e5f2c | 2014-03-30 08:57:30 +0300 | [diff] [blame] | 1102 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1103 | mvm->bf_allowed_vif = mvmvif; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1104 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
| 1105 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1106 | } |
| 1107 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1108 | /* |
| 1109 | * P2P_DEVICE interface does not have a channel context assigned to it, |
| 1110 | * so a dedicated PHY context is allocated to it and the corresponding |
| 1111 | * MAC context is bound to it at this stage. |
| 1112 | */ |
| 1113 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1114 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1115 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 1116 | if (!mvmvif->phy_ctxt) { |
| 1117 | ret = -ENOSPC; |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 1118 | goto out_free_bf; |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1119 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1120 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1121 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1122 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1123 | if (ret) |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1124 | goto out_unref_phy; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1125 | |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1126 | ret = iwl_mvm_add_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1127 | if (ret) |
| 1128 | goto out_unbind; |
| 1129 | |
| 1130 | /* Save a pointer to p2p device vif, so it can later be used to |
| 1131 | * update the p2p device MAC when a GO is started/stopped */ |
| 1132 | mvm->p2p_device_vif = vif; |
| 1133 | } |
| 1134 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 1135 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1136 | goto out_unlock; |
| 1137 | |
| 1138 | out_unbind: |
| 1139 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 1140 | out_unref_phy: |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1141 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 1142 | out_free_bf: |
| 1143 | if (mvm->bf_allowed_vif == mvmvif) { |
| 1144 | mvm->bf_allowed_vif = NULL; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1145 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 1146 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
Eliad Peller | bd3351b | 2013-07-16 17:50:17 +0300 | [diff] [blame] | 1147 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1148 | out_remove_mac: |
| 1149 | mvmvif->phy_ctxt = NULL; |
| 1150 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 1151 | out_release: |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 1152 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
| 1153 | mvm->vif_count--; |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 1154 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1155 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 1156 | out_unlock: |
| 1157 | mutex_unlock(&mvm->mutex); |
| 1158 | |
Gregory Greenman | d40fc48 | 2014-06-25 14:08:50 +0200 | [diff] [blame] | 1159 | iwl_mvm_unref(mvm, IWL_MVM_REF_ADD_IF); |
| 1160 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1161 | return ret; |
| 1162 | } |
| 1163 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 1164 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
| 1165 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1166 | { |
Arik Nemtsov | d92b732e | 2014-09-21 19:00:42 +0300 | [diff] [blame] | 1167 | u32 tfd_msk = iwl_mvm_mac_get_queues_mask(vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1168 | |
| 1169 | if (tfd_msk) { |
| 1170 | mutex_lock(&mvm->mutex); |
| 1171 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); |
| 1172 | mutex_unlock(&mvm->mutex); |
| 1173 | } |
| 1174 | |
| 1175 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1176 | /* |
| 1177 | * Flush the ROC worker which will flush the OFFCHANNEL queue. |
| 1178 | * We assume here that all the packets sent to the OFFCHANNEL |
| 1179 | * queue are sent in ROC session. |
| 1180 | */ |
| 1181 | flush_work(&mvm->roc_done_wk); |
| 1182 | } else { |
| 1183 | /* |
| 1184 | * By now, all the AC queues are empty. The AGG queues are |
| 1185 | * empty too. We already got all the Tx responses for all the |
| 1186 | * packets in the queues. The drain work can have been |
Emmanuel Grumbach | 0742a75 | 2013-06-10 14:10:33 +0300 | [diff] [blame] | 1187 | * triggered. Flush it. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1188 | */ |
| 1189 | flush_work(&mvm->sta_drained_wk); |
| 1190 | } |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, |
| 1194 | struct ieee80211_vif *vif) |
| 1195 | { |
| 1196 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1197 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1198 | |
| 1199 | iwl_mvm_prepare_mac_removal(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1200 | |
| 1201 | mutex_lock(&mvm->mutex); |
| 1202 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1203 | if (mvm->bf_allowed_vif == mvmvif) { |
| 1204 | mvm->bf_allowed_vif = NULL; |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1205 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
| 1206 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 1207 | } |
| 1208 | |
Johannes Berg | 6349437 | 2013-03-26 10:47:53 +0100 | [diff] [blame] | 1209 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
| 1210 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1211 | /* |
| 1212 | * 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] | 1213 | * interface is be handled as part of the stop_ap flow. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1214 | */ |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1215 | if (vif->type == NL80211_IFTYPE_AP || |
| 1216 | vif->type == NL80211_IFTYPE_ADHOC) { |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 1217 | #ifdef CONFIG_NL80211_TESTMODE |
| 1218 | if (vif == mvm->noa_vif) { |
| 1219 | mvm->noa_vif = NULL; |
| 1220 | mvm->noa_duration = 0; |
| 1221 | } |
| 1222 | #endif |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1223 | iwl_mvm_dealloc_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1224 | goto out_release; |
| 1225 | } |
| 1226 | |
| 1227 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 1228 | mvm->p2p_device_vif = NULL; |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1229 | iwl_mvm_rm_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1230 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 1231 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1232 | mvmvif->phy_ctxt = NULL; |
| 1233 | } |
| 1234 | |
Alexander Bondar | 5ee2b21 | 2013-03-05 10:16:40 +0200 | [diff] [blame] | 1235 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1236 | mvm->vif_count--; |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 1237 | |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 1238 | iwl_mvm_power_update_mac(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1239 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 1240 | |
| 1241 | out_release: |
| 1242 | iwl_mvm_mac_ctxt_release(mvm, vif); |
| 1243 | mutex_unlock(&mvm->mutex); |
| 1244 | } |
| 1245 | |
| 1246 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
| 1247 | { |
| 1248 | return 0; |
| 1249 | } |
| 1250 | |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1251 | struct iwl_mvm_mc_iter_data { |
| 1252 | struct iwl_mvm *mvm; |
| 1253 | int port_id; |
| 1254 | }; |
| 1255 | |
| 1256 | static void iwl_mvm_mc_iface_iterator(void *_data, u8 *mac, |
| 1257 | struct ieee80211_vif *vif) |
| 1258 | { |
| 1259 | struct iwl_mvm_mc_iter_data *data = _data; |
| 1260 | struct iwl_mvm *mvm = data->mvm; |
| 1261 | struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd; |
| 1262 | int ret, len; |
| 1263 | |
| 1264 | /* if we don't have free ports, mcast frames will be dropped */ |
| 1265 | if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM)) |
| 1266 | return; |
| 1267 | |
| 1268 | if (vif->type != NL80211_IFTYPE_STATION || |
| 1269 | !vif->bss_conf.assoc) |
| 1270 | return; |
| 1271 | |
| 1272 | cmd->port_id = data->port_id++; |
| 1273 | memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 1274 | len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4); |
| 1275 | |
Emmanuel Grumbach | 1c4abec | 2014-05-08 09:48:10 +0300 | [diff] [blame] | 1276 | ret = iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_ASYNC, len, cmd); |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1277 | if (ret) |
| 1278 | IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret); |
| 1279 | } |
| 1280 | |
| 1281 | static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm) |
| 1282 | { |
| 1283 | struct iwl_mvm_mc_iter_data iter_data = { |
| 1284 | .mvm = mvm, |
| 1285 | }; |
| 1286 | |
| 1287 | lockdep_assert_held(&mvm->mutex); |
| 1288 | |
| 1289 | if (WARN_ON_ONCE(!mvm->mcast_filter_cmd)) |
| 1290 | return; |
| 1291 | |
Emmanuel Grumbach | 1c4abec | 2014-05-08 09:48:10 +0300 | [diff] [blame] | 1292 | ieee80211_iterate_active_interfaces_atomic( |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1293 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 1294 | iwl_mvm_mc_iface_iterator, &iter_data); |
| 1295 | } |
| 1296 | |
| 1297 | static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw, |
| 1298 | struct netdev_hw_addr_list *mc_list) |
| 1299 | { |
| 1300 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1301 | struct iwl_mcast_filter_cmd *cmd; |
| 1302 | struct netdev_hw_addr *addr; |
Max Stepanov | f3bd58f | 2014-08-04 13:55:01 +0300 | [diff] [blame] | 1303 | int addr_count; |
| 1304 | bool pass_all; |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1305 | int len; |
| 1306 | |
Max Stepanov | f3bd58f | 2014-08-04 13:55:01 +0300 | [diff] [blame] | 1307 | addr_count = netdev_hw_addr_list_count(mc_list); |
| 1308 | pass_all = addr_count > MAX_MCAST_FILTERING_ADDRESSES || |
| 1309 | IWL_MVM_FW_MCAST_FILTER_PASS_ALL; |
| 1310 | if (pass_all) |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1311 | addr_count = 0; |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1312 | |
| 1313 | len = roundup(sizeof(*cmd) + addr_count * ETH_ALEN, 4); |
| 1314 | cmd = kzalloc(len, GFP_ATOMIC); |
| 1315 | if (!cmd) |
| 1316 | return 0; |
| 1317 | |
| 1318 | if (pass_all) { |
| 1319 | cmd->pass_all = 1; |
| 1320 | return (u64)(unsigned long)cmd; |
| 1321 | } |
| 1322 | |
| 1323 | netdev_hw_addr_list_for_each(addr, mc_list) { |
| 1324 | IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n", |
| 1325 | cmd->count, addr->addr); |
| 1326 | memcpy(&cmd->addr_list[cmd->count * ETH_ALEN], |
| 1327 | addr->addr, ETH_ALEN); |
| 1328 | cmd->count++; |
| 1329 | } |
| 1330 | |
| 1331 | return (u64)(unsigned long)cmd; |
| 1332 | } |
| 1333 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1334 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, |
| 1335 | unsigned int changed_flags, |
| 1336 | unsigned int *total_flags, |
| 1337 | u64 multicast) |
| 1338 | { |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1339 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1340 | struct iwl_mcast_filter_cmd *cmd = (void *)(unsigned long)multicast; |
| 1341 | |
| 1342 | mutex_lock(&mvm->mutex); |
| 1343 | |
| 1344 | /* replace previous configuration */ |
| 1345 | kfree(mvm->mcast_filter_cmd); |
| 1346 | mvm->mcast_filter_cmd = cmd; |
| 1347 | |
| 1348 | if (!cmd) |
| 1349 | goto out; |
| 1350 | |
| 1351 | iwl_mvm_recalc_multicast(mvm); |
| 1352 | out: |
| 1353 | mutex_unlock(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1354 | *total_flags = 0; |
| 1355 | } |
| 1356 | |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1357 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1358 | struct iwl_bcast_iter_data { |
| 1359 | struct iwl_mvm *mvm; |
| 1360 | struct iwl_bcast_filter_cmd *cmd; |
| 1361 | u8 current_filter; |
| 1362 | }; |
| 1363 | |
| 1364 | static void |
| 1365 | iwl_mvm_set_bcast_filter(struct ieee80211_vif *vif, |
| 1366 | const struct iwl_fw_bcast_filter *in_filter, |
| 1367 | struct iwl_fw_bcast_filter *out_filter) |
| 1368 | { |
| 1369 | struct iwl_fw_bcast_filter_attr *attr; |
| 1370 | int i; |
| 1371 | |
| 1372 | memcpy(out_filter, in_filter, sizeof(*out_filter)); |
| 1373 | |
| 1374 | for (i = 0; i < ARRAY_SIZE(out_filter->attrs); i++) { |
| 1375 | attr = &out_filter->attrs[i]; |
| 1376 | |
| 1377 | if (!attr->mask) |
| 1378 | break; |
| 1379 | |
Eliad Peller | 2ee8f02 | 2014-01-13 19:07:09 +0200 | [diff] [blame] | 1380 | switch (attr->reserved1) { |
| 1381 | case cpu_to_le16(BC_FILTER_MAGIC_IP): |
| 1382 | if (vif->bss_conf.arp_addr_cnt != 1) { |
| 1383 | attr->mask = 0; |
| 1384 | continue; |
| 1385 | } |
| 1386 | |
| 1387 | attr->val = vif->bss_conf.arp_addr_list[0]; |
| 1388 | break; |
| 1389 | case cpu_to_le16(BC_FILTER_MAGIC_MAC): |
| 1390 | attr->val = *(__be32 *)&vif->addr[2]; |
| 1391 | break; |
| 1392 | default: |
| 1393 | break; |
| 1394 | } |
| 1395 | attr->reserved1 = 0; |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1396 | out_filter->num_attrs++; |
| 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac, |
| 1401 | struct ieee80211_vif *vif) |
| 1402 | { |
| 1403 | struct iwl_bcast_iter_data *data = _data; |
| 1404 | struct iwl_mvm *mvm = data->mvm; |
| 1405 | struct iwl_bcast_filter_cmd *cmd = data->cmd; |
| 1406 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1407 | struct iwl_fw_bcast_mac *bcast_mac; |
| 1408 | int i; |
| 1409 | |
| 1410 | if (WARN_ON(mvmvif->id >= ARRAY_SIZE(cmd->macs))) |
| 1411 | return; |
| 1412 | |
| 1413 | bcast_mac = &cmd->macs[mvmvif->id]; |
| 1414 | |
Ilan Peer | e48393e | 2014-05-22 11:19:02 +0300 | [diff] [blame] | 1415 | /* |
| 1416 | * enable filtering only for associated stations, but not for P2P |
| 1417 | * Clients |
| 1418 | */ |
| 1419 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p || |
| 1420 | !vif->bss_conf.assoc) |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1421 | return; |
| 1422 | |
| 1423 | bcast_mac->default_discard = 1; |
| 1424 | |
| 1425 | /* copy all configured filters */ |
| 1426 | for (i = 0; mvm->bcast_filters[i].attrs[0].mask; i++) { |
| 1427 | /* |
| 1428 | * Make sure we don't exceed our filters limit. |
| 1429 | * if there is still a valid filter to be configured, |
| 1430 | * be on the safe side and just allow bcast for this mac. |
| 1431 | */ |
| 1432 | if (WARN_ON_ONCE(data->current_filter >= |
| 1433 | ARRAY_SIZE(cmd->filters))) { |
| 1434 | bcast_mac->default_discard = 0; |
| 1435 | bcast_mac->attached_filters = 0; |
| 1436 | break; |
| 1437 | } |
| 1438 | |
| 1439 | iwl_mvm_set_bcast_filter(vif, |
| 1440 | &mvm->bcast_filters[i], |
| 1441 | &cmd->filters[data->current_filter]); |
| 1442 | |
| 1443 | /* skip current filter if it contains no attributes */ |
| 1444 | if (!cmd->filters[data->current_filter].num_attrs) |
| 1445 | continue; |
| 1446 | |
| 1447 | /* attach the filter to current mac */ |
| 1448 | bcast_mac->attached_filters |= |
| 1449 | cpu_to_le16(BIT(data->current_filter)); |
| 1450 | |
| 1451 | data->current_filter++; |
| 1452 | } |
| 1453 | } |
| 1454 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1455 | bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm, |
| 1456 | struct iwl_bcast_filter_cmd *cmd) |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1457 | { |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1458 | struct iwl_bcast_iter_data iter_data = { |
| 1459 | .mvm = mvm, |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1460 | .cmd = cmd, |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1461 | }; |
| 1462 | |
Max Stepanov | 3b8983b | 2014-10-15 11:27:16 +0300 | [diff] [blame] | 1463 | if (IWL_MVM_FW_BCAST_FILTER_PASS_ALL) |
| 1464 | return false; |
| 1465 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1466 | memset(cmd, 0, sizeof(*cmd)); |
| 1467 | cmd->max_bcast_filters = ARRAY_SIZE(cmd->filters); |
| 1468 | cmd->max_macs = ARRAY_SIZE(cmd->macs); |
| 1469 | |
| 1470 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1471 | /* use debugfs filters/macs if override is configured */ |
| 1472 | if (mvm->dbgfs_bcast_filtering.override) { |
| 1473 | memcpy(cmd->filters, &mvm->dbgfs_bcast_filtering.cmd.filters, |
| 1474 | sizeof(cmd->filters)); |
| 1475 | memcpy(cmd->macs, &mvm->dbgfs_bcast_filtering.cmd.macs, |
| 1476 | sizeof(cmd->macs)); |
| 1477 | return true; |
| 1478 | } |
| 1479 | #endif |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1480 | |
| 1481 | /* if no filters are configured, do nothing */ |
| 1482 | if (!mvm->bcast_filters) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1483 | return false; |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1484 | |
| 1485 | /* configure and attach these filters for each associated sta vif */ |
| 1486 | ieee80211_iterate_active_interfaces( |
| 1487 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
| 1488 | iwl_mvm_bcast_filter_iterator, &iter_data); |
| 1489 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1490 | return true; |
| 1491 | } |
| 1492 | static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, |
| 1493 | struct ieee80211_vif *vif) |
| 1494 | { |
| 1495 | struct iwl_bcast_filter_cmd cmd; |
| 1496 | |
| 1497 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) |
| 1498 | return 0; |
| 1499 | |
| 1500 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
| 1501 | return 0; |
| 1502 | |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1503 | return iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1504 | sizeof(cmd), &cmd); |
| 1505 | } |
| 1506 | #else |
| 1507 | static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, |
| 1508 | struct ieee80211_vif *vif) |
| 1509 | { |
| 1510 | return 0; |
| 1511 | } |
| 1512 | #endif |
| 1513 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1514 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
| 1515 | struct ieee80211_vif *vif, |
| 1516 | struct ieee80211_bss_conf *bss_conf, |
| 1517 | u32 changes) |
| 1518 | { |
| 1519 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1520 | int ret; |
| 1521 | |
Ilan Peer | 6e97b0d | 2013-12-23 22:18:02 +0200 | [diff] [blame] | 1522 | /* |
| 1523 | * Re-calculate the tsf id, as the master-slave relations depend on the |
| 1524 | * beacon interval, which was not known when the station interface was |
| 1525 | * added. |
| 1526 | */ |
| 1527 | if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) |
| 1528 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); |
| 1529 | |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 1530 | /* |
| 1531 | * If we're not associated yet, take the (new) BSSID before associating |
| 1532 | * so the firmware knows. If we're already associated, then use the old |
| 1533 | * BSSID here, and we'll send a cleared one later in the CHANGED_ASSOC |
| 1534 | * branch for disassociation below. |
| 1535 | */ |
| 1536 | if (changes & BSS_CHANGED_BSSID && !mvmvif->associated) |
| 1537 | memcpy(mvmvif->bssid, bss_conf->bssid, ETH_ALEN); |
| 1538 | |
| 1539 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, mvmvif->bssid); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1540 | if (ret) |
| 1541 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
| 1542 | |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 1543 | /* after sending it once, adopt mac80211 data */ |
| 1544 | memcpy(mvmvif->bssid, bss_conf->bssid, ETH_ALEN); |
| 1545 | mvmvif->associated = bss_conf->assoc; |
| 1546 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1547 | if (changes & BSS_CHANGED_ASSOC) { |
| 1548 | if (bss_conf->assoc) { |
| 1549 | /* add quota for this interface */ |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 1550 | ret = iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1551 | if (ret) { |
| 1552 | IWL_ERR(mvm, "failed to update quotas\n"); |
| 1553 | return; |
| 1554 | } |
Johannes Berg | 016d27e | 2013-05-03 11:16:15 +0200 | [diff] [blame] | 1555 | |
| 1556 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, |
| 1557 | &mvm->status)) { |
| 1558 | /* |
| 1559 | * If we're restarting then the firmware will |
| 1560 | * obviously have lost synchronisation with |
| 1561 | * the AP. It will attempt to synchronise by |
| 1562 | * itself, but we can make it more reliable by |
| 1563 | * scheduling a session protection time event. |
| 1564 | * |
| 1565 | * The firmware needs to receive a beacon to |
| 1566 | * catch up with synchronisation, use 110% of |
| 1567 | * the beacon interval. |
| 1568 | * |
| 1569 | * Set a large maximum delay to allow for more |
| 1570 | * than a single interface. |
| 1571 | */ |
| 1572 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; |
| 1573 | iwl_mvm_protect_session(mvm, vif, dur, dur, |
Liad Kaufman | d20d37b | 2014-07-06 17:14:39 +0300 | [diff] [blame] | 1574 | 5 * dur, false); |
Johannes Berg | 016d27e | 2013-05-03 11:16:15 +0200 | [diff] [blame] | 1575 | } |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 1576 | |
| 1577 | iwl_mvm_sf_update(mvm, vif, false); |
Alexander Bondar | 175a70b | 2013-04-14 20:59:37 +0300 | [diff] [blame] | 1578 | iwl_mvm_power_vif_assoc(mvm, vif); |
Emmanuel Grumbach | 697162a | 2014-07-30 15:56:42 +0300 | [diff] [blame] | 1579 | if (vif->p2p) { |
Eliad Peller | 29a90a4 | 2013-11-05 14:06:29 +0200 | [diff] [blame] | 1580 | iwl_mvm_ref(mvm, IWL_MVM_REF_P2P_CLIENT); |
Emmanuel Grumbach | 697162a | 2014-07-30 15:56:42 +0300 | [diff] [blame] | 1581 | iwl_mvm_update_smps(mvm, vif, |
| 1582 | IWL_MVM_SMPS_REQ_PROT, |
| 1583 | IEEE80211_SMPS_DYNAMIC); |
| 1584 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1585 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 1586 | /* |
| 1587 | * If update fails - SF might be running in associated |
| 1588 | * mode while disassociated - which is forbidden. |
| 1589 | */ |
| 1590 | WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false), |
| 1591 | "Failed to update SF upon disassociation\n"); |
| 1592 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1593 | /* remove AP station now that the MAC is unassoc */ |
| 1594 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); |
| 1595 | if (ret) |
| 1596 | IWL_ERR(mvm, "failed to remove AP station\n"); |
Eliad Peller | 37577fe | 2013-12-05 17:19:39 +0200 | [diff] [blame] | 1597 | |
| 1598 | if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id) |
| 1599 | mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1600 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
| 1601 | /* remove quota for this interface */ |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 1602 | ret = iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1603 | if (ret) |
| 1604 | IWL_ERR(mvm, "failed to update quotas\n"); |
Eliad Peller | 29a90a4 | 2013-11-05 14:06:29 +0200 | [diff] [blame] | 1605 | |
| 1606 | if (vif->p2p) |
| 1607 | iwl_mvm_unref(mvm, IWL_MVM_REF_P2P_CLIENT); |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 1608 | |
| 1609 | /* this will take the cleared BSSID from bss_conf */ |
| 1610 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
| 1611 | if (ret) |
| 1612 | IWL_ERR(mvm, |
| 1613 | "failed to update MAC %pM (clear after unassoc)\n", |
| 1614 | vif->addr); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1615 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1616 | |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1617 | iwl_mvm_recalc_multicast(mvm); |
Eliad Peller | c87163b | 2014-01-08 10:11:11 +0200 | [diff] [blame] | 1618 | iwl_mvm_configure_bcast_filter(mvm, vif); |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 1619 | |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1620 | /* reset rssi values */ |
| 1621 | mvmvif->bf_data.ave_beacon_signal = 0; |
| 1622 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 1623 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | f94045e | 2014-01-06 13:38:55 +0200 | [diff] [blame] | 1624 | iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, |
| 1625 | IEEE80211_SMPS_AUTOMATIC); |
Alexander Bondar | 989c650 | 2013-05-16 17:34:17 +0300 | [diff] [blame] | 1626 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
Johannes Berg | 210a544 | 2013-01-24 23:48:23 +0100 | [diff] [blame] | 1627 | /* |
| 1628 | * We received a beacon _after_ association so |
| 1629 | * remove the session protection. |
| 1630 | */ |
| 1631 | iwl_mvm_remove_time_event(mvm, mvmvif, |
| 1632 | &mvmvif->time_event_data); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1633 | } |
Eran Harary | cc87d32 | 2014-07-15 14:04:23 +0300 | [diff] [blame] | 1634 | |
| 1635 | if (changes & BSS_CHANGED_BEACON_INFO) { |
| 1636 | iwl_mvm_sf_update(mvm, vif, false); |
| 1637 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); |
| 1638 | } |
| 1639 | |
Johannes Berg | 1bc10d3 | 2014-08-26 14:25:46 +0200 | [diff] [blame] | 1640 | if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | BSS_CHANGED_QOS)) { |
| 1641 | ret = iwl_mvm_power_update_mac(mvm); |
| 1642 | if (ret) |
| 1643 | IWL_ERR(mvm, "failed to update power mode\n"); |
| 1644 | } |
| 1645 | |
Matti Gottlieb | 88f2fd7 | 2013-07-09 15:25:46 +0300 | [diff] [blame] | 1646 | if (changes & BSS_CHANGED_TXPOWER) { |
| 1647 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", |
| 1648 | bss_conf->txpower); |
| 1649 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); |
| 1650 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1651 | |
| 1652 | if (changes & BSS_CHANGED_CQM) { |
Johannes Berg | 3c6acb6 | 2014-05-07 11:47:53 +0200 | [diff] [blame] | 1653 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed\n"); |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1654 | /* reset cqm events tracking */ |
| 1655 | mvmvif->bf_data.last_cqm_event = 0; |
Avri Altman | fa7b2e7 | 2014-05-20 08:03:24 +0300 | [diff] [blame] | 1656 | if (mvmvif->bf_data.bf_enabled) { |
| 1657 | ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0); |
| 1658 | if (ret) |
| 1659 | IWL_ERR(mvm, |
| 1660 | "failed to update CQM thresholds\n"); |
| 1661 | } |
Andrei Otcheretianski | a20fd39 | 2013-07-21 17:23:59 +0300 | [diff] [blame] | 1662 | } |
Eliad Peller | 2ee8f02 | 2014-01-13 19:07:09 +0200 | [diff] [blame] | 1663 | |
| 1664 | if (changes & BSS_CHANGED_ARP_FILTER) { |
Johannes Berg | 3c6acb6 | 2014-05-07 11:47:53 +0200 | [diff] [blame] | 1665 | IWL_DEBUG_MAC80211(mvm, "arp filter changed\n"); |
Eliad Peller | 2ee8f02 | 2014-01-13 19:07:09 +0200 | [diff] [blame] | 1666 | iwl_mvm_configure_bcast_filter(mvm, vif); |
| 1667 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1668 | } |
| 1669 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1670 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
| 1671 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1672 | { |
| 1673 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1674 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1675 | int ret; |
| 1676 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1677 | /* |
| 1678 | * iwl_mvm_mac_ctxt_add() might read directly from the device |
| 1679 | * (the system time), so make sure it is available. |
| 1680 | */ |
| 1681 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_START_AP); |
| 1682 | if (ret) |
| 1683 | return ret; |
| 1684 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1685 | mutex_lock(&mvm->mutex); |
| 1686 | |
| 1687 | /* Send the beacon template */ |
| 1688 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); |
| 1689 | if (ret) |
| 1690 | goto out_unlock; |
| 1691 | |
Ilan Peer | 6e97b0d | 2013-12-23 22:18:02 +0200 | [diff] [blame] | 1692 | /* |
| 1693 | * Re-calculate the tsf id, as the master-slave relations depend on the |
| 1694 | * beacon interval, which was not known when the AP interface was added. |
| 1695 | */ |
| 1696 | if (vif->type == NL80211_IFTYPE_AP) |
| 1697 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); |
| 1698 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1699 | /* Add the mac context */ |
| 1700 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
| 1701 | if (ret) |
| 1702 | goto out_unlock; |
| 1703 | |
| 1704 | /* Perform the binding */ |
| 1705 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 1706 | if (ret) |
| 1707 | goto out_remove; |
| 1708 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1709 | /* Send the bcast station. At this stage the TBTT and DTIM time events |
| 1710 | * are added and applied to the scheduler */ |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1711 | ret = iwl_mvm_send_add_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1712 | if (ret) |
| 1713 | goto out_unbind; |
| 1714 | |
Ilan Peer | 5691e21 | 2013-12-31 21:05:50 +0200 | [diff] [blame] | 1715 | /* must be set before quota calculations */ |
| 1716 | mvmvif->ap_ibss_active = true; |
| 1717 | |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 1718 | /* power updated needs to be done before quotas */ |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 1719 | iwl_mvm_power_update_mac(mvm); |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 1720 | |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 1721 | ret = iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1722 | if (ret) |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 1723 | goto out_quota_failed; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1724 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1725 | /* 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] | 1726 | if (vif->p2p && mvm->p2p_device_vif) |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 1727 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1728 | |
Eliad Peller | 29a90a4 | 2013-11-05 14:06:29 +0200 | [diff] [blame] | 1729 | iwl_mvm_ref(mvm, IWL_MVM_REF_AP_IBSS); |
| 1730 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 1731 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | dac94da | 2013-06-18 07:35:27 +0300 | [diff] [blame] | 1732 | |
Arik Nemtsov | f697267 | 2014-06-15 16:03:55 +0300 | [diff] [blame] | 1733 | /* we don't support TDLS during DCM */ |
| 1734 | if (iwl_mvm_phy_ctx_count(mvm) > 1) |
| 1735 | iwl_mvm_teardown_tdls_peers(mvm); |
| 1736 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1737 | mutex_unlock(&mvm->mutex); |
| 1738 | return 0; |
| 1739 | |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 1740 | out_quota_failed: |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 1741 | iwl_mvm_power_update_mac(mvm); |
Ilan Peer | 5691e21 | 2013-12-31 21:05:50 +0200 | [diff] [blame] | 1742 | mvmvif->ap_ibss_active = false; |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1743 | iwl_mvm_send_rm_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1744 | out_unbind: |
| 1745 | iwl_mvm_binding_remove_vif(mvm, vif); |
| 1746 | out_remove: |
| 1747 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 1748 | out_unlock: |
| 1749 | mutex_unlock(&mvm->mutex); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1750 | iwl_mvm_unref(mvm, IWL_MVM_REF_START_AP); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1751 | return ret; |
| 1752 | } |
| 1753 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1754 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
| 1755 | struct ieee80211_vif *vif) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1756 | { |
| 1757 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1758 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 1759 | |
Johannes Berg | 38a12b5 | 2013-02-22 14:07:56 +0100 | [diff] [blame] | 1760 | iwl_mvm_prepare_mac_removal(mvm, vif); |
| 1761 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1762 | mutex_lock(&mvm->mutex); |
| 1763 | |
Andrei Otcheretianski | 664322f | 2014-06-05 16:40:36 +0300 | [diff] [blame] | 1764 | /* Handle AP stop while in CSA */ |
Andrei Otcheretianski | 7f0a7c6 | 2014-05-04 11:48:12 +0300 | [diff] [blame] | 1765 | if (rcu_access_pointer(mvm->csa_vif) == vif) { |
| 1766 | iwl_mvm_remove_time_event(mvm, mvmvif, |
| 1767 | &mvmvif->time_event_data); |
Andrei Otcheretianski | 664322f | 2014-06-05 16:40:36 +0300 | [diff] [blame] | 1768 | RCU_INIT_POINTER(mvm->csa_vif, NULL); |
Andrei Otcheretianski | 7f0a7c6 | 2014-05-04 11:48:12 +0300 | [diff] [blame] | 1769 | } |
Andrei Otcheretianski | 664322f | 2014-06-05 16:40:36 +0300 | [diff] [blame] | 1770 | |
Andrei Otcheretianski | 003e5236 | 2014-05-25 17:24:22 +0300 | [diff] [blame] | 1771 | if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { |
| 1772 | RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); |
| 1773 | mvm->csa_tx_block_bcn_timeout = 0; |
| 1774 | } |
| 1775 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1776 | mvmvif->ap_ibss_active = false; |
David Spinadel | 1c87bba | 2014-02-27 16:41:52 +0200 | [diff] [blame] | 1777 | mvm->ap_last_beacon_gp2 = 0; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1778 | |
Emmanuel Grumbach | 8e484f0 | 2013-10-02 15:02:25 +0300 | [diff] [blame] | 1779 | iwl_mvm_bt_coex_vif_change(mvm); |
Emmanuel Grumbach | dac94da | 2013-06-18 07:35:27 +0300 | [diff] [blame] | 1780 | |
Eliad Peller | 29a90a4 | 2013-11-05 14:06:29 +0200 | [diff] [blame] | 1781 | iwl_mvm_unref(mvm, IWL_MVM_REF_AP_IBSS); |
| 1782 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1783 | /* 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] | 1784 | if (vif->p2p && mvm->p2p_device_vif) |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 1785 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1786 | |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 1787 | iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 013290a | 2014-08-04 13:38:48 +0200 | [diff] [blame] | 1788 | iwl_mvm_send_rm_bcast_sta(mvm, vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1789 | iwl_mvm_binding_remove_vif(mvm, vif); |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 1790 | |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 1791 | iwl_mvm_power_update_mac(mvm); |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 1792 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1793 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
| 1794 | |
| 1795 | mutex_unlock(&mvm->mutex); |
| 1796 | } |
| 1797 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1798 | static void |
| 1799 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, |
| 1800 | struct ieee80211_vif *vif, |
| 1801 | struct ieee80211_bss_conf *bss_conf, |
| 1802 | u32 changes) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1803 | { |
Ilan Peer | be2056f | 2013-12-04 16:47:14 +0200 | [diff] [blame] | 1804 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Avri Altman | 8a5e366 | 2013-11-12 19:16:03 +0200 | [diff] [blame] | 1805 | |
Ilan Peer | be2056f | 2013-12-04 16:47:14 +0200 | [diff] [blame] | 1806 | /* Changes will be applied when the AP/IBSS is started */ |
| 1807 | if (!mvmvif->ap_ibss_active) |
| 1808 | return; |
| 1809 | |
Johannes Berg | 863230da | 2013-12-04 17:08:40 +0100 | [diff] [blame] | 1810 | if (changes & (BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_HT | |
Johannes Berg | f7d8b70 | 2014-09-09 15:49:19 +0200 | [diff] [blame] | 1811 | BSS_CHANGED_BANDWIDTH | BSS_CHANGED_QOS) && |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 1812 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL)) |
Johannes Berg | 863230da | 2013-12-04 17:08:40 +0100 | [diff] [blame] | 1813 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
Avri Altman | 8a5e366 | 2013-11-12 19:16:03 +0200 | [diff] [blame] | 1814 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1815 | /* Need to send a new beacon template to the FW */ |
Johannes Berg | 863230da | 2013-12-04 17:08:40 +0100 | [diff] [blame] | 1816 | if (changes & BSS_CHANGED_BEACON && |
| 1817 | iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) |
| 1818 | IWL_WARN(mvm, "Failed updating beacon data\n"); |
Haim Dreyfuss | 79b7a69 | 2014-09-14 12:40:00 +0300 | [diff] [blame] | 1819 | |
| 1820 | if (changes & BSS_CHANGED_TXPOWER) { |
| 1821 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", |
| 1822 | bss_conf->txpower); |
| 1823 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); |
| 1824 | } |
| 1825 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1826 | } |
| 1827 | |
| 1828 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, |
| 1829 | struct ieee80211_vif *vif, |
| 1830 | struct ieee80211_bss_conf *bss_conf, |
| 1831 | u32 changes) |
| 1832 | { |
| 1833 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1834 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1835 | /* |
| 1836 | * iwl_mvm_bss_info_changed_station() might call |
| 1837 | * iwl_mvm_protect_session(), which reads directly from |
| 1838 | * the device (the system time), so make sure it is available. |
| 1839 | */ |
| 1840 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_BSS_CHANGED)) |
| 1841 | return; |
| 1842 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1843 | mutex_lock(&mvm->mutex); |
| 1844 | |
David Spinadel | 723f02e | 2014-04-27 09:54:54 +0300 | [diff] [blame] | 1845 | if (changes & BSS_CHANGED_IDLE && !bss_conf->idle) |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 1846 | iwl_mvm_scan_offload_stop(mvm, true); |
David Spinadel | 723f02e | 2014-04-27 09:54:54 +0300 | [diff] [blame] | 1847 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1848 | switch (vif->type) { |
| 1849 | case NL80211_IFTYPE_STATION: |
| 1850 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); |
| 1851 | break; |
| 1852 | case NL80211_IFTYPE_AP: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 1853 | case NL80211_IFTYPE_ADHOC: |
| 1854 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1855 | break; |
| 1856 | default: |
| 1857 | /* shouldn't happen */ |
| 1858 | WARN_ON_ONCE(1); |
| 1859 | } |
| 1860 | |
| 1861 | mutex_unlock(&mvm->mutex); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1862 | iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1863 | } |
| 1864 | |
Eliad Peller | 4660dfb | 2014-06-22 18:15:59 +0300 | [diff] [blame] | 1865 | static int iwl_mvm_cancel_scan_wait_notif(struct iwl_mvm *mvm, |
| 1866 | enum iwl_scan_status scan_type) |
| 1867 | { |
| 1868 | int ret; |
| 1869 | bool wait_for_handlers = false; |
| 1870 | |
| 1871 | mutex_lock(&mvm->mutex); |
| 1872 | |
| 1873 | if (mvm->scan_status != scan_type) { |
| 1874 | ret = 0; |
| 1875 | /* make sure there are no pending notifications */ |
| 1876 | wait_for_handlers = true; |
| 1877 | goto out; |
| 1878 | } |
| 1879 | |
| 1880 | switch (scan_type) { |
| 1881 | case IWL_MVM_SCAN_SCHED: |
| 1882 | ret = iwl_mvm_scan_offload_stop(mvm, true); |
| 1883 | break; |
| 1884 | case IWL_MVM_SCAN_OS: |
| 1885 | ret = iwl_mvm_cancel_scan(mvm); |
| 1886 | break; |
| 1887 | case IWL_MVM_SCAN_NONE: |
| 1888 | default: |
| 1889 | WARN_ON_ONCE(1); |
| 1890 | ret = -EINVAL; |
| 1891 | break; |
| 1892 | } |
| 1893 | if (ret) |
| 1894 | goto out; |
| 1895 | |
| 1896 | wait_for_handlers = true; |
| 1897 | out: |
| 1898 | mutex_unlock(&mvm->mutex); |
| 1899 | |
| 1900 | /* make sure we consume the completion notification */ |
| 1901 | if (wait_for_handlers) |
| 1902 | iwl_mvm_wait_for_async_handlers(mvm); |
| 1903 | |
| 1904 | return ret; |
| 1905 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1906 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, |
| 1907 | struct ieee80211_vif *vif, |
David Spinadel | c56ef67 | 2014-02-05 15:21:13 +0200 | [diff] [blame] | 1908 | struct ieee80211_scan_request *hw_req) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1909 | { |
| 1910 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
David Spinadel | c56ef67 | 2014-02-05 15:21:13 +0200 | [diff] [blame] | 1911 | struct cfg80211_scan_request *req = &hw_req->req; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1912 | int ret; |
| 1913 | |
David Spinadel | 762533b | 2014-06-05 11:20:43 +0300 | [diff] [blame] | 1914 | if (req->n_channels == 0 || |
| 1915 | req->n_channels > mvm->fw->ucode_capa.n_scan_channels) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1916 | return -EINVAL; |
| 1917 | |
Eliad Peller | 4660dfb | 2014-06-22 18:15:59 +0300 | [diff] [blame] | 1918 | ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_SCHED); |
| 1919 | if (ret) |
| 1920 | return ret; |
| 1921 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1922 | mutex_lock(&mvm->mutex); |
| 1923 | |
Eliad Peller | 4660dfb | 2014-06-22 18:15:59 +0300 | [diff] [blame] | 1924 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1925 | ret = -EBUSY; |
Arik Nemtsov | 519e202 | 2013-10-17 17:51:35 +0300 | [diff] [blame] | 1926 | goto out; |
| 1927 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1928 | |
Arik Nemtsov | 519e202 | 2013-10-17 17:51:35 +0300 | [diff] [blame] | 1929 | iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN); |
| 1930 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 1931 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) |
| 1932 | ret = iwl_mvm_unified_scan_lmac(mvm, vif, hw_req); |
| 1933 | else |
| 1934 | ret = iwl_mvm_scan_request(mvm, vif, req); |
| 1935 | |
Arik Nemtsov | 519e202 | 2013-10-17 17:51:35 +0300 | [diff] [blame] | 1936 | if (ret) |
| 1937 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
| 1938 | out: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1939 | mutex_unlock(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1940 | return ret; |
| 1941 | } |
| 1942 | |
| 1943 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, |
| 1944 | struct ieee80211_vif *vif) |
| 1945 | { |
| 1946 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1947 | |
| 1948 | mutex_lock(&mvm->mutex); |
| 1949 | |
| 1950 | iwl_mvm_cancel_scan(mvm); |
| 1951 | |
| 1952 | mutex_unlock(&mvm->mutex); |
| 1953 | } |
| 1954 | |
| 1955 | static void |
| 1956 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 1957 | struct ieee80211_sta *sta, u16 tids, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1958 | int num_frames, |
| 1959 | enum ieee80211_frame_release_type reason, |
| 1960 | bool more_data) |
| 1961 | { |
| 1962 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1963 | |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 1964 | /* Called when we need to transmit (a) frame(s) from mac80211 */ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1965 | |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 1966 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
| 1967 | tids, more_data, false); |
| 1968 | } |
| 1969 | |
| 1970 | static void |
| 1971 | iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw, |
| 1972 | struct ieee80211_sta *sta, u16 tids, |
| 1973 | int num_frames, |
| 1974 | enum ieee80211_frame_release_type reason, |
| 1975 | bool more_data) |
| 1976 | { |
| 1977 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 1978 | |
| 1979 | /* Called when we need to transmit (a) frame(s) from agg queue */ |
| 1980 | |
| 1981 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
| 1982 | tids, more_data, true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1983 | } |
| 1984 | |
| 1985 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
| 1986 | struct ieee80211_vif *vif, |
| 1987 | enum sta_notify_cmd cmd, |
| 1988 | struct ieee80211_sta *sta) |
| 1989 | { |
| 1990 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 5b577a9 | 2013-11-14 18:20:04 +0100 | [diff] [blame] | 1991 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 1992 | int tid; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1993 | |
| 1994 | switch (cmd) { |
| 1995 | case STA_NOTIFY_SLEEP: |
Emmanuel Grumbach | e3d4bc8 | 2013-05-07 14:08:24 +0300 | [diff] [blame] | 1996 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1997 | ieee80211_sta_block_awake(hw, sta, true); |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 1998 | spin_lock_bh(&mvmsta->lock); |
| 1999 | for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { |
| 2000 | struct iwl_mvm_tid_data *tid_data; |
| 2001 | |
| 2002 | tid_data = &mvmsta->tid_data[tid]; |
| 2003 | if (tid_data->state != IWL_AGG_ON && |
| 2004 | tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA) |
| 2005 | continue; |
| 2006 | if (iwl_mvm_tid_queued(tid_data) == 0) |
| 2007 | continue; |
| 2008 | ieee80211_sta_set_buffered(sta, tid, true); |
| 2009 | } |
| 2010 | spin_unlock_bh(&mvmsta->lock); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2011 | /* |
| 2012 | * The fw updates the STA to be asleep. Tx packets on the Tx |
| 2013 | * queues to this station will not be transmitted. The fw will |
| 2014 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. |
| 2015 | */ |
| 2016 | break; |
| 2017 | case STA_NOTIFY_AWAKE: |
Emmanuel Grumbach | 881acd8 | 2013-03-19 16:16:00 +0200 | [diff] [blame] | 2018 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2019 | break; |
Johannes Berg | 9cc4071 | 2013-02-15 22:47:48 +0100 | [diff] [blame] | 2020 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2021 | break; |
| 2022 | default: |
| 2023 | break; |
| 2024 | } |
| 2025 | } |
| 2026 | |
Johannes Berg | 1ddbbb0 | 2013-12-04 22:39:17 +0100 | [diff] [blame] | 2027 | static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, |
| 2028 | struct ieee80211_vif *vif, |
| 2029 | struct ieee80211_sta *sta) |
| 2030 | { |
| 2031 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2032 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; |
| 2033 | |
| 2034 | /* |
| 2035 | * This is called before mac80211 does RCU synchronisation, |
| 2036 | * so here we already invalidate our internal RCU-protected |
| 2037 | * station pointer. The rest of the code will thus no longer |
| 2038 | * be able to find the station this way, and we don't rely |
| 2039 | * on further RCU synchronisation after the sta_state() |
| 2040 | * callback deleted the station. |
| 2041 | */ |
| 2042 | mutex_lock(&mvm->mutex); |
| 2043 | if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id])) |
| 2044 | rcu_assign_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id], |
| 2045 | ERR_PTR(-ENOENT)); |
| 2046 | mutex_unlock(&mvm->mutex); |
| 2047 | } |
| 2048 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2049 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
| 2050 | struct ieee80211_vif *vif, |
| 2051 | struct ieee80211_sta *sta, |
| 2052 | enum ieee80211_sta_state old_state, |
| 2053 | enum ieee80211_sta_state new_state) |
| 2054 | { |
| 2055 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2056 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2057 | int ret; |
| 2058 | |
| 2059 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", |
| 2060 | sta->addr, old_state, new_state); |
| 2061 | |
| 2062 | /* this would be a mac80211 bug ... but don't crash */ |
| 2063 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) |
| 2064 | return -EINVAL; |
| 2065 | |
| 2066 | /* if a STA is being removed, reuse its ID */ |
| 2067 | flush_work(&mvm->sta_drained_wk); |
| 2068 | |
| 2069 | mutex_lock(&mvm->mutex); |
| 2070 | if (old_state == IEEE80211_STA_NOTEXIST && |
| 2071 | new_state == IEEE80211_STA_NONE) { |
Johannes Berg | 48bc130 | 2013-07-04 15:55:29 +0200 | [diff] [blame] | 2072 | /* |
| 2073 | * Firmware bug - it'll crash if the beacon interval is less |
| 2074 | * than 16. We can't avoid connecting at all, so refuse the |
| 2075 | * station state change, this will cause mac80211 to abandon |
| 2076 | * attempts to connect to this AP, and eventually wpa_s will |
| 2077 | * blacklist the AP... |
| 2078 | */ |
| 2079 | if (vif->type == NL80211_IFTYPE_STATION && |
| 2080 | vif->bss_conf.beacon_int < 16) { |
| 2081 | IWL_ERR(mvm, |
| 2082 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", |
| 2083 | sta->addr, vif->bss_conf.beacon_int); |
| 2084 | ret = -EINVAL; |
| 2085 | goto out_unlock; |
| 2086 | } |
Arik Nemtsov | cf7b491 | 2014-05-15 11:44:40 +0300 | [diff] [blame] | 2087 | |
| 2088 | if (sta->tdls && |
| 2089 | (vif->p2p || |
Arik Nemtsov | fa3d07e | 2014-05-15 18:59:32 +0300 | [diff] [blame] | 2090 | iwl_mvm_tdls_sta_count(mvm, NULL) == |
| 2091 | IWL_MVM_TDLS_STA_COUNT || |
Arik Nemtsov | cf7b491 | 2014-05-15 11:44:40 +0300 | [diff] [blame] | 2092 | iwl_mvm_phy_ctx_count(mvm) > 1)) { |
| 2093 | IWL_DEBUG_MAC80211(mvm, "refusing TDLS sta\n"); |
| 2094 | ret = -EBUSY; |
| 2095 | goto out_unlock; |
| 2096 | } |
| 2097 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2098 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
Arik Nemtsov | fa3d07e | 2014-05-15 18:59:32 +0300 | [diff] [blame] | 2099 | if (sta->tdls && ret == 0) |
| 2100 | iwl_mvm_recalc_tdls_state(mvm, vif, true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2101 | } else if (old_state == IEEE80211_STA_NONE && |
| 2102 | new_state == IEEE80211_STA_AUTH) { |
Haim Dreyfuss | e820c2d | 2014-04-06 11:19:09 +0300 | [diff] [blame] | 2103 | /* |
| 2104 | * EBS may be disabled due to previous failures reported by FW. |
| 2105 | * Reset EBS status here assuming environment has been changed. |
| 2106 | */ |
| 2107 | mvm->last_ebs_successful = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2108 | ret = 0; |
| 2109 | } else if (old_state == IEEE80211_STA_AUTH && |
| 2110 | new_state == IEEE80211_STA_ASSOC) { |
Johannes Berg | 7a45397 | 2013-02-12 13:10:44 +0100 | [diff] [blame] | 2111 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
| 2112 | if (ret == 0) |
| 2113 | iwl_mvm_rs_rate_init(mvm, sta, |
Eyal Shapira | b87c217 | 2013-11-09 23:37:55 +0200 | [diff] [blame] | 2114 | mvmvif->phy_ctxt->channel->band, |
| 2115 | true); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2116 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 2117 | new_state == IEEE80211_STA_AUTHORIZED) { |
Arik Nemtsov | f59e0e3c | 2014-06-10 19:56:27 +0300 | [diff] [blame] | 2118 | |
| 2119 | /* we don't support TDLS during DCM */ |
| 2120 | if (iwl_mvm_phy_ctx_count(mvm) > 1) |
| 2121 | iwl_mvm_teardown_tdls_peers(mvm); |
| 2122 | |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 2123 | /* enable beacon filtering */ |
Avri Altman | fa7b2e7 | 2014-05-20 08:03:24 +0300 | [diff] [blame] | 2124 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2125 | ret = 0; |
| 2126 | } else if (old_state == IEEE80211_STA_AUTHORIZED && |
| 2127 | new_state == IEEE80211_STA_ASSOC) { |
Hila Gonen | 7df15b1 | 2012-12-12 11:16:19 +0200 | [diff] [blame] | 2128 | /* disable beacon filtering */ |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 2129 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif, 0)); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2130 | ret = 0; |
| 2131 | } else if (old_state == IEEE80211_STA_ASSOC && |
| 2132 | new_state == IEEE80211_STA_AUTH) { |
| 2133 | ret = 0; |
| 2134 | } else if (old_state == IEEE80211_STA_AUTH && |
| 2135 | new_state == IEEE80211_STA_NONE) { |
| 2136 | ret = 0; |
| 2137 | } else if (old_state == IEEE80211_STA_NONE && |
| 2138 | new_state == IEEE80211_STA_NOTEXIST) { |
| 2139 | ret = iwl_mvm_rm_sta(mvm, vif, sta); |
Arik Nemtsov | fa3d07e | 2014-05-15 18:59:32 +0300 | [diff] [blame] | 2140 | if (sta->tdls) |
| 2141 | iwl_mvm_recalc_tdls_state(mvm, vif, false); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2142 | } else { |
| 2143 | ret = -EIO; |
| 2144 | } |
Johannes Berg | 48bc130 | 2013-07-04 15:55:29 +0200 | [diff] [blame] | 2145 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2146 | mutex_unlock(&mvm->mutex); |
| 2147 | |
| 2148 | return ret; |
| 2149 | } |
| 2150 | |
| 2151 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
| 2152 | { |
| 2153 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2154 | |
| 2155 | mvm->rts_threshold = value; |
| 2156 | |
| 2157 | return 0; |
| 2158 | } |
| 2159 | |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 2160 | static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, |
| 2161 | struct ieee80211_vif *vif, |
| 2162 | struct ieee80211_sta *sta, u32 changed) |
| 2163 | { |
| 2164 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2165 | |
| 2166 | if (vif->type == NL80211_IFTYPE_STATION && |
| 2167 | changed & IEEE80211_RC_NSS_CHANGED) |
| 2168 | iwl_mvm_sf_update(mvm, vif, false); |
| 2169 | } |
| 2170 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2171 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
| 2172 | struct ieee80211_vif *vif, u16 ac, |
| 2173 | const struct ieee80211_tx_queue_params *params) |
| 2174 | { |
| 2175 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2176 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2177 | |
| 2178 | mvmvif->queue_params[ac] = *params; |
| 2179 | |
| 2180 | /* |
| 2181 | * No need to update right away, we'll get BSS_CHANGED_QOS |
| 2182 | * The exception is P2P_DEVICE interface which needs immediate update. |
| 2183 | */ |
| 2184 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 2185 | int ret; |
| 2186 | |
| 2187 | mutex_lock(&mvm->mutex); |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 2188 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2189 | mutex_unlock(&mvm->mutex); |
| 2190 | return ret; |
| 2191 | } |
| 2192 | return 0; |
| 2193 | } |
| 2194 | |
| 2195 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, |
| 2196 | struct ieee80211_vif *vif) |
| 2197 | { |
| 2198 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2199 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, |
| 2200 | 200 + vif->bss_conf.beacon_int); |
| 2201 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, |
| 2202 | 100 + vif->bss_conf.beacon_int); |
| 2203 | |
| 2204 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) |
| 2205 | return; |
| 2206 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 2207 | /* |
| 2208 | * iwl_mvm_protect_session() reads directly from the device |
| 2209 | * (the system time), so make sure it is available. |
| 2210 | */ |
| 2211 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PREPARE_TX)) |
| 2212 | return; |
| 2213 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2214 | mutex_lock(&mvm->mutex); |
| 2215 | /* Try really hard to protect the session and hear a beacon */ |
Liad Kaufman | d20d37b | 2014-07-06 17:14:39 +0300 | [diff] [blame] | 2216 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500, false); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2217 | mutex_unlock(&mvm->mutex); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 2218 | |
| 2219 | iwl_mvm_unref(mvm, IWL_MVM_REF_PREPARE_TX); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2220 | } |
| 2221 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2222 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
| 2223 | struct ieee80211_vif *vif, |
| 2224 | struct cfg80211_sched_scan_request *req, |
David Spinadel | 633e271 | 2014-02-06 16:15:23 +0200 | [diff] [blame] | 2225 | struct ieee80211_scan_ies *ies) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2226 | { |
| 2227 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2228 | int ret; |
| 2229 | |
Eliad Peller | 4660dfb | 2014-06-22 18:15:59 +0300 | [diff] [blame] | 2230 | ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_OS); |
| 2231 | if (ret) |
| 2232 | return ret; |
| 2233 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2234 | mutex_lock(&mvm->mutex); |
| 2235 | |
Alexander Bondar | 59ecb12 | 2014-07-30 17:40:28 +0300 | [diff] [blame] | 2236 | /* Newest FW fixes sched scan while connected on another interface */ |
| 2237 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) { |
| 2238 | if (!vif->bss_conf.idle) { |
| 2239 | ret = -EBUSY; |
| 2240 | goto out; |
| 2241 | } |
| 2242 | } else if (!iwl_mvm_is_idle(mvm)) { |
David Spinadel | bd5e474 | 2014-04-24 13:15:29 +0300 | [diff] [blame] | 2243 | ret = -EBUSY; |
| 2244 | goto out; |
| 2245 | } |
| 2246 | |
Eliad Peller | 4660dfb | 2014-06-22 18:15:59 +0300 | [diff] [blame] | 2247 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2248 | ret = -EBUSY; |
| 2249 | goto out; |
| 2250 | } |
| 2251 | |
| 2252 | mvm->scan_status = IWL_MVM_SCAN_SCHED; |
| 2253 | |
Luciano Coelho | b141c23 | 2014-10-01 13:22:40 +0300 | [diff] [blame] | 2254 | ret = iwl_mvm_scan_offload_start(mvm, vif, req, ies); |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2255 | if (ret) |
Luciano Coelho | b141c23 | 2014-10-01 13:22:40 +0300 | [diff] [blame] | 2256 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2257 | out: |
| 2258 | mutex_unlock(&mvm->mutex); |
| 2259 | return ret; |
| 2260 | } |
| 2261 | |
Johannes Berg | 37e3308 | 2014-02-17 10:48:17 +0100 | [diff] [blame] | 2262 | static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, |
| 2263 | struct ieee80211_vif *vif) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2264 | { |
| 2265 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 2266 | int ret; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2267 | |
| 2268 | mutex_lock(&mvm->mutex); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 2269 | ret = iwl_mvm_scan_offload_stop(mvm, false); |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2270 | mutex_unlock(&mvm->mutex); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 2271 | iwl_mvm_wait_for_async_handlers(mvm); |
Johannes Berg | 37e3308 | 2014-02-17 10:48:17 +0100 | [diff] [blame] | 2272 | |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 2273 | return ret; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 2274 | } |
| 2275 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2276 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
| 2277 | enum set_key_cmd cmd, |
| 2278 | struct ieee80211_vif *vif, |
| 2279 | struct ieee80211_sta *sta, |
| 2280 | struct ieee80211_key_conf *key) |
| 2281 | { |
| 2282 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2283 | int ret; |
| 2284 | |
| 2285 | if (iwlwifi_mod_params.sw_crypto) { |
| 2286 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); |
| 2287 | return -EOPNOTSUPP; |
| 2288 | } |
| 2289 | |
| 2290 | switch (key->cipher) { |
| 2291 | case WLAN_CIPHER_SUITE_TKIP: |
| 2292 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
| 2293 | /* fall-through */ |
| 2294 | case WLAN_CIPHER_SUITE_CCMP: |
| 2295 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
| 2296 | break; |
| 2297 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 2298 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); |
| 2299 | break; |
| 2300 | case WLAN_CIPHER_SUITE_WEP40: |
| 2301 | case WLAN_CIPHER_SUITE_WEP104: |
| 2302 | /* |
| 2303 | * Support for TX only, at least for now, so accept |
| 2304 | * the key and do nothing else. Then mac80211 will |
| 2305 | * pass it for TX but we don't have to use it for RX. |
| 2306 | */ |
| 2307 | return 0; |
| 2308 | default: |
Max Stepanov | e36e543 | 2013-08-27 19:56:13 +0300 | [diff] [blame] | 2309 | /* currently FW supports only one optional cipher scheme */ |
| 2310 | if (hw->n_cipher_schemes && |
| 2311 | hw->cipher_schemes->cipher == key->cipher) |
| 2312 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; |
| 2313 | else |
| 2314 | return -EOPNOTSUPP; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2315 | } |
| 2316 | |
| 2317 | mutex_lock(&mvm->mutex); |
| 2318 | |
| 2319 | switch (cmd) { |
| 2320 | case SET_KEY: |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 2321 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 2322 | vif->type == NL80211_IFTYPE_AP) && !sta) { |
| 2323 | /* |
| 2324 | * GTK on AP interface is a TX-only key, return 0; |
| 2325 | * on IBSS they're per-station and because we're lazy |
| 2326 | * we don't support them for RX, so do the same. |
| 2327 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 2328 | ret = 0; |
| 2329 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
| 2330 | break; |
| 2331 | } |
| 2332 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2333 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
| 2334 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); |
| 2335 | if (ret) { |
| 2336 | IWL_WARN(mvm, "set key failed\n"); |
| 2337 | /* |
| 2338 | * can't add key for RX, but we don't need it |
| 2339 | * in the device for TX so still return 0 |
| 2340 | */ |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 2341 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2342 | ret = 0; |
| 2343 | } |
| 2344 | |
| 2345 | break; |
| 2346 | case DISABLE_KEY: |
Johannes Berg | 6caffd4 | 2013-03-06 13:15:21 +0100 | [diff] [blame] | 2347 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
| 2348 | ret = 0; |
| 2349 | break; |
| 2350 | } |
| 2351 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2352 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
| 2353 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); |
| 2354 | break; |
| 2355 | default: |
| 2356 | ret = -EINVAL; |
| 2357 | } |
| 2358 | |
| 2359 | mutex_unlock(&mvm->mutex); |
| 2360 | return ret; |
| 2361 | } |
| 2362 | |
| 2363 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 2364 | struct ieee80211_vif *vif, |
| 2365 | struct ieee80211_key_conf *keyconf, |
| 2366 | struct ieee80211_sta *sta, |
| 2367 | u32 iv32, u16 *phase1key) |
| 2368 | { |
| 2369 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2370 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 2371 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
| 2372 | return; |
| 2373 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2374 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
| 2375 | } |
| 2376 | |
| 2377 | |
Ariej Marjieh | b112889 | 2014-07-16 21:11:12 +0300 | [diff] [blame] | 2378 | static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data *notif_wait, |
| 2379 | struct iwl_rx_packet *pkt, void *data) |
| 2380 | { |
| 2381 | struct iwl_mvm *mvm = |
| 2382 | container_of(notif_wait, struct iwl_mvm, notif_wait); |
| 2383 | struct iwl_hs20_roc_res *resp; |
| 2384 | int resp_len = iwl_rx_packet_payload_len(pkt); |
| 2385 | struct iwl_mvm_time_event_data *te_data = data; |
| 2386 | |
| 2387 | if (WARN_ON(pkt->hdr.cmd != HOT_SPOT_CMD)) |
| 2388 | return true; |
| 2389 | |
| 2390 | if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { |
| 2391 | IWL_ERR(mvm, "Invalid HOT_SPOT_CMD response\n"); |
| 2392 | return true; |
| 2393 | } |
| 2394 | |
| 2395 | resp = (void *)pkt->data; |
| 2396 | |
| 2397 | IWL_DEBUG_TE(mvm, |
| 2398 | "Aux ROC: Recieved response from ucode: status=%d uid=%d\n", |
| 2399 | resp->status, resp->event_unique_id); |
| 2400 | |
| 2401 | te_data->uid = le32_to_cpu(resp->event_unique_id); |
| 2402 | IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n", |
| 2403 | te_data->uid); |
| 2404 | |
| 2405 | spin_lock_bh(&mvm->time_event_lock); |
| 2406 | list_add_tail(&te_data->list, &mvm->aux_roc_te_list); |
| 2407 | spin_unlock_bh(&mvm->time_event_lock); |
| 2408 | |
| 2409 | return true; |
| 2410 | } |
| 2411 | |
| 2412 | #define AUX_ROC_MAX_DELAY_ON_CHANNEL 5000 |
| 2413 | static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm, |
| 2414 | struct ieee80211_channel *channel, |
| 2415 | struct ieee80211_vif *vif, |
| 2416 | int duration) |
| 2417 | { |
| 2418 | int res, time_reg = DEVICE_SYSTEM_TIME_REG; |
| 2419 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2420 | struct iwl_mvm_time_event_data *te_data = &mvmvif->hs_time_event_data; |
| 2421 | static const u8 time_event_response[] = { HOT_SPOT_CMD }; |
| 2422 | struct iwl_notification_wait wait_time_event; |
| 2423 | struct iwl_hs20_roc_req aux_roc_req = { |
| 2424 | .action = cpu_to_le32(FW_CTXT_ACTION_ADD), |
| 2425 | .id_and_color = |
| 2426 | cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)), |
| 2427 | .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id), |
| 2428 | /* Set the channel info data */ |
| 2429 | .channel_info.band = (channel->band == IEEE80211_BAND_2GHZ) ? |
| 2430 | PHY_BAND_24 : PHY_BAND_5, |
| 2431 | .channel_info.channel = channel->hw_value, |
| 2432 | .channel_info.width = PHY_VHT_CHANNEL_MODE20, |
| 2433 | /* Set the time and duration */ |
| 2434 | .apply_time = cpu_to_le32(iwl_read_prph(mvm->trans, time_reg)), |
| 2435 | .apply_time_max_delay = |
| 2436 | cpu_to_le32(MSEC_TO_TU(AUX_ROC_MAX_DELAY_ON_CHANNEL)), |
| 2437 | .duration = cpu_to_le32(MSEC_TO_TU(duration)), |
| 2438 | }; |
| 2439 | |
| 2440 | /* Set the node address */ |
| 2441 | memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN); |
| 2442 | |
Matti Gottlieb | a6cc516 | 2014-09-29 11:46:04 +0300 | [diff] [blame] | 2443 | lockdep_assert_held(&mvm->mutex); |
| 2444 | |
| 2445 | spin_lock_bh(&mvm->time_event_lock); |
| 2446 | |
| 2447 | if (WARN_ON(te_data->id == HOT_SPOT_CMD)) { |
| 2448 | spin_unlock_bh(&mvm->time_event_lock); |
| 2449 | return -EIO; |
| 2450 | } |
| 2451 | |
Ariej Marjieh | b112889 | 2014-07-16 21:11:12 +0300 | [diff] [blame] | 2452 | te_data->vif = vif; |
| 2453 | te_data->duration = duration; |
| 2454 | te_data->id = HOT_SPOT_CMD; |
| 2455 | |
Ariej Marjieh | b112889 | 2014-07-16 21:11:12 +0300 | [diff] [blame] | 2456 | spin_unlock_bh(&mvm->time_event_lock); |
| 2457 | |
| 2458 | /* |
| 2459 | * Use a notification wait, which really just processes the |
| 2460 | * command response and doesn't wait for anything, in order |
| 2461 | * to be able to process the response and get the UID inside |
| 2462 | * the RX path. Using CMD_WANT_SKB doesn't work because it |
| 2463 | * stores the buffer and then wakes up this thread, by which |
| 2464 | * time another notification (that the time event started) |
| 2465 | * might already be processed unsuccessfully. |
| 2466 | */ |
| 2467 | iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event, |
| 2468 | time_event_response, |
| 2469 | ARRAY_SIZE(time_event_response), |
| 2470 | iwl_mvm_rx_aux_roc, te_data); |
| 2471 | |
| 2472 | res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, sizeof(aux_roc_req), |
| 2473 | &aux_roc_req); |
| 2474 | |
| 2475 | if (res) { |
| 2476 | IWL_ERR(mvm, "Couldn't send HOT_SPOT_CMD: %d\n", res); |
| 2477 | iwl_remove_notification(&mvm->notif_wait, &wait_time_event); |
| 2478 | goto out_clear_te; |
| 2479 | } |
| 2480 | |
| 2481 | /* No need to wait for anything, so just pass 1 (0 isn't valid) */ |
| 2482 | res = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1); |
| 2483 | /* should never fail */ |
| 2484 | WARN_ON_ONCE(res); |
| 2485 | |
| 2486 | if (res) { |
| 2487 | out_clear_te: |
| 2488 | spin_lock_bh(&mvm->time_event_lock); |
| 2489 | iwl_mvm_te_clear_data(mvm, te_data); |
| 2490 | spin_unlock_bh(&mvm->time_event_lock); |
| 2491 | } |
| 2492 | |
| 2493 | return res; |
| 2494 | } |
| 2495 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2496 | static int iwl_mvm_roc(struct ieee80211_hw *hw, |
| 2497 | struct ieee80211_vif *vif, |
| 2498 | struct ieee80211_channel *channel, |
Ilan Peer | d339d5c | 2013-02-12 09:34:13 +0200 | [diff] [blame] | 2499 | int duration, |
| 2500 | enum ieee80211_roc_type type) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2501 | { |
| 2502 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2503 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2504 | struct cfg80211_chan_def chandef; |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 2505 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
| 2506 | int ret, i; |
| 2507 | |
| 2508 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, |
| 2509 | duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2510 | |
Matti Gottlieb | a6cc516 | 2014-09-29 11:46:04 +0300 | [diff] [blame] | 2511 | mutex_lock(&mvm->mutex); |
| 2512 | |
Ariej Marjieh | b112889 | 2014-07-16 21:11:12 +0300 | [diff] [blame] | 2513 | switch (vif->type) { |
| 2514 | case NL80211_IFTYPE_STATION: |
| 2515 | /* Use aux roc framework (HS20) */ |
| 2516 | ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, |
| 2517 | vif, duration); |
Matti Gottlieb | a6cc516 | 2014-09-29 11:46:04 +0300 | [diff] [blame] | 2518 | goto out_unlock; |
Ariej Marjieh | b112889 | 2014-07-16 21:11:12 +0300 | [diff] [blame] | 2519 | case NL80211_IFTYPE_P2P_DEVICE: |
| 2520 | /* handle below */ |
| 2521 | break; |
| 2522 | default: |
| 2523 | IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type); |
Matti Gottlieb | a6cc516 | 2014-09-29 11:46:04 +0300 | [diff] [blame] | 2524 | ret = -EINVAL; |
| 2525 | goto out_unlock; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2526 | } |
| 2527 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 2528 | for (i = 0; i < NUM_PHY_CTX; i++) { |
| 2529 | phy_ctxt = &mvm->phy_ctxts[i]; |
| 2530 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) |
| 2531 | continue; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2532 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 2533 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { |
| 2534 | /* |
| 2535 | * Unbind the P2P_DEVICE from the current PHY context, |
| 2536 | * and if the PHY context is not used remove it. |
| 2537 | */ |
| 2538 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 2539 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 2540 | goto out_unlock; |
| 2541 | |
| 2542 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 2543 | |
| 2544 | /* Bind the P2P_DEVICE to the current PHY Context */ |
| 2545 | mvmvif->phy_ctxt = phy_ctxt; |
| 2546 | |
| 2547 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 2548 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 2549 | goto out_unlock; |
| 2550 | |
| 2551 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 2552 | goto schedule_time_event; |
| 2553 | } |
| 2554 | } |
| 2555 | |
| 2556 | /* Need to update the PHY context only if the ROC channel changed */ |
| 2557 | if (channel == mvmvif->phy_ctxt->channel) |
| 2558 | goto schedule_time_event; |
| 2559 | |
| 2560 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
| 2561 | |
| 2562 | /* |
| 2563 | * Change the PHY context configuration as it is currently referenced |
| 2564 | * only by the P2P Device MAC |
| 2565 | */ |
| 2566 | if (mvmvif->phy_ctxt->ref == 1) { |
| 2567 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, |
| 2568 | &chandef, 1, 1); |
| 2569 | if (ret) |
| 2570 | goto out_unlock; |
| 2571 | } else { |
| 2572 | /* |
| 2573 | * The PHY context is shared with other MACs. Need to remove the |
| 2574 | * P2P Device from the binding, allocate an new PHY context and |
| 2575 | * create a new binding |
| 2576 | */ |
| 2577 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 2578 | if (!phy_ctxt) { |
| 2579 | ret = -ENOSPC; |
| 2580 | goto out_unlock; |
| 2581 | } |
| 2582 | |
| 2583 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, |
| 2584 | 1, 1); |
| 2585 | if (ret) { |
| 2586 | IWL_ERR(mvm, "Failed to change PHY context\n"); |
| 2587 | goto out_unlock; |
| 2588 | } |
| 2589 | |
| 2590 | /* Unbind the P2P_DEVICE from the current PHY context */ |
| 2591 | ret = iwl_mvm_binding_remove_vif(mvm, vif); |
| 2592 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) |
| 2593 | goto out_unlock; |
| 2594 | |
| 2595 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
| 2596 | |
| 2597 | /* Bind the P2P_DEVICE to the new allocated PHY context */ |
| 2598 | mvmvif->phy_ctxt = phy_ctxt; |
| 2599 | |
| 2600 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 2601 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) |
| 2602 | goto out_unlock; |
| 2603 | |
| 2604 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
| 2605 | } |
| 2606 | |
| 2607 | schedule_time_event: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2608 | /* Schedule the time events */ |
Ilan Peer | e635c79 | 2013-02-13 11:05:18 +0200 | [diff] [blame] | 2609 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2610 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 2611 | out_unlock: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2612 | mutex_unlock(&mvm->mutex); |
| 2613 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2614 | return ret; |
| 2615 | } |
| 2616 | |
| 2617 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) |
| 2618 | { |
| 2619 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2620 | |
| 2621 | IWL_DEBUG_MAC80211(mvm, "enter\n"); |
| 2622 | |
| 2623 | mutex_lock(&mvm->mutex); |
| 2624 | iwl_mvm_stop_p2p_roc(mvm); |
| 2625 | mutex_unlock(&mvm->mutex); |
| 2626 | |
| 2627 | IWL_DEBUG_MAC80211(mvm, "leave\n"); |
| 2628 | return 0; |
| 2629 | } |
| 2630 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2631 | static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm, |
| 2632 | struct ieee80211_chanctx_conf *ctx) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2633 | { |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2634 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 2635 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2636 | int ret; |
| 2637 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2638 | lockdep_assert_held(&mvm->mutex); |
| 2639 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 2640 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2641 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2642 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
| 2643 | if (!phy_ctxt) { |
| 2644 | ret = -ENOSPC; |
| 2645 | goto out; |
| 2646 | } |
| 2647 | |
Eliad Peller | dcbc3e1 | 2013-10-31 14:31:25 +0200 | [diff] [blame] | 2648 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 2649 | ctx->rx_chains_static, |
| 2650 | ctx->rx_chains_dynamic); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2651 | if (ret) { |
| 2652 | IWL_ERR(mvm, "Failed to add PHY context\n"); |
| 2653 | goto out; |
| 2654 | } |
| 2655 | |
Ilan Peer | 53a9d61 | 2013-04-28 11:55:08 +0300 | [diff] [blame] | 2656 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2657 | *phy_ctxt_id = phy_ctxt->id; |
| 2658 | out: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2659 | return ret; |
| 2660 | } |
| 2661 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2662 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, |
| 2663 | struct ieee80211_chanctx_conf *ctx) |
| 2664 | { |
| 2665 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2666 | int ret; |
| 2667 | |
| 2668 | mutex_lock(&mvm->mutex); |
| 2669 | ret = __iwl_mvm_add_chanctx(mvm, ctx); |
| 2670 | mutex_unlock(&mvm->mutex); |
| 2671 | |
| 2672 | return ret; |
| 2673 | } |
| 2674 | |
| 2675 | static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm, |
| 2676 | struct ieee80211_chanctx_conf *ctx) |
| 2677 | { |
| 2678 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 2679 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; |
| 2680 | |
| 2681 | lockdep_assert_held(&mvm->mutex); |
| 2682 | |
| 2683 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
| 2684 | } |
| 2685 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2686 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
| 2687 | struct ieee80211_chanctx_conf *ctx) |
| 2688 | { |
| 2689 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2690 | |
| 2691 | mutex_lock(&mvm->mutex); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2692 | __iwl_mvm_remove_chanctx(mvm, ctx); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2693 | mutex_unlock(&mvm->mutex); |
| 2694 | } |
| 2695 | |
| 2696 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, |
| 2697 | struct ieee80211_chanctx_conf *ctx, |
| 2698 | u32 changed) |
| 2699 | { |
| 2700 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2701 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 2702 | 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] | 2703 | |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 2704 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
| 2705 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | |
| 2706 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | |
Arik Nemtsov | 2dceeda | 2013-12-29 17:57:53 +0200 | [diff] [blame] | 2707 | IEEE80211_CHANCTX_CHANGE_RADAR | |
| 2708 | IEEE80211_CHANCTX_CHANGE_MIN_WIDTH)), |
Ilan Peer | 31d385a | 2013-04-02 10:25:46 +0300 | [diff] [blame] | 2709 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
| 2710 | phy_ctxt->ref, changed)) |
| 2711 | return; |
| 2712 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2713 | mutex_lock(&mvm->mutex); |
Emmanuel Grumbach | 4d66449 | 2014-04-30 18:09:59 +0300 | [diff] [blame] | 2714 | iwl_mvm_bt_coex_vif_change(mvm); |
Eliad Peller | dcbc3e1 | 2013-10-31 14:31:25 +0200 | [diff] [blame] | 2715 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2716 | ctx->rx_chains_static, |
| 2717 | ctx->rx_chains_dynamic); |
| 2718 | mutex_unlock(&mvm->mutex); |
| 2719 | } |
| 2720 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2721 | static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm, |
| 2722 | struct ieee80211_vif *vif, |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2723 | struct ieee80211_chanctx_conf *ctx, |
| 2724 | bool switching_chanctx) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2725 | { |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2726 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
| 2727 | 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] | 2728 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 2729 | int ret; |
| 2730 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2731 | lockdep_assert_held(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2732 | |
Ilan Peer | fe0f2de | 2013-03-21 10:23:52 +0200 | [diff] [blame] | 2733 | mvmvif->phy_ctxt = phy_ctxt; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2734 | |
| 2735 | switch (vif->type) { |
| 2736 | case NL80211_IFTYPE_AP: |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 2737 | /* Unless it's a CSA flow we have nothing to do here */ |
| 2738 | if (vif->csa_active) { |
| 2739 | mvmvif->ap_ibss_active = true; |
| 2740 | break; |
| 2741 | } |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 2742 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2743 | /* |
| 2744 | * 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] | 2745 | * (in bss_info_changed), similarly for IBSS. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2746 | */ |
| 2747 | ret = 0; |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2748 | goto out; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2749 | case NL80211_IFTYPE_STATION: |
Luciano Coelho | 2533edc | 2014-08-08 19:50:46 +0300 | [diff] [blame] | 2750 | break; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2751 | case NL80211_IFTYPE_MONITOR: |
Luciano Coelho | 2533edc | 2014-08-08 19:50:46 +0300 | [diff] [blame] | 2752 | /* always disable PS when a monitor interface is active */ |
| 2753 | mvmvif->ps_disabled = true; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2754 | break; |
| 2755 | default: |
| 2756 | ret = -EINVAL; |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2757 | goto out; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2758 | } |
| 2759 | |
| 2760 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
| 2761 | if (ret) |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2762 | goto out; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2763 | |
| 2764 | /* |
Alexander Bondar | 92d8556 | 2013-10-23 11:50:34 +0200 | [diff] [blame] | 2765 | * Power state must be updated before quotas, |
| 2766 | * otherwise fw will complain. |
| 2767 | */ |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 2768 | iwl_mvm_power_update_mac(mvm); |
Alexander Bondar | 92d8556 | 2013-10-23 11:50:34 +0200 | [diff] [blame] | 2769 | |
| 2770 | /* Setting the quota at this stage is only required for monitor |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2771 | * interfaces. For the other types, the bss_info changed flow |
| 2772 | * will handle quota settings. |
| 2773 | */ |
| 2774 | if (vif->type == NL80211_IFTYPE_MONITOR) { |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 2775 | mvmvif->monitor_active = true; |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 2776 | ret = iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2777 | if (ret) |
| 2778 | goto out_remove_binding; |
| 2779 | } |
| 2780 | |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 2781 | /* Handle binding during CSA */ |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2782 | if ((vif->type == NL80211_IFTYPE_AP) || |
| 2783 | (switching_chanctx && (vif->type == NL80211_IFTYPE_STATION))) { |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 2784 | iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 2785 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 2786 | } |
| 2787 | |
Luciano Coelho | 0ce04ce | 2014-05-08 16:03:39 +0300 | [diff] [blame] | 2788 | if (vif->csa_active && vif->type == NL80211_IFTYPE_STATION) { |
| 2789 | struct iwl_mvm_sta *mvmsta; |
| 2790 | |
| 2791 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, |
| 2792 | mvmvif->ap_sta_id); |
| 2793 | |
| 2794 | if (WARN_ON(!mvmsta)) |
| 2795 | goto out; |
| 2796 | |
| 2797 | /* TODO: only re-enable after the first beacon */ |
| 2798 | iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false); |
| 2799 | } |
| 2800 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2801 | goto out; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2802 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2803 | out_remove_binding: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2804 | iwl_mvm_binding_remove_vif(mvm, vif); |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 2805 | iwl_mvm_power_update_mac(mvm); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2806 | out: |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2807 | if (ret) |
| 2808 | mvmvif->phy_ctxt = NULL; |
| 2809 | return ret; |
| 2810 | } |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2811 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 2812 | struct ieee80211_vif *vif, |
| 2813 | struct ieee80211_chanctx_conf *ctx) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2814 | { |
| 2815 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2816 | int ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2817 | |
| 2818 | mutex_lock(&mvm->mutex); |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2819 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vif, ctx, false); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2820 | mutex_unlock(&mvm->mutex); |
| 2821 | |
| 2822 | return ret; |
| 2823 | } |
| 2824 | |
| 2825 | static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm, |
| 2826 | struct ieee80211_vif *vif, |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2827 | struct ieee80211_chanctx_conf *ctx, |
| 2828 | bool switching_chanctx) |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2829 | { |
| 2830 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2831 | struct ieee80211_vif *disabled_vif = NULL; |
Luciano Coelho | 0ce04ce | 2014-05-08 16:03:39 +0300 | [diff] [blame] | 2832 | struct iwl_mvm_sta *mvmsta; |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2833 | |
| 2834 | lockdep_assert_held(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2835 | |
| 2836 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); |
| 2837 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2838 | switch (vif->type) { |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 2839 | case NL80211_IFTYPE_ADHOC: |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2840 | goto out; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2841 | case NL80211_IFTYPE_MONITOR: |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 2842 | mvmvif->monitor_active = false; |
Luciano Coelho | 2533edc | 2014-08-08 19:50:46 +0300 | [diff] [blame] | 2843 | mvmvif->ps_disabled = false; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2844 | break; |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 2845 | case NL80211_IFTYPE_AP: |
| 2846 | /* This part is triggered only during CSA */ |
| 2847 | if (!vif->csa_active || !mvmvif->ap_ibss_active) |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2848 | goto out; |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 2849 | |
Andrei Otcheretianski | 003e5236 | 2014-05-25 17:24:22 +0300 | [diff] [blame] | 2850 | /* Set CS bit on all the stations */ |
| 2851 | iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true); |
| 2852 | |
| 2853 | /* Save blocked iface, the timeout is set on the next beacon */ |
| 2854 | rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif); |
| 2855 | |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 2856 | mvmvif->ap_ibss_active = false; |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2857 | break; |
| 2858 | case NL80211_IFTYPE_STATION: |
| 2859 | if (!switching_chanctx) |
| 2860 | break; |
| 2861 | |
| 2862 | disabled_vif = vif; |
| 2863 | |
Luciano Coelho | 0ce04ce | 2014-05-08 16:03:39 +0300 | [diff] [blame] | 2864 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, |
| 2865 | mvmvif->ap_sta_id); |
| 2866 | |
| 2867 | if (!WARN_ON(!mvmsta)) |
| 2868 | iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, true); |
| 2869 | |
Johannes Berg | 3dfd3a9 | 2014-08-11 21:37:30 +0200 | [diff] [blame] | 2870 | iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL); |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2871 | break; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2872 | default: |
| 2873 | break; |
| 2874 | } |
| 2875 | |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2876 | iwl_mvm_update_quotas(mvm, disabled_vif); |
Ilan Peer | 1e1391c | 2013-03-13 14:52:04 +0200 | [diff] [blame] | 2877 | iwl_mvm_binding_remove_vif(mvm, vif); |
Alexander Bondar | 1c2abf7 | 2013-08-27 20:31:48 +0300 | [diff] [blame] | 2878 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2879 | out: |
Ilan Peer | a11e144 | 2013-12-31 21:19:55 +0200 | [diff] [blame] | 2880 | mvmvif->phy_ctxt = NULL; |
Arik Nemtsov | 999609f | 2014-05-15 17:31:51 +0300 | [diff] [blame] | 2881 | iwl_mvm_power_update_mac(mvm); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2882 | } |
| 2883 | |
| 2884 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 2885 | struct ieee80211_vif *vif, |
| 2886 | struct ieee80211_chanctx_conf *ctx) |
| 2887 | { |
| 2888 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2889 | |
| 2890 | mutex_lock(&mvm->mutex); |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2891 | __iwl_mvm_unassign_vif_chanctx(mvm, vif, ctx, false); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2892 | mutex_unlock(&mvm->mutex); |
| 2893 | } |
| 2894 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2895 | static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw *hw, |
| 2896 | struct ieee80211_vif_chanctx_switch *vifs, |
| 2897 | int n_vifs, |
| 2898 | enum ieee80211_chanctx_switch_mode mode) |
| 2899 | { |
| 2900 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2901 | int ret; |
| 2902 | |
| 2903 | /* we only support SWAP_CONTEXTS and with a single-vif right now */ |
| 2904 | if (mode != CHANCTX_SWMODE_SWAP_CONTEXTS || n_vifs > 1) |
| 2905 | return -EOPNOTSUPP; |
| 2906 | |
| 2907 | mutex_lock(&mvm->mutex); |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2908 | __iwl_mvm_unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2909 | __iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx); |
| 2910 | |
| 2911 | ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx); |
| 2912 | if (ret) { |
| 2913 | IWL_ERR(mvm, "failed to add new_ctx during channel switch\n"); |
| 2914 | goto out_reassign; |
| 2915 | } |
| 2916 | |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2917 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx, |
| 2918 | true); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2919 | if (ret) { |
| 2920 | IWL_ERR(mvm, |
| 2921 | "failed to assign new_ctx during channel switch\n"); |
| 2922 | goto out_remove; |
| 2923 | } |
| 2924 | |
Arik Nemtsov | f697267 | 2014-06-15 16:03:55 +0300 | [diff] [blame] | 2925 | /* we don't support TDLS during DCM - can be caused by channel switch */ |
| 2926 | if (iwl_mvm_phy_ctx_count(mvm) > 1) |
| 2927 | iwl_mvm_teardown_tdls_peers(mvm); |
| 2928 | |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2929 | goto out; |
| 2930 | |
| 2931 | out_remove: |
| 2932 | __iwl_mvm_remove_chanctx(mvm, vifs[0].new_ctx); |
| 2933 | |
| 2934 | out_reassign: |
| 2935 | ret = __iwl_mvm_add_chanctx(mvm, vifs[0].old_ctx); |
| 2936 | if (ret) { |
| 2937 | IWL_ERR(mvm, "failed to add old_ctx back after failure.\n"); |
| 2938 | goto out_restart; |
| 2939 | } |
| 2940 | |
Luciano Coelho | f0c9778 | 2014-03-05 15:41:48 +0200 | [diff] [blame] | 2941 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, |
| 2942 | true); |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 2943 | if (ret) { |
| 2944 | IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n"); |
| 2945 | goto out_restart; |
| 2946 | } |
| 2947 | |
| 2948 | goto out; |
| 2949 | |
| 2950 | out_restart: |
| 2951 | /* things keep failing, better restart the hw */ |
| 2952 | iwl_mvm_nic_restart(mvm, false); |
| 2953 | |
| 2954 | out: |
| 2955 | mutex_unlock(&mvm->mutex); |
| 2956 | return ret; |
| 2957 | } |
| 2958 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 2959 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, |
| 2960 | struct ieee80211_sta *sta, |
| 2961 | bool set) |
| 2962 | { |
| 2963 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 2964 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; |
| 2965 | |
| 2966 | if (!mvm_sta || !mvm_sta->vif) { |
| 2967 | IWL_ERR(mvm, "Station is not associated to a vif\n"); |
| 2968 | return -EINVAL; |
| 2969 | } |
| 2970 | |
| 2971 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); |
| 2972 | } |
| 2973 | |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 2974 | #ifdef CONFIG_NL80211_TESTMODE |
| 2975 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { |
| 2976 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 2977 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, |
Johannes Berg | f6c6ad42 | 2013-08-01 14:17:15 +0200 | [diff] [blame] | 2978 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 2979 | }; |
| 2980 | |
| 2981 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, |
| 2982 | struct ieee80211_vif *vif, |
| 2983 | void *data, int len) |
| 2984 | { |
| 2985 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; |
| 2986 | int err; |
| 2987 | u32 noa_duration; |
| 2988 | |
| 2989 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy); |
| 2990 | if (err) |
| 2991 | return err; |
| 2992 | |
| 2993 | if (!tb[IWL_MVM_TM_ATTR_CMD]) |
| 2994 | return -EINVAL; |
| 2995 | |
| 2996 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { |
| 2997 | case IWL_MVM_TM_CMD_SET_NOA: |
| 2998 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || |
| 2999 | !vif->bss_conf.enable_beacon || |
| 3000 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) |
| 3001 | return -EINVAL; |
| 3002 | |
| 3003 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); |
| 3004 | if (noa_duration >= vif->bss_conf.beacon_int) |
| 3005 | return -EINVAL; |
| 3006 | |
| 3007 | mvm->noa_duration = noa_duration; |
| 3008 | mvm->noa_vif = vif; |
| 3009 | |
Johannes Berg | 0166230 | 2014-06-06 15:18:45 +0200 | [diff] [blame] | 3010 | return iwl_mvm_update_quotas(mvm, NULL); |
Johannes Berg | f6c6ad42 | 2013-08-01 14:17:15 +0200 | [diff] [blame] | 3011 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
| 3012 | /* must be associated client vif - ignore authorized */ |
| 3013 | if (!vif || vif->type != NL80211_IFTYPE_STATION || |
| 3014 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || |
| 3015 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) |
| 3016 | return -EINVAL; |
| 3017 | |
| 3018 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 3019 | return iwl_mvm_enable_beacon_filter(mvm, vif, 0); |
| 3020 | return iwl_mvm_disable_beacon_filter(mvm, vif, 0); |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 3021 | } |
| 3022 | |
| 3023 | return -EOPNOTSUPP; |
| 3024 | } |
| 3025 | |
| 3026 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, |
| 3027 | struct ieee80211_vif *vif, |
| 3028 | void *data, int len) |
| 3029 | { |
| 3030 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3031 | int err; |
| 3032 | |
| 3033 | mutex_lock(&mvm->mutex); |
| 3034 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); |
| 3035 | mutex_unlock(&mvm->mutex); |
| 3036 | |
| 3037 | return err; |
| 3038 | } |
| 3039 | #endif |
| 3040 | |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 3041 | static void iwl_mvm_channel_switch_beacon(struct ieee80211_hw *hw, |
| 3042 | struct ieee80211_vif *vif, |
| 3043 | struct cfg80211_chan_def *chandef) |
| 3044 | { |
| 3045 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
Andrei Otcheretianski | 664322f | 2014-06-05 16:40:36 +0300 | [diff] [blame] | 3046 | struct ieee80211_vif *csa_vif; |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 3047 | |
| 3048 | mutex_lock(&mvm->mutex); |
Andrei Otcheretianski | 664322f | 2014-06-05 16:40:36 +0300 | [diff] [blame] | 3049 | |
| 3050 | csa_vif = rcu_dereference_protected(mvm->csa_vif, |
| 3051 | lockdep_is_held(&mvm->mutex)); |
| 3052 | if (WARN(csa_vif && csa_vif->csa_active, |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 3053 | "Another CSA is already in progress")) |
| 3054 | goto out_unlock; |
| 3055 | |
| 3056 | IWL_DEBUG_MAC80211(mvm, "CSA started to freq %d\n", |
| 3057 | chandef->center_freq1); |
Andrei Otcheretianski | 664322f | 2014-06-05 16:40:36 +0300 | [diff] [blame] | 3058 | rcu_assign_pointer(mvm->csa_vif, vif); |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 3059 | |
| 3060 | out_unlock: |
| 3061 | mutex_unlock(&mvm->mutex); |
| 3062 | } |
| 3063 | |
Emmanuel Grumbach | c5b0e7c | 2014-03-24 12:08:53 +0200 | [diff] [blame] | 3064 | static void iwl_mvm_mac_flush(struct ieee80211_hw *hw, |
| 3065 | struct ieee80211_vif *vif, u32 queues, bool drop) |
| 3066 | { |
| 3067 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
| 3068 | struct iwl_mvm_vif *mvmvif; |
| 3069 | struct iwl_mvm_sta *mvmsta; |
| 3070 | |
| 3071 | if (!vif || vif->type != NL80211_IFTYPE_STATION) |
| 3072 | return; |
| 3073 | |
| 3074 | mutex_lock(&mvm->mutex); |
| 3075 | mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 3076 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, mvmvif->ap_sta_id); |
| 3077 | |
Johannes Berg | 480acbc | 2014-10-10 08:59:27 +0200 | [diff] [blame] | 3078 | if (WARN_ON_ONCE(!mvmsta)) { |
| 3079 | mutex_unlock(&mvm->mutex); |
| 3080 | return; |
| 3081 | } |
Emmanuel Grumbach | c5b0e7c | 2014-03-24 12:08:53 +0200 | [diff] [blame] | 3082 | |
| 3083 | if (drop) { |
| 3084 | if (iwl_mvm_flush_tx_path(mvm, mvmsta->tfd_queue_msk, true)) |
| 3085 | IWL_ERR(mvm, "flush request fail\n"); |
Johannes Berg | 480acbc | 2014-10-10 08:59:27 +0200 | [diff] [blame] | 3086 | mutex_unlock(&mvm->mutex); |
Emmanuel Grumbach | c5b0e7c | 2014-03-24 12:08:53 +0200 | [diff] [blame] | 3087 | } else { |
Johannes Berg | 480acbc | 2014-10-10 08:59:27 +0200 | [diff] [blame] | 3088 | u32 tfd_queue_msk = mvmsta->tfd_queue_msk; |
| 3089 | mutex_unlock(&mvm->mutex); |
| 3090 | |
| 3091 | /* this can take a while, and we may need/want other operations |
| 3092 | * to succeed while doing this, so do it without the mutex held |
| 3093 | */ |
| 3094 | iwl_trans_wait_tx_queue_empty(mvm->trans, tfd_queue_msk); |
Emmanuel Grumbach | c5b0e7c | 2014-03-24 12:08:53 +0200 | [diff] [blame] | 3095 | } |
Emmanuel Grumbach | c5b0e7c | 2014-03-24 12:08:53 +0200 | [diff] [blame] | 3096 | } |
| 3097 | |
Johannes Berg | e520926 | 2014-01-20 23:38:59 +0100 | [diff] [blame] | 3098 | const struct ieee80211_ops iwl_mvm_hw_ops = { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3099 | .tx = iwl_mvm_mac_tx, |
| 3100 | .ampdu_action = iwl_mvm_mac_ampdu_action, |
| 3101 | .start = iwl_mvm_mac_start, |
Eliad Peller | cf2c92d | 2014-11-04 11:43:54 +0200 | [diff] [blame] | 3102 | .reconfig_complete = iwl_mvm_mac_reconfig_complete, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3103 | .stop = iwl_mvm_mac_stop, |
| 3104 | .add_interface = iwl_mvm_mac_add_interface, |
| 3105 | .remove_interface = iwl_mvm_mac_remove_interface, |
| 3106 | .config = iwl_mvm_mac_config, |
Eliad Peller | e59647e | 2013-11-28 14:08:50 +0200 | [diff] [blame] | 3107 | .prepare_multicast = iwl_mvm_prepare_multicast, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3108 | .configure_filter = iwl_mvm_configure_filter, |
| 3109 | .bss_info_changed = iwl_mvm_bss_info_changed, |
| 3110 | .hw_scan = iwl_mvm_mac_hw_scan, |
| 3111 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, |
Johannes Berg | 1ddbbb0 | 2013-12-04 22:39:17 +0100 | [diff] [blame] | 3112 | .sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3113 | .sta_state = iwl_mvm_mac_sta_state, |
| 3114 | .sta_notify = iwl_mvm_mac_sta_notify, |
| 3115 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, |
Johannes Berg | 3e56ead | 2013-02-15 22:23:18 +0100 | [diff] [blame] | 3116 | .release_buffered_frames = iwl_mvm_mac_release_buffered_frames, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3117 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
Lilach Edelstein | 1f3b0ff | 2013-10-06 13:03:32 +0200 | [diff] [blame] | 3118 | .sta_rc_update = iwl_mvm_sta_rc_update, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3119 | .conf_tx = iwl_mvm_mac_conf_tx, |
| 3120 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, |
Arik Nemtsov | 07ecd89 | 2014-05-20 18:16:42 +0300 | [diff] [blame] | 3121 | .mgd_protect_tdls_discover = iwl_mvm_mac_mgd_protect_tdls_discover, |
Emmanuel Grumbach | c5b0e7c | 2014-03-24 12:08:53 +0200 | [diff] [blame] | 3122 | .flush = iwl_mvm_mac_flush, |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 3123 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
| 3124 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3125 | .set_key = iwl_mvm_mac_set_key, |
| 3126 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, |
| 3127 | .remain_on_channel = iwl_mvm_roc, |
| 3128 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3129 | .add_chanctx = iwl_mvm_add_chanctx, |
| 3130 | .remove_chanctx = iwl_mvm_remove_chanctx, |
| 3131 | .change_chanctx = iwl_mvm_change_chanctx, |
| 3132 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, |
| 3133 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, |
Luciano Coelho | b08c1d9 | 2014-05-20 23:31:05 +0300 | [diff] [blame] | 3134 | .switch_vif_chanctx = iwl_mvm_switch_vif_chanctx, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3135 | |
Johannes Berg | 5023d96 | 2013-07-31 14:07:43 +0200 | [diff] [blame] | 3136 | .start_ap = iwl_mvm_start_ap_ibss, |
| 3137 | .stop_ap = iwl_mvm_stop_ap_ibss, |
| 3138 | .join_ibss = iwl_mvm_start_ap_ibss, |
| 3139 | .leave_ibss = iwl_mvm_stop_ap_ibss, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3140 | |
| 3141 | .set_tim = iwl_mvm_set_tim, |
| 3142 | |
Andrei Otcheretianski | bd3398e | 2013-10-22 05:01:12 +0200 | [diff] [blame] | 3143 | .channel_switch_beacon = iwl_mvm_channel_switch_beacon, |
| 3144 | |
David Spinadel | 507cadf | 2013-07-31 18:07:21 +0300 | [diff] [blame] | 3145 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
| 3146 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 3147 | #ifdef CONFIG_PM_SLEEP |
| 3148 | /* look at d3.c */ |
| 3149 | .suspend = iwl_mvm_suspend, |
| 3150 | .resume = iwl_mvm_resume, |
| 3151 | .set_wakeup = iwl_mvm_set_wakeup, |
| 3152 | .set_rekey_data = iwl_mvm_set_rekey_data, |
| 3153 | #if IS_ENABLED(CONFIG_IPV6) |
| 3154 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, |
| 3155 | #endif |
| 3156 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, |
| 3157 | #endif |
| 3158 | }; |