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