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