Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 | * redistributing this file, you may do so under either license. |
| 5 | * |
| 6 | * GPL LICENSE SUMMARY |
| 7 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Johannes Berg | 8b4139d | 2014-07-24 14:05:26 +0200 | [diff] [blame] | 9 | * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of version 2 of the GNU General Public License as |
| 13 | * published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 23 | * USA |
| 24 | * |
| 25 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 26 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 27 | * |
| 28 | * Contact Information: |
| 29 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 30 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 31 | * |
| 32 | * BSD LICENSE |
| 33 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 34 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Johannes Berg | 8b4139d | 2014-07-24 14:05:26 +0200 | [diff] [blame] | 35 | * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 36 | * All rights reserved. |
| 37 | * |
| 38 | * Redistribution and use in source and binary forms, with or without |
| 39 | * modification, are permitted provided that the following conditions |
| 40 | * are met: |
| 41 | * |
| 42 | * * Redistributions of source code must retain the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer. |
| 44 | * * Redistributions in binary form must reproduce the above copyright |
| 45 | * notice, this list of conditions and the following disclaimer in |
| 46 | * the documentation and/or other materials provided with the |
| 47 | * distribution. |
| 48 | * * Neither the name Intel Corporation nor the names of its |
| 49 | * contributors may be used to endorse or promote products derived |
| 50 | * from this software without specific prior written permission. |
| 51 | * |
| 52 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 53 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 54 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 55 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 56 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 57 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 58 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 59 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 60 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 61 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 62 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 63 | * |
| 64 | *****************************************************************************/ |
| 65 | |
| 66 | #include <linux/etherdevice.h> |
| 67 | #include <net/mac80211.h> |
| 68 | |
| 69 | #include "mvm.h" |
| 70 | #include "iwl-eeprom-parse.h" |
| 71 | #include "fw-api-scan.h" |
| 72 | |
| 73 | #define IWL_PLCP_QUIET_THRESH 1 |
| 74 | #define IWL_ACTIVE_QUIET_TIME 10 |
Haim Dreyfuss | a1ed402 | 2014-12-01 23:30:07 +0200 | [diff] [blame] | 75 | #define IWL_DENSE_EBS_SCAN_RATIO 5 |
| 76 | #define IWL_SPARSE_EBS_SCAN_RATIO 1 |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 77 | |
| 78 | struct iwl_mvm_scan_params { |
| 79 | u32 max_out_time; |
| 80 | u32 suspend_time; |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 81 | bool passive_fragmented; |
| 82 | struct _dwell { |
| 83 | u16 passive; |
| 84 | u16 active; |
David Spinadel | 190f102 | 2015-02-17 12:45:21 +0200 | [diff] [blame] | 85 | u16 fragmented; |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 86 | } dwell[IEEE80211_NUM_BANDS]; |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 87 | }; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 88 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 89 | enum iwl_umac_scan_uid_type { |
| 90 | IWL_UMAC_SCAN_UID_REG_SCAN = BIT(0), |
| 91 | IWL_UMAC_SCAN_UID_SCHED_SCAN = BIT(1), |
| 92 | IWL_UMAC_SCAN_UID_ALL = IWL_UMAC_SCAN_UID_REG_SCAN | |
| 93 | IWL_UMAC_SCAN_UID_SCHED_SCAN, |
| 94 | }; |
| 95 | |
| 96 | static int iwl_umac_scan_stop(struct iwl_mvm *mvm, |
| 97 | enum iwl_umac_scan_uid_type type, bool notify); |
| 98 | |
| 99 | static u8 iwl_mvm_scan_rx_ant(struct iwl_mvm *mvm) |
| 100 | { |
| 101 | if (mvm->scan_rx_ant != ANT_NONE) |
| 102 | return mvm->scan_rx_ant; |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 103 | return iwl_mvm_get_valid_rx_ant(mvm); |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 104 | } |
| 105 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 106 | static inline __le16 iwl_mvm_scan_rx_chain(struct iwl_mvm *mvm) |
| 107 | { |
| 108 | u16 rx_chain; |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 109 | u8 rx_ant; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 110 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 111 | rx_ant = iwl_mvm_scan_rx_ant(mvm); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 112 | rx_chain = rx_ant << PHY_RX_CHAIN_VALID_POS; |
| 113 | rx_chain |= rx_ant << PHY_RX_CHAIN_FORCE_MIMO_SEL_POS; |
| 114 | rx_chain |= rx_ant << PHY_RX_CHAIN_FORCE_SEL_POS; |
| 115 | rx_chain |= 0x1 << PHY_RX_CHAIN_DRIVER_FORCE_POS; |
| 116 | return cpu_to_le16(rx_chain); |
| 117 | } |
| 118 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 119 | static __le32 iwl_mvm_scan_rxon_flags(enum ieee80211_band band) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 120 | { |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 121 | if (band == IEEE80211_BAND_2GHZ) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 122 | return cpu_to_le32(PHY_BAND_24); |
| 123 | else |
| 124 | return cpu_to_le32(PHY_BAND_5); |
| 125 | } |
| 126 | |
| 127 | static inline __le32 |
| 128 | iwl_mvm_scan_rate_n_flags(struct iwl_mvm *mvm, enum ieee80211_band band, |
| 129 | bool no_cck) |
| 130 | { |
| 131 | u32 tx_ant; |
| 132 | |
| 133 | mvm->scan_last_antenna_idx = |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 134 | iwl_mvm_next_antenna(mvm, iwl_mvm_get_valid_tx_ant(mvm), |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 135 | mvm->scan_last_antenna_idx); |
| 136 | tx_ant = BIT(mvm->scan_last_antenna_idx) << RATE_MCS_ANT_POS; |
| 137 | |
| 138 | if (band == IEEE80211_BAND_2GHZ && !no_cck) |
| 139 | return cpu_to_le32(IWL_RATE_1M_PLCP | RATE_MCS_CCK_MSK | |
| 140 | tx_ant); |
| 141 | else |
| 142 | return cpu_to_le32(IWL_RATE_6M_PLCP | tx_ant); |
| 143 | } |
| 144 | |
| 145 | /* |
| 146 | * We insert the SSIDs in an inverted order, because the FW will |
| 147 | * invert it back. The most prioritized SSID, which is first in the |
| 148 | * request list, is not copied here, but inserted directly to the probe |
| 149 | * request. |
| 150 | */ |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 151 | static void iwl_mvm_scan_fill_ssids(struct iwl_ssid_ie *cmd_ssid, |
| 152 | struct cfg80211_ssid *ssids, |
| 153 | int n_ssids, int first) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 154 | { |
| 155 | int fw_idx, req_idx; |
| 156 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 157 | for (req_idx = n_ssids - 1, fw_idx = 0; req_idx >= first; |
David Spinadel | fe04e83 | 2013-07-04 15:17:48 +0300 | [diff] [blame] | 158 | req_idx--, fw_idx++) { |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 159 | cmd_ssid[fw_idx].id = WLAN_EID_SSID; |
| 160 | cmd_ssid[fw_idx].len = ssids[req_idx].ssid_len; |
| 161 | memcpy(cmd_ssid[fw_idx].ssid, |
| 162 | ssids[req_idx].ssid, |
| 163 | ssids[req_idx].ssid_len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | * If req->n_ssids > 0, it means we should do an active scan. |
| 169 | * In case of active scan w/o directed scan, we receive a zero-length SSID |
| 170 | * just to notify that this scan is active and not passive. |
| 171 | * In order to notify the FW of the number of SSIDs we wish to scan (including |
| 172 | * the zero-length one), we need to set the corresponding bits in chan->type, |
David Spinadel | 20f1a5d | 2013-08-21 09:14:27 +0300 | [diff] [blame] | 173 | * one for each SSID, and set the active bit (first). If the first SSID is |
| 174 | * already included in the probe template, so we need to set only |
| 175 | * req->n_ssids - 1 bits in addition to the first bit. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 176 | */ |
David Spinadel | 3cae073 | 2014-12-29 15:43:48 +0200 | [diff] [blame] | 177 | static u16 iwl_mvm_get_active_dwell(struct iwl_mvm *mvm, |
| 178 | enum ieee80211_band band, int n_ssids) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 179 | { |
David Spinadel | 3cae073 | 2014-12-29 15:43:48 +0200 | [diff] [blame] | 180 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BASIC_DWELL) |
| 181 | return 10; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 182 | if (band == IEEE80211_BAND_2GHZ) |
David Spinadel | 3974533 | 2014-09-10 16:40:41 +0300 | [diff] [blame] | 183 | return 20 + 3 * (n_ssids + 1); |
| 184 | return 10 + 2 * (n_ssids + 1); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 185 | } |
| 186 | |
David Spinadel | 3cae073 | 2014-12-29 15:43:48 +0200 | [diff] [blame] | 187 | static u16 iwl_mvm_get_passive_dwell(struct iwl_mvm *mvm, |
| 188 | enum ieee80211_band band) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 189 | { |
David Spinadel | 3cae073 | 2014-12-29 15:43:48 +0200 | [diff] [blame] | 190 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BASIC_DWELL) |
| 191 | return 110; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 192 | return band == IEEE80211_BAND_2GHZ ? 100 + 20 : 100 + 10; |
| 193 | } |
| 194 | |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 195 | static void iwl_mvm_scan_condition_iterator(void *data, u8 *mac, |
| 196 | struct ieee80211_vif *vif) |
Haim Dreyfuss | 61f6325 | 2013-11-03 23:02:59 +0200 | [diff] [blame] | 197 | { |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 198 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Haim Dreyfuss | c3f8d0a | 2014-12-02 11:03:16 +0200 | [diff] [blame] | 199 | int *global_cnt = data; |
Haim Dreyfuss | 61f6325 | 2013-11-03 23:02:59 +0200 | [diff] [blame] | 200 | |
David Spinadel | 1e2ebe0 | 2014-10-26 15:53:27 +0200 | [diff] [blame] | 201 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE && mvmvif->phy_ctxt && |
| 202 | mvmvif->phy_ctxt->id < MAX_PHYS) |
Haim Dreyfuss | c3f8d0a | 2014-12-02 11:03:16 +0200 | [diff] [blame] | 203 | *global_cnt += 1; |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm, |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 207 | struct ieee80211_vif *vif, |
Johannes Berg | ab48003 | 2014-06-04 10:13:50 +0200 | [diff] [blame] | 208 | int n_ssids, u32 flags, |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 209 | struct iwl_mvm_scan_params *params) |
| 210 | { |
Haim Dreyfuss | c3f8d0a | 2014-12-02 11:03:16 +0200 | [diff] [blame] | 211 | int global_cnt = 0; |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 212 | enum ieee80211_band band; |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 213 | u8 frag_passive_dwell = 0; |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 214 | |
| 215 | ieee80211_iterate_active_interfaces_atomic(mvm->hw, |
| 216 | IEEE80211_IFACE_ITER_NORMAL, |
| 217 | iwl_mvm_scan_condition_iterator, |
Haim Dreyfuss | c3f8d0a | 2014-12-02 11:03:16 +0200 | [diff] [blame] | 218 | &global_cnt); |
Alexander Bondar | 8a110d9 | 2014-03-12 17:31:19 +0200 | [diff] [blame] | 219 | |
Haim Dreyfuss | c3f8d0a | 2014-12-02 11:03:16 +0200 | [diff] [blame] | 220 | if (!global_cnt) |
Alexander Bondar | ef67f18d | 2014-03-30 10:47:08 +0300 | [diff] [blame] | 221 | goto not_bound; |
| 222 | |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 223 | params->suspend_time = 30; |
Haim Dreyfuss | 44e9cd7 | 2014-12-18 12:34:01 +0200 | [diff] [blame] | 224 | params->max_out_time = 120; |
Alexander Bondar | ef67f18d | 2014-03-30 10:47:08 +0300 | [diff] [blame] | 225 | |
| 226 | if (iwl_mvm_low_latency(mvm)) { |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 227 | if (mvm->fw->ucode_capa.api[0] & |
| 228 | IWL_UCODE_TLV_API_FRAGMENTED_SCAN) { |
| 229 | params->suspend_time = 105; |
Haim Dreyfuss | c3f8d0a | 2014-12-02 11:03:16 +0200 | [diff] [blame] | 230 | /* |
| 231 | * If there is more than one active interface make |
| 232 | * passive scan more fragmented. |
| 233 | */ |
David Spinadel | ef17708 | 2015-02-15 14:45:33 +0200 | [diff] [blame] | 234 | frag_passive_dwell = 40; |
Haim Dreyfuss | 44e9cd7 | 2014-12-18 12:34:01 +0200 | [diff] [blame] | 235 | params->max_out_time = frag_passive_dwell; |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 236 | } else { |
| 237 | params->suspend_time = 120; |
| 238 | params->max_out_time = 120; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | if (frag_passive_dwell && (mvm->fw->ucode_capa.api[0] & |
| 243 | IWL_UCODE_TLV_API_FRAGMENTED_SCAN)) { |
| 244 | /* |
| 245 | * P2P device scan should not be fragmented to avoid negative |
| 246 | * impact on P2P device discovery. Configure max_out_time to be |
| 247 | * equal to dwell time on passive channel. Take a longest |
| 248 | * possible value, one that corresponds to 2GHz band |
| 249 | */ |
| 250 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
| 251 | u32 passive_dwell = |
David Spinadel | 3cae073 | 2014-12-29 15:43:48 +0200 | [diff] [blame] | 252 | iwl_mvm_get_passive_dwell(mvm, |
| 253 | IEEE80211_BAND_2GHZ); |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 254 | params->max_out_time = passive_dwell; |
| 255 | } else { |
| 256 | params->passive_fragmented = true; |
| 257 | } |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 258 | } |
| 259 | |
Johannes Berg | ab48003 | 2014-06-04 10:13:50 +0200 | [diff] [blame] | 260 | if (flags & NL80211_SCAN_FLAG_LOW_PRIORITY) |
| 261 | params->max_out_time = 200; |
| 262 | |
Alexander Bondar | ef67f18d | 2014-03-30 10:47:08 +0300 | [diff] [blame] | 263 | not_bound: |
| 264 | |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 265 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 266 | if (params->passive_fragmented) |
David Spinadel | 190f102 | 2015-02-17 12:45:21 +0200 | [diff] [blame] | 267 | params->dwell[band].fragmented = frag_passive_dwell; |
| 268 | |
| 269 | params->dwell[band].passive = iwl_mvm_get_passive_dwell(mvm, |
| 270 | band); |
David Spinadel | 3cae073 | 2014-12-29 15:43:48 +0200 | [diff] [blame] | 271 | params->dwell[band].active = iwl_mvm_get_active_dwell(mvm, band, |
Alexander Bondar | 50df8a3 | 2014-03-12 20:30:51 +0200 | [diff] [blame] | 272 | n_ssids); |
| 273 | } |
Luciano Coelho | 0616c62 | 2015-04-09 12:18:56 +0300 | [diff] [blame^] | 274 | |
| 275 | IWL_DEBUG_SCAN(mvm, |
| 276 | "scan parameters: max_out_time %d, suspend_time %d, passive_fragmented %d\n", |
| 277 | params->max_out_time, params->suspend_time, |
| 278 | params->passive_fragmented); |
| 279 | IWL_DEBUG_SCAN(mvm, |
| 280 | "dwell[IEEE80211_BAND_2GHZ]: passive %d, active %d, fragmented %d\n", |
| 281 | params->dwell[IEEE80211_BAND_2GHZ].passive, |
| 282 | params->dwell[IEEE80211_BAND_2GHZ].active, |
| 283 | params->dwell[IEEE80211_BAND_2GHZ].fragmented); |
| 284 | IWL_DEBUG_SCAN(mvm, |
| 285 | "dwell[IEEE80211_BAND_5GHZ]: passive %d, active %d, fragmented %d\n", |
| 286 | params->dwell[IEEE80211_BAND_5GHZ].passive, |
| 287 | params->dwell[IEEE80211_BAND_5GHZ].active, |
| 288 | params->dwell[IEEE80211_BAND_5GHZ].fragmented); |
Haim Dreyfuss | 61f6325 | 2013-11-03 23:02:59 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Andrei Otcheretianski | 73897bd | 2014-07-09 18:59:14 +0300 | [diff] [blame] | 291 | static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm) |
| 292 | { |
| 293 | /* require rrm scan whenever the fw supports it */ |
| 294 | return mvm->fw->ucode_capa.capa[0] & |
| 295 | IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT; |
| 296 | } |
| 297 | |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 298 | static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm, |
| 299 | bool is_sched_scan) |
| 300 | { |
| 301 | int max_probe_len; |
| 302 | |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 303 | max_probe_len = SCAN_OFFLOAD_PROBE_REQ_SIZE; |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 304 | |
| 305 | /* we create the 802.11 header and SSID element */ |
| 306 | max_probe_len -= 24 + 2; |
| 307 | |
Andrei Otcheretianski | 66dc527 | 2014-09-02 17:55:40 +0300 | [diff] [blame] | 308 | /* DS parameter set element is added on 2.4GHZ band if required */ |
| 309 | if (iwl_mvm_rrm_scan_needed(mvm)) |
| 310 | max_probe_len -= 3; |
| 311 | |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 312 | return max_probe_len; |
| 313 | } |
| 314 | |
| 315 | int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan) |
| 316 | { |
| 317 | int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm, is_sched_scan); |
| 318 | |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 319 | /* TODO: [BUG] This function should return the maximum allowed size of |
| 320 | * scan IEs, however the LMAC scan api contains both 2GHZ and 5GHZ IEs |
| 321 | * in the same command. So the correct implementation of this function |
| 322 | * is just iwl_mvm_max_scan_ie_fw_cmd_room() / 2. Currently the scan |
| 323 | * command has only 512 bytes and it would leave us with about 240 |
| 324 | * bytes for scan IEs, which is clearly not enough. So meanwhile |
| 325 | * we will report an incorrect value. This may result in a failure to |
| 326 | * issue a scan in unified_scan_lmac and unified_sched_scan_lmac |
| 327 | * functions with -ENOBUFS, if a large enough probe will be provided. |
| 328 | */ |
| 329 | return max_ie_len; |
| 330 | } |
| 331 | |
Alexander Bondar | e5d7464 | 2014-12-09 19:15:49 +0200 | [diff] [blame] | 332 | int iwl_mvm_rx_scan_offload_iter_complete_notif(struct iwl_mvm *mvm, |
| 333 | struct iwl_rx_cmd_buffer *rxb, |
| 334 | struct iwl_device_cmd *cmd) |
| 335 | { |
| 336 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
Avraham Stern | 1083fd7 | 2015-03-31 16:14:41 +0300 | [diff] [blame] | 337 | struct iwl_lmac_scan_complete_notif *notif = (void *)pkt->data; |
Alexander Bondar | e5d7464 | 2014-12-09 19:15:49 +0200 | [diff] [blame] | 338 | |
| 339 | IWL_DEBUG_SCAN(mvm, |
| 340 | "Scan offload iteration complete: status=0x%x scanned channels=%d\n", |
| 341 | notif->status, notif->scanned_channels); |
| 342 | return 0; |
| 343 | } |
| 344 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 345 | int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm, |
| 346 | struct iwl_rx_cmd_buffer *rxb, |
| 347 | struct iwl_device_cmd *cmd) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 348 | { |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 349 | IWL_DEBUG_SCAN(mvm, "Scheduled scan results\n"); |
| 350 | ieee80211_sched_scan_results(mvm->hw); |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 355 | int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm, |
| 356 | struct iwl_rx_cmd_buffer *rxb, |
| 357 | struct iwl_device_cmd *cmd) |
| 358 | { |
| 359 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 360 | struct iwl_periodic_scan_complete *scan_notif; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 361 | |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 362 | scan_notif = (void *)pkt->data; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 363 | |
Johannes Berg | a6623e8 | 2014-01-27 15:40:53 +0100 | [diff] [blame] | 364 | /* scan status must be locked for proper checking */ |
| 365 | lockdep_assert_held(&mvm->mutex); |
| 366 | |
Haim Dreyfuss | e820c2d | 2014-04-06 11:19:09 +0300 | [diff] [blame] | 367 | IWL_DEBUG_SCAN(mvm, |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 368 | "%s completed, status %s, EBS status %s\n", |
| 369 | mvm->scan_status == IWL_MVM_SCAN_SCHED ? |
| 370 | "Scheduled scan" : "Scan", |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 371 | scan_notif->status == IWL_SCAN_OFFLOAD_COMPLETED ? |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 372 | "completed" : "aborted", |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 373 | scan_notif->ebs_status == IWL_SCAN_EBS_SUCCESS ? |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 374 | "success" : "failed"); |
Haim Dreyfuss | e820c2d | 2014-04-06 11:19:09 +0300 | [diff] [blame] | 375 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 376 | |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 377 | /* only call mac80211 completion if the stop was initiated by FW */ |
| 378 | if (mvm->scan_status == IWL_MVM_SCAN_SCHED) { |
Johannes Berg | a6623e8 | 2014-01-27 15:40:53 +0100 | [diff] [blame] | 379 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 380 | ieee80211_sched_scan_stopped(mvm->hw); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 381 | } else if (mvm->scan_status == IWL_MVM_SCAN_OS) { |
| 382 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 383 | ieee80211_scan_completed(mvm->hw, |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 384 | scan_notif->status == IWL_SCAN_OFFLOAD_ABORTED); |
Eliad Peller | 4ff7818 | 2014-06-22 14:44:44 +0300 | [diff] [blame] | 385 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 386 | } |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 387 | |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 388 | if (scan_notif->ebs_status) |
Haim Dreyfuss | 5a4b2af | 2015-01-13 11:54:51 +0200 | [diff] [blame] | 389 | mvm->last_ebs_successful = false; |
Haim Dreyfuss | e820c2d | 2014-04-06 11:19:09 +0300 | [diff] [blame] | 390 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 391 | return 0; |
| 392 | } |
| 393 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 394 | static int iwl_ssid_exist(u8 *ssid, u8 ssid_len, struct iwl_ssid_ie *ssid_list) |
| 395 | { |
| 396 | int i; |
| 397 | |
| 398 | for (i = 0; i < PROBE_OPTION_MAX; i++) { |
| 399 | if (!ssid_list[i].len) |
| 400 | break; |
| 401 | if (ssid_list[i].len == ssid_len && |
| 402 | !memcmp(ssid_list->ssid, ssid, ssid_len)) |
| 403 | return i; |
| 404 | } |
| 405 | return -1; |
| 406 | } |
| 407 | |
| 408 | static void iwl_scan_offload_build_ssid(struct cfg80211_sched_scan_request *req, |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 409 | struct iwl_ssid_ie *direct_scan, |
| 410 | u32 *ssid_bitmap, bool basic_ssid) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 411 | { |
| 412 | int i, j; |
| 413 | int index; |
| 414 | |
| 415 | /* |
| 416 | * copy SSIDs from match list. |
| 417 | * iwl_config_sched_scan_profiles() uses the order of these ssids to |
| 418 | * config match list. |
| 419 | */ |
| 420 | for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) { |
Johannes Berg | ea73cbc | 2014-01-24 10:53:53 +0100 | [diff] [blame] | 421 | /* skip empty SSID matchsets */ |
| 422 | if (!req->match_sets[i].ssid.ssid_len) |
| 423 | continue; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 424 | direct_scan[i].id = WLAN_EID_SSID; |
| 425 | direct_scan[i].len = req->match_sets[i].ssid.ssid_len; |
| 426 | memcpy(direct_scan[i].ssid, req->match_sets[i].ssid.ssid, |
| 427 | direct_scan[i].len); |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | /* add SSIDs from scan SSID list */ |
| 431 | *ssid_bitmap = 0; |
| 432 | for (j = 0; j < req->n_ssids && i < PROBE_OPTION_MAX; j++) { |
| 433 | index = iwl_ssid_exist(req->ssids[j].ssid, |
| 434 | req->ssids[j].ssid_len, |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 435 | direct_scan); |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 436 | if (index < 0) { |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 437 | if (!req->ssids[j].ssid_len && basic_ssid) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 438 | continue; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 439 | direct_scan[i].id = WLAN_EID_SSID; |
| 440 | direct_scan[i].len = req->ssids[j].ssid_len; |
| 441 | memcpy(direct_scan[i].ssid, req->ssids[j].ssid, |
| 442 | direct_scan[i].len); |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 443 | *ssid_bitmap |= BIT(i + 1); |
| 444 | i++; |
| 445 | } else { |
| 446 | *ssid_bitmap |= BIT(index + 1); |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 451 | int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm, |
| 452 | struct cfg80211_sched_scan_request *req) |
| 453 | { |
| 454 | struct iwl_scan_offload_profile *profile; |
| 455 | struct iwl_scan_offload_profile_cfg *profile_cfg; |
| 456 | struct iwl_scan_offload_blacklist *blacklist; |
| 457 | struct iwl_host_cmd cmd = { |
| 458 | .id = SCAN_OFFLOAD_UPDATE_PROFILES_CMD, |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 459 | .len[1] = sizeof(*profile_cfg), |
| 460 | .dataflags[0] = IWL_HCMD_DFL_NOCOPY, |
| 461 | .dataflags[1] = IWL_HCMD_DFL_NOCOPY, |
| 462 | }; |
| 463 | int blacklist_len; |
| 464 | int i; |
| 465 | int ret; |
| 466 | |
| 467 | if (WARN_ON(req->n_match_sets > IWL_SCAN_MAX_PROFILES)) |
| 468 | return -EIO; |
| 469 | |
| 470 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SHORT_BL) |
| 471 | blacklist_len = IWL_SCAN_SHORT_BLACKLIST_LEN; |
| 472 | else |
| 473 | blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN; |
| 474 | |
| 475 | blacklist = kzalloc(sizeof(*blacklist) * blacklist_len, GFP_KERNEL); |
| 476 | if (!blacklist) |
| 477 | return -ENOMEM; |
| 478 | |
| 479 | profile_cfg = kzalloc(sizeof(*profile_cfg), GFP_KERNEL); |
| 480 | if (!profile_cfg) { |
| 481 | ret = -ENOMEM; |
| 482 | goto free_blacklist; |
| 483 | } |
| 484 | |
| 485 | cmd.data[0] = blacklist; |
| 486 | cmd.len[0] = sizeof(*blacklist) * blacklist_len; |
| 487 | cmd.data[1] = profile_cfg; |
| 488 | |
| 489 | /* No blacklist configuration */ |
| 490 | |
| 491 | profile_cfg->num_profiles = req->n_match_sets; |
| 492 | profile_cfg->active_clients = SCAN_CLIENT_SCHED_SCAN; |
| 493 | profile_cfg->pass_match = SCAN_CLIENT_SCHED_SCAN; |
| 494 | profile_cfg->match_notify = SCAN_CLIENT_SCHED_SCAN; |
David Spinadel | 6e0bbe5 | 2013-12-30 09:59:45 +0200 | [diff] [blame] | 495 | if (!req->n_match_sets || !req->match_sets[0].ssid.ssid_len) |
| 496 | profile_cfg->any_beacon_notify = SCAN_CLIENT_SCHED_SCAN; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 497 | |
| 498 | for (i = 0; i < req->n_match_sets; i++) { |
| 499 | profile = &profile_cfg->profiles[i]; |
| 500 | profile->ssid_index = i; |
| 501 | /* Support any cipher and auth algorithm */ |
| 502 | profile->unicast_cipher = 0xff; |
| 503 | profile->auth_alg = 0xff; |
| 504 | profile->network_type = IWL_NETWORK_TYPE_ANY; |
| 505 | profile->band_selection = IWL_SCAN_OFFLOAD_SELECT_ANY; |
| 506 | profile->client_bitmap = SCAN_CLIENT_SCHED_SCAN; |
| 507 | } |
| 508 | |
| 509 | IWL_DEBUG_SCAN(mvm, "Sending scheduled scan profile config\n"); |
| 510 | |
| 511 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
| 512 | kfree(profile_cfg); |
| 513 | free_blacklist: |
| 514 | kfree(blacklist); |
| 515 | |
| 516 | return ret; |
| 517 | } |
| 518 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 519 | static bool iwl_mvm_scan_pass_all(struct iwl_mvm *mvm, |
| 520 | struct cfg80211_sched_scan_request *req) |
| 521 | { |
| 522 | if (req->n_match_sets && req->match_sets[0].ssid.ssid_len) { |
| 523 | IWL_DEBUG_SCAN(mvm, |
| 524 | "Sending scheduled scan with filtering, n_match_sets %d\n", |
| 525 | req->n_match_sets); |
| 526 | return false; |
| 527 | } |
| 528 | |
| 529 | IWL_DEBUG_SCAN(mvm, "Sending Scheduled scan without filtering\n"); |
| 530 | return true; |
| 531 | } |
| 532 | |
Luciano Coelho | b141c23 | 2014-10-01 13:22:40 +0300 | [diff] [blame] | 533 | int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm, |
| 534 | struct ieee80211_vif *vif, |
| 535 | struct cfg80211_sched_scan_request *req, |
| 536 | struct ieee80211_scan_ies *ies) |
| 537 | { |
| 538 | int ret; |
| 539 | |
David Spinadel | b975e55 | 2014-11-17 12:30:05 +0200 | [diff] [blame] | 540 | if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) { |
| 541 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); |
| 542 | if (ret) |
| 543 | return ret; |
| 544 | ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies); |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 545 | } else { |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 546 | mvm->scan_status = IWL_MVM_SCAN_SCHED; |
Luciano Coelho | b141c23 | 2014-10-01 13:22:40 +0300 | [diff] [blame] | 547 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); |
| 548 | if (ret) |
| 549 | return ret; |
| 550 | ret = iwl_mvm_unified_sched_scan_lmac(mvm, vif, req, ies); |
Luciano Coelho | b141c23 | 2014-10-01 13:22:40 +0300 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | return ret; |
| 554 | } |
| 555 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 556 | static int iwl_mvm_send_scan_offload_abort(struct iwl_mvm *mvm) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 557 | { |
| 558 | int ret; |
| 559 | struct iwl_host_cmd cmd = { |
| 560 | .id = SCAN_OFFLOAD_ABORT_CMD, |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 561 | }; |
| 562 | u32 status; |
| 563 | |
| 564 | /* Exit instantly with error when device is not ready |
| 565 | * to receive scan abort command or it does not perform |
| 566 | * scheduled scan currently */ |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 567 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 568 | return -EIO; |
| 569 | |
| 570 | ret = iwl_mvm_send_cmd_status(mvm, &cmd, &status); |
| 571 | if (ret) |
| 572 | return ret; |
| 573 | |
| 574 | if (status != CAN_ABORT_STATUS) { |
| 575 | /* |
| 576 | * The scan abort will return 1 for success or |
| 577 | * 2 for "failure". A failure condition can be |
| 578 | * due to simply not being in an active scan which |
| 579 | * can occur if we send the scan abort before the |
| 580 | * microcode has notified us that a scan is completed. |
| 581 | */ |
| 582 | IWL_DEBUG_SCAN(mvm, "SCAN OFFLOAD ABORT ret %d.\n", status); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 583 | ret = -ENOENT; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | return ret; |
| 587 | } |
| 588 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 589 | int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify) |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 590 | { |
| 591 | int ret; |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 592 | struct iwl_notification_wait wait_scan_done; |
| 593 | static const u8 scan_done_notif[] = { SCAN_OFFLOAD_COMPLETE, }; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 594 | bool sched = mvm->scan_status == IWL_MVM_SCAN_SCHED; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 595 | |
| 596 | lockdep_assert_held(&mvm->mutex); |
| 597 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 598 | if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) |
| 599 | return iwl_umac_scan_stop(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN, |
| 600 | notify); |
| 601 | |
Emmanuel Grumbach | 90ea15c | 2015-01-18 21:39:30 +0200 | [diff] [blame] | 602 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) |
| 603 | return 0; |
| 604 | |
Luciano Coelho | 54331db | 2015-02-05 00:39:22 +0200 | [diff] [blame] | 605 | if (iwl_mvm_is_radio_killed(mvm)) { |
| 606 | ret = 0; |
Emmanuel Grumbach | 90ea15c | 2015-01-18 21:39:30 +0200 | [diff] [blame] | 607 | goto out; |
Luciano Coelho | 54331db | 2015-02-05 00:39:22 +0200 | [diff] [blame] | 608 | } |
Emmanuel Grumbach | 90ea15c | 2015-01-18 21:39:30 +0200 | [diff] [blame] | 609 | |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 610 | iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_done, |
| 611 | scan_done_notif, |
| 612 | ARRAY_SIZE(scan_done_notif), |
| 613 | NULL, NULL); |
| 614 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 615 | ret = iwl_mvm_send_scan_offload_abort(mvm); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 616 | if (ret) { |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 617 | IWL_DEBUG_SCAN(mvm, "Send stop %sscan failed %d\n", |
| 618 | sched ? "offloaded " : "", ret); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 619 | iwl_remove_notification(&mvm->notif_wait, &wait_scan_done); |
Luciano Coelho | 54331db | 2015-02-05 00:39:22 +0200 | [diff] [blame] | 620 | goto out; |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 621 | } |
| 622 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 623 | IWL_DEBUG_SCAN(mvm, "Successfully sent stop %sscan\n", |
| 624 | sched ? "offloaded " : ""); |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 625 | |
| 626 | ret = iwl_wait_notification(&mvm->notif_wait, &wait_scan_done, 1 * HZ); |
Luciano Coelho | 54331db | 2015-02-05 00:39:22 +0200 | [diff] [blame] | 627 | out: |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 628 | /* |
| 629 | * Clear the scan status so the next scan requests will succeed. This |
| 630 | * also ensures the Rx handler doesn't do anything, as the scan was |
Eliad Peller | 4ff7818 | 2014-06-22 14:44:44 +0300 | [diff] [blame] | 631 | * stopped from above. Since the rx handler won't do anything now, |
| 632 | * we have to release the scan reference here. |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 633 | */ |
Eliad Peller | 4ff7818 | 2014-06-22 14:44:44 +0300 | [diff] [blame] | 634 | if (mvm->scan_status == IWL_MVM_SCAN_OS) |
| 635 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
| 636 | |
Arik Nemtsov | 33ea27f | 2014-02-10 15:34:29 +0200 | [diff] [blame] | 637 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 638 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 639 | if (notify) { |
| 640 | if (sched) |
| 641 | ieee80211_sched_scan_stopped(mvm->hw); |
| 642 | else |
| 643 | ieee80211_scan_completed(mvm->hw, true); |
| 644 | } |
David Spinadel | 636a2cd | 2014-05-01 15:57:22 +0300 | [diff] [blame] | 645 | |
Luciano Coelho | 54331db | 2015-02-05 00:39:22 +0200 | [diff] [blame] | 646 | return ret; |
David Spinadel | 35a000b | 2013-08-28 09:29:43 +0300 | [diff] [blame] | 647 | } |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 648 | |
| 649 | static void iwl_mvm_unified_scan_fill_tx_cmd(struct iwl_mvm *mvm, |
| 650 | struct iwl_scan_req_tx_cmd *tx_cmd, |
| 651 | bool no_cck) |
| 652 | { |
| 653 | tx_cmd[0].tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL | |
| 654 | TX_CMD_FLG_BT_DIS); |
| 655 | tx_cmd[0].rate_n_flags = iwl_mvm_scan_rate_n_flags(mvm, |
| 656 | IEEE80211_BAND_2GHZ, |
| 657 | no_cck); |
| 658 | tx_cmd[0].sta_id = mvm->aux_sta.sta_id; |
| 659 | |
| 660 | tx_cmd[1].tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL | |
| 661 | TX_CMD_FLG_BT_DIS); |
| 662 | tx_cmd[1].rate_n_flags = iwl_mvm_scan_rate_n_flags(mvm, |
| 663 | IEEE80211_BAND_5GHZ, |
| 664 | no_cck); |
| 665 | tx_cmd[1].sta_id = mvm->aux_sta.sta_id; |
| 666 | } |
| 667 | |
| 668 | static void |
| 669 | iwl_mvm_lmac_scan_cfg_channels(struct iwl_mvm *mvm, |
| 670 | struct ieee80211_channel **channels, |
| 671 | int n_channels, u32 ssid_bitmap, |
| 672 | struct iwl_scan_req_unified_lmac *cmd) |
| 673 | { |
| 674 | struct iwl_scan_channel_cfg_lmac *channel_cfg = (void *)&cmd->data; |
| 675 | int i; |
| 676 | |
| 677 | for (i = 0; i < n_channels; i++) { |
| 678 | channel_cfg[i].channel_num = |
| 679 | cpu_to_le16(channels[i]->hw_value); |
| 680 | channel_cfg[i].iter_count = cpu_to_le16(1); |
| 681 | channel_cfg[i].iter_interval = 0; |
| 682 | channel_cfg[i].flags = |
| 683 | cpu_to_le32(IWL_UNIFIED_SCAN_CHANNEL_PARTIAL | |
| 684 | ssid_bitmap); |
| 685 | } |
| 686 | } |
| 687 | |
Andrei Otcheretianski | 66dc527 | 2014-09-02 17:55:40 +0300 | [diff] [blame] | 688 | static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies, |
| 689 | size_t len, u8 *const pos) |
| 690 | { |
| 691 | static const u8 before_ds_params[] = { |
| 692 | WLAN_EID_SSID, |
| 693 | WLAN_EID_SUPP_RATES, |
| 694 | WLAN_EID_REQUEST, |
| 695 | WLAN_EID_EXT_SUPP_RATES, |
| 696 | }; |
| 697 | size_t offs; |
| 698 | u8 *newpos = pos; |
| 699 | |
| 700 | if (!iwl_mvm_rrm_scan_needed(mvm)) { |
| 701 | memcpy(newpos, ies, len); |
| 702 | return newpos + len; |
| 703 | } |
| 704 | |
| 705 | offs = ieee80211_ie_split(ies, len, |
| 706 | before_ds_params, |
| 707 | ARRAY_SIZE(before_ds_params), |
| 708 | 0); |
| 709 | |
| 710 | memcpy(newpos, ies, offs); |
| 711 | newpos += offs; |
| 712 | |
| 713 | /* Add a placeholder for DS Parameter Set element */ |
| 714 | *newpos++ = WLAN_EID_DS_PARAMS; |
| 715 | *newpos++ = 1; |
| 716 | *newpos++ = 0; |
| 717 | |
| 718 | memcpy(newpos, ies + offs, len - offs); |
| 719 | newpos += len - offs; |
| 720 | |
| 721 | return newpos; |
| 722 | } |
| 723 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 724 | static void |
| 725 | iwl_mvm_build_unified_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 726 | struct ieee80211_scan_ies *ies, |
Johannes Berg | effd05a | 2014-11-18 17:21:19 +0100 | [diff] [blame] | 727 | struct iwl_scan_probe_req *preq, |
| 728 | const u8 *mac_addr, const u8 *mac_addr_mask) |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 729 | { |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 730 | struct ieee80211_mgmt *frame = (struct ieee80211_mgmt *)preq->buf; |
Andrei Otcheretianski | 66dc527 | 2014-09-02 17:55:40 +0300 | [diff] [blame] | 731 | u8 *pos, *newpos; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 732 | |
Johannes Berg | effd05a | 2014-11-18 17:21:19 +0100 | [diff] [blame] | 733 | /* |
| 734 | * Unfortunately, right now the offload scan doesn't support randomising |
| 735 | * within the firmware, so until the firmware API is ready we implement |
| 736 | * it in the driver. This means that the scan iterations won't really be |
| 737 | * random, only when it's restarted, but at least that helps a bit. |
| 738 | */ |
| 739 | if (mac_addr) |
| 740 | get_random_mask_addr(frame->sa, mac_addr, mac_addr_mask); |
| 741 | else |
| 742 | memcpy(frame->sa, vif->addr, ETH_ALEN); |
| 743 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 744 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); |
| 745 | eth_broadcast_addr(frame->da); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 746 | eth_broadcast_addr(frame->bssid); |
| 747 | frame->seq_ctrl = 0; |
| 748 | |
| 749 | pos = frame->u.probe_req.variable; |
| 750 | *pos++ = WLAN_EID_SSID; |
| 751 | *pos++ = 0; |
| 752 | |
| 753 | preq->mac_header.offset = 0; |
| 754 | preq->mac_header.len = cpu_to_le16(24 + 2); |
| 755 | |
Andrei Otcheretianski | 66dc527 | 2014-09-02 17:55:40 +0300 | [diff] [blame] | 756 | /* Insert ds parameter set element on 2.4 GHz band */ |
| 757 | newpos = iwl_mvm_copy_and_insert_ds_elem(mvm, |
| 758 | ies->ies[IEEE80211_BAND_2GHZ], |
| 759 | ies->len[IEEE80211_BAND_2GHZ], |
| 760 | pos); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 761 | preq->band_data[0].offset = cpu_to_le16(pos - preq->buf); |
Andrei Otcheretianski | 66dc527 | 2014-09-02 17:55:40 +0300 | [diff] [blame] | 762 | preq->band_data[0].len = cpu_to_le16(newpos - pos); |
| 763 | pos = newpos; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 764 | |
| 765 | memcpy(pos, ies->ies[IEEE80211_BAND_5GHZ], |
| 766 | ies->len[IEEE80211_BAND_5GHZ]); |
| 767 | preq->band_data[1].offset = cpu_to_le16(pos - preq->buf); |
| 768 | preq->band_data[1].len = cpu_to_le16(ies->len[IEEE80211_BAND_5GHZ]); |
| 769 | pos += ies->len[IEEE80211_BAND_5GHZ]; |
| 770 | |
| 771 | memcpy(pos, ies->common_ies, ies->common_ie_len); |
| 772 | preq->common_data.offset = cpu_to_le16(pos - preq->buf); |
| 773 | preq->common_data.len = cpu_to_le16(ies->common_ie_len); |
| 774 | } |
| 775 | |
| 776 | static void |
| 777 | iwl_mvm_build_generic_unified_scan_cmd(struct iwl_mvm *mvm, |
| 778 | struct iwl_scan_req_unified_lmac *cmd, |
| 779 | struct iwl_mvm_scan_params *params) |
| 780 | { |
David Spinadel | af91344 | 2014-06-12 19:29:40 +0300 | [diff] [blame] | 781 | memset(cmd, 0, ksize(cmd)); |
David Spinadel | 2ce89cd | 2014-07-22 13:11:18 +0300 | [diff] [blame] | 782 | cmd->active_dwell = params->dwell[IEEE80211_BAND_2GHZ].active; |
| 783 | cmd->passive_dwell = params->dwell[IEEE80211_BAND_2GHZ].passive; |
| 784 | if (params->passive_fragmented) |
| 785 | cmd->fragmented_dwell = |
David Spinadel | 190f102 | 2015-02-17 12:45:21 +0200 | [diff] [blame] | 786 | params->dwell[IEEE80211_BAND_2GHZ].fragmented; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 787 | cmd->rx_chain_select = iwl_mvm_scan_rx_chain(mvm); |
| 788 | cmd->max_out_time = cpu_to_le32(params->max_out_time); |
| 789 | cmd->suspend_time = cpu_to_le32(params->suspend_time); |
| 790 | cmd->scan_prio = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 791 | cmd->iter_num = cpu_to_le32(1); |
David Spinadel | af91344 | 2014-06-12 19:29:40 +0300 | [diff] [blame] | 792 | |
Andrei Otcheretianski | 73897bd | 2014-07-09 18:59:14 +0300 | [diff] [blame] | 793 | if (iwl_mvm_rrm_scan_needed(mvm)) |
| 794 | cmd->scan_flags |= |
| 795 | cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm, |
| 799 | struct ieee80211_vif *vif, |
| 800 | struct ieee80211_scan_request *req) |
| 801 | { |
| 802 | struct iwl_host_cmd hcmd = { |
| 803 | .id = SCAN_OFFLOAD_REQUEST_CMD, |
| 804 | .len = { sizeof(struct iwl_scan_req_unified_lmac) + |
| 805 | sizeof(struct iwl_scan_channel_cfg_lmac) * |
| 806 | mvm->fw->ucode_capa.n_scan_channels + |
| 807 | sizeof(struct iwl_scan_probe_req), }, |
| 808 | .data = { mvm->scan_cmd, }, |
| 809 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, |
| 810 | }; |
| 811 | struct iwl_scan_req_unified_lmac *cmd = mvm->scan_cmd; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 812 | struct iwl_scan_probe_req *preq; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 813 | struct iwl_mvm_scan_params params = {}; |
| 814 | u32 flags; |
Johannes Berg | c8660dd | 2014-11-17 15:06:52 +0100 | [diff] [blame] | 815 | u32 ssid_bitmap = 0; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 816 | int ret, i; |
| 817 | |
| 818 | lockdep_assert_held(&mvm->mutex); |
| 819 | |
| 820 | /* we should have failed registration if scan_cmd was NULL */ |
| 821 | if (WARN_ON(mvm->scan_cmd == NULL)) |
| 822 | return -ENOMEM; |
| 823 | |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 824 | if (req->req.n_ssids > PROBE_OPTION_MAX || |
| 825 | req->ies.common_ie_len + req->ies.len[NL80211_BAND_2GHZ] + |
| 826 | req->ies.len[NL80211_BAND_5GHZ] > |
| 827 | iwl_mvm_max_scan_ie_fw_cmd_room(mvm, false) || |
| 828 | req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels) |
| 829 | return -ENOBUFS; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 830 | |
| 831 | mvm->scan_status = IWL_MVM_SCAN_OS; |
| 832 | |
| 833 | iwl_mvm_scan_calc_params(mvm, vif, req->req.n_ssids, req->req.flags, |
| 834 | ¶ms); |
| 835 | |
| 836 | iwl_mvm_build_generic_unified_scan_cmd(mvm, cmd, ¶ms); |
| 837 | |
| 838 | cmd->n_channels = (u8)req->req.n_channels; |
| 839 | |
| 840 | flags = IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL; |
| 841 | |
| 842 | if (req->req.n_ssids == 1 && req->req.ssids[0].ssid_len != 0) |
| 843 | flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION; |
| 844 | |
| 845 | if (params.passive_fragmented) |
| 846 | flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED; |
| 847 | |
| 848 | if (req->req.n_ssids == 0) |
| 849 | flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE; |
| 850 | |
Andrei Otcheretianski | 73897bd | 2014-07-09 18:59:14 +0300 | [diff] [blame] | 851 | cmd->scan_flags |= cpu_to_le32(flags); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 852 | |
| 853 | cmd->flags = iwl_mvm_scan_rxon_flags(req->req.channels[0]->band); |
| 854 | cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP | |
| 855 | MAC_FILTER_IN_BEACON); |
| 856 | iwl_mvm_unified_scan_fill_tx_cmd(mvm, cmd->tx_cmd, req->req.no_cck); |
| 857 | iwl_mvm_scan_fill_ssids(cmd->direct_scan, req->req.ssids, |
| 858 | req->req.n_ssids, 0); |
| 859 | |
| 860 | cmd->schedule[0].delay = 0; |
| 861 | cmd->schedule[0].iterations = 1; |
| 862 | cmd->schedule[0].full_scan_mul = 0; |
| 863 | cmd->schedule[1].delay = 0; |
| 864 | cmd->schedule[1].iterations = 0; |
| 865 | cmd->schedule[1].full_scan_mul = 0; |
| 866 | |
David Spinadel | 1f9c418 | 2014-12-01 23:30:07 +0200 | [diff] [blame] | 867 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS && |
| 868 | mvm->last_ebs_successful) { |
| 869 | cmd->channel_opt[0].flags = |
| 870 | cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS | |
| 871 | IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | |
| 872 | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD); |
| 873 | cmd->channel_opt[0].non_ebs_ratio = |
| 874 | cpu_to_le16(IWL_DENSE_EBS_SCAN_RATIO); |
| 875 | cmd->channel_opt[1].flags = |
| 876 | cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS | |
| 877 | IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | |
| 878 | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD); |
| 879 | cmd->channel_opt[1].non_ebs_ratio = |
| 880 | cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO); |
| 881 | } |
| 882 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 883 | for (i = 1; i <= req->req.n_ssids; i++) |
| 884 | ssid_bitmap |= BIT(i); |
| 885 | |
| 886 | iwl_mvm_lmac_scan_cfg_channels(mvm, req->req.channels, |
| 887 | req->req.n_channels, ssid_bitmap, |
| 888 | cmd); |
| 889 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 890 | preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) * |
| 891 | mvm->fw->ucode_capa.n_scan_channels); |
| 892 | |
Johannes Berg | effd05a | 2014-11-18 17:21:19 +0100 | [diff] [blame] | 893 | iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, preq, |
| 894 | req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ? |
| 895 | req->req.mac_addr : NULL, |
| 896 | req->req.mac_addr_mask); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 897 | |
| 898 | ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 899 | if (!ret) { |
| 900 | IWL_DEBUG_SCAN(mvm, "Scan request was sent successfully\n"); |
| 901 | } else { |
| 902 | /* |
| 903 | * If the scan failed, it usually means that the FW was unable |
| 904 | * to allocate the time events. Warn on it, but maybe we |
| 905 | * should try to send the command again with different params. |
| 906 | */ |
| 907 | IWL_ERR(mvm, "Scan failed! ret %d\n", ret); |
| 908 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 909 | ret = -EIO; |
| 910 | } |
| 911 | return ret; |
| 912 | } |
| 913 | |
| 914 | int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm, |
| 915 | struct ieee80211_vif *vif, |
| 916 | struct cfg80211_sched_scan_request *req, |
| 917 | struct ieee80211_scan_ies *ies) |
| 918 | { |
| 919 | struct iwl_host_cmd hcmd = { |
| 920 | .id = SCAN_OFFLOAD_REQUEST_CMD, |
| 921 | .len = { sizeof(struct iwl_scan_req_unified_lmac) + |
| 922 | sizeof(struct iwl_scan_channel_cfg_lmac) * |
| 923 | mvm->fw->ucode_capa.n_scan_channels + |
| 924 | sizeof(struct iwl_scan_probe_req), }, |
| 925 | .data = { mvm->scan_cmd, }, |
| 926 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, |
| 927 | }; |
| 928 | struct iwl_scan_req_unified_lmac *cmd = mvm->scan_cmd; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 929 | struct iwl_scan_probe_req *preq; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 930 | struct iwl_mvm_scan_params params = {}; |
| 931 | int ret; |
| 932 | u32 flags = 0, ssid_bitmap = 0; |
| 933 | |
| 934 | lockdep_assert_held(&mvm->mutex); |
| 935 | |
| 936 | /* we should have failed registration if scan_cmd was NULL */ |
| 937 | if (WARN_ON(mvm->scan_cmd == NULL)) |
| 938 | return -ENOMEM; |
| 939 | |
Andrei Otcheretianski | 48849a4 | 2014-09-09 10:58:49 +0300 | [diff] [blame] | 940 | if (req->n_ssids > PROBE_OPTION_MAX || |
| 941 | ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] + |
| 942 | ies->len[NL80211_BAND_5GHZ] > |
| 943 | iwl_mvm_max_scan_ie_fw_cmd_room(mvm, true) || |
| 944 | req->n_channels > mvm->fw->ucode_capa.n_scan_channels) |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 945 | return -ENOBUFS; |
| 946 | |
| 947 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, ¶ms); |
| 948 | |
| 949 | iwl_mvm_build_generic_unified_scan_cmd(mvm, cmd, ¶ms); |
| 950 | |
| 951 | cmd->n_channels = (u8)req->n_channels; |
| 952 | |
Luciano Coelho | 2250fd9 | 2014-12-03 10:52:26 +0200 | [diff] [blame] | 953 | cmd->delay = cpu_to_le32(req->delay); |
| 954 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 955 | if (iwl_mvm_scan_pass_all(mvm, req)) |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 956 | flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL; |
David Spinadel | 7e2a388 | 2014-12-23 14:38:09 +0200 | [diff] [blame] | 957 | else |
| 958 | flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH; |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 959 | |
| 960 | if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0) |
| 961 | flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION; |
| 962 | |
| 963 | if (params.passive_fragmented) |
| 964 | flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED; |
| 965 | |
| 966 | if (req->n_ssids == 0) |
| 967 | flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE; |
| 968 | |
Alexander Bondar | e5d7464 | 2014-12-09 19:15:49 +0200 | [diff] [blame] | 969 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 970 | if (mvm->scan_iter_notif_enabled) |
| 971 | flags |= IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE; |
| 972 | #endif |
| 973 | |
Andrei Otcheretianski | 73897bd | 2014-07-09 18:59:14 +0300 | [diff] [blame] | 974 | cmd->scan_flags |= cpu_to_le32(flags); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 975 | |
| 976 | cmd->flags = iwl_mvm_scan_rxon_flags(req->channels[0]->band); |
| 977 | cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP | |
| 978 | MAC_FILTER_IN_BEACON); |
| 979 | iwl_mvm_unified_scan_fill_tx_cmd(mvm, cmd->tx_cmd, false); |
| 980 | iwl_scan_offload_build_ssid(req, cmd->direct_scan, &ssid_bitmap, false); |
| 981 | |
David Spinadel | b14fc2b | 2014-06-25 13:17:53 +0300 | [diff] [blame] | 982 | cmd->schedule[0].delay = cpu_to_le16(req->interval / MSEC_PER_SEC); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 983 | cmd->schedule[0].iterations = IWL_FAST_SCHED_SCAN_ITERATIONS; |
| 984 | cmd->schedule[0].full_scan_mul = 1; |
| 985 | |
David Spinadel | b14fc2b | 2014-06-25 13:17:53 +0300 | [diff] [blame] | 986 | cmd->schedule[1].delay = cpu_to_le16(req->interval / MSEC_PER_SEC); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 987 | cmd->schedule[1].iterations = 0xff; |
| 988 | cmd->schedule[1].full_scan_mul = IWL_FULL_SCAN_MULTIPLIER; |
| 989 | |
David Spinadel | 1f9c418 | 2014-12-01 23:30:07 +0200 | [diff] [blame] | 990 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT && |
| 991 | mvm->last_ebs_successful) { |
| 992 | cmd->channel_opt[0].flags = |
| 993 | cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS | |
| 994 | IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | |
| 995 | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD); |
| 996 | cmd->channel_opt[0].non_ebs_ratio = |
| 997 | cpu_to_le16(IWL_DENSE_EBS_SCAN_RATIO); |
| 998 | cmd->channel_opt[1].flags = |
| 999 | cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS | |
| 1000 | IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | |
| 1001 | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD); |
| 1002 | cmd->channel_opt[1].non_ebs_ratio = |
| 1003 | cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO); |
| 1004 | } |
| 1005 | |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 1006 | iwl_mvm_lmac_scan_cfg_channels(mvm, req->channels, req->n_channels, |
| 1007 | ssid_bitmap, cmd); |
| 1008 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1009 | preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) * |
| 1010 | mvm->fw->ucode_capa.n_scan_channels); |
| 1011 | |
Johannes Berg | effd05a | 2014-11-18 17:21:19 +0100 | [diff] [blame] | 1012 | iwl_mvm_build_unified_scan_probe(mvm, vif, ies, preq, |
| 1013 | req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ? |
| 1014 | req->mac_addr : NULL, |
| 1015 | req->mac_addr_mask); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 1016 | |
| 1017 | ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 1018 | if (!ret) { |
| 1019 | IWL_DEBUG_SCAN(mvm, |
| 1020 | "Sched scan request was sent successfully\n"); |
| 1021 | } else { |
| 1022 | /* |
| 1023 | * If the scan failed, it usually means that the FW was unable |
| 1024 | * to allocate the time events. Warn on it, but maybe we |
| 1025 | * should try to send the command again with different params. |
| 1026 | */ |
| 1027 | IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret); |
| 1028 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 1029 | ret = -EIO; |
| 1030 | } |
| 1031 | return ret; |
| 1032 | } |
| 1033 | |
| 1034 | |
| 1035 | int iwl_mvm_cancel_scan(struct iwl_mvm *mvm) |
| 1036 | { |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1037 | if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) |
| 1038 | return iwl_umac_scan_stop(mvm, IWL_UMAC_SCAN_UID_REG_SCAN, |
| 1039 | true); |
| 1040 | |
Emmanuel Grumbach | 9b520d8 | 2014-11-04 15:54:11 +0200 | [diff] [blame] | 1041 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) |
| 1042 | return 0; |
| 1043 | |
| 1044 | if (iwl_mvm_is_radio_killed(mvm)) { |
| 1045 | ieee80211_scan_completed(mvm->hw, true); |
| 1046 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
| 1047 | mvm->scan_status = IWL_MVM_SCAN_NONE; |
| 1048 | return 0; |
| 1049 | } |
| 1050 | |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 1051 | return iwl_mvm_scan_offload_stop(mvm, true); |
David Spinadel | fb98be5 | 2014-05-04 12:51:10 +0300 | [diff] [blame] | 1052 | } |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1053 | |
| 1054 | /* UMAC scan API */ |
| 1055 | |
| 1056 | struct iwl_umac_scan_done { |
| 1057 | struct iwl_mvm *mvm; |
| 1058 | enum iwl_umac_scan_uid_type type; |
| 1059 | }; |
| 1060 | |
| 1061 | static int rate_to_scan_rate_flag(unsigned int rate) |
| 1062 | { |
| 1063 | static const int rate_to_scan_rate[IWL_RATE_COUNT] = { |
| 1064 | [IWL_RATE_1M_INDEX] = SCAN_CONFIG_RATE_1M, |
| 1065 | [IWL_RATE_2M_INDEX] = SCAN_CONFIG_RATE_2M, |
| 1066 | [IWL_RATE_5M_INDEX] = SCAN_CONFIG_RATE_5M, |
| 1067 | [IWL_RATE_11M_INDEX] = SCAN_CONFIG_RATE_11M, |
| 1068 | [IWL_RATE_6M_INDEX] = SCAN_CONFIG_RATE_6M, |
| 1069 | [IWL_RATE_9M_INDEX] = SCAN_CONFIG_RATE_9M, |
| 1070 | [IWL_RATE_12M_INDEX] = SCAN_CONFIG_RATE_12M, |
| 1071 | [IWL_RATE_18M_INDEX] = SCAN_CONFIG_RATE_18M, |
| 1072 | [IWL_RATE_24M_INDEX] = SCAN_CONFIG_RATE_24M, |
| 1073 | [IWL_RATE_36M_INDEX] = SCAN_CONFIG_RATE_36M, |
| 1074 | [IWL_RATE_48M_INDEX] = SCAN_CONFIG_RATE_48M, |
| 1075 | [IWL_RATE_54M_INDEX] = SCAN_CONFIG_RATE_54M, |
| 1076 | }; |
| 1077 | |
| 1078 | return rate_to_scan_rate[rate]; |
| 1079 | } |
| 1080 | |
| 1081 | static __le32 iwl_mvm_scan_config_rates(struct iwl_mvm *mvm) |
| 1082 | { |
| 1083 | struct ieee80211_supported_band *band; |
| 1084 | unsigned int rates = 0; |
| 1085 | int i; |
| 1086 | |
| 1087 | band = &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; |
| 1088 | for (i = 0; i < band->n_bitrates; i++) |
| 1089 | rates |= rate_to_scan_rate_flag(band->bitrates[i].hw_value); |
| 1090 | band = &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; |
| 1091 | for (i = 0; i < band->n_bitrates; i++) |
| 1092 | rates |= rate_to_scan_rate_flag(band->bitrates[i].hw_value); |
| 1093 | |
| 1094 | /* Set both basic rates and supported rates */ |
| 1095 | rates |= SCAN_CONFIG_SUPPORTED_RATE(rates); |
| 1096 | |
| 1097 | return cpu_to_le32(rates); |
| 1098 | } |
| 1099 | |
| 1100 | int iwl_mvm_config_scan(struct iwl_mvm *mvm) |
| 1101 | { |
| 1102 | |
| 1103 | struct iwl_scan_config *scan_config; |
| 1104 | struct ieee80211_supported_band *band; |
| 1105 | int num_channels = |
| 1106 | mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels + |
| 1107 | mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; |
| 1108 | int ret, i, j = 0, cmd_size, data_size; |
| 1109 | struct iwl_host_cmd cmd = { |
| 1110 | .id = SCAN_CFG_CMD, |
| 1111 | }; |
| 1112 | |
| 1113 | if (WARN_ON(num_channels > mvm->fw->ucode_capa.n_scan_channels)) |
| 1114 | return -ENOBUFS; |
| 1115 | |
| 1116 | cmd_size = sizeof(*scan_config) + mvm->fw->ucode_capa.n_scan_channels; |
| 1117 | |
| 1118 | scan_config = kzalloc(cmd_size, GFP_KERNEL); |
| 1119 | if (!scan_config) |
| 1120 | return -ENOMEM; |
| 1121 | |
| 1122 | data_size = cmd_size - sizeof(struct iwl_mvm_umac_cmd_hdr); |
| 1123 | scan_config->hdr.size = cpu_to_le16(data_size); |
| 1124 | scan_config->flags = cpu_to_le32(SCAN_CONFIG_FLAG_ACTIVATE | |
| 1125 | SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS | |
| 1126 | SCAN_CONFIG_FLAG_SET_TX_CHAINS | |
| 1127 | SCAN_CONFIG_FLAG_SET_RX_CHAINS | |
| 1128 | SCAN_CONFIG_FLAG_SET_ALL_TIMES | |
| 1129 | SCAN_CONFIG_FLAG_SET_LEGACY_RATES | |
| 1130 | SCAN_CONFIG_FLAG_SET_MAC_ADDR | |
| 1131 | SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS| |
| 1132 | SCAN_CONFIG_N_CHANNELS(num_channels)); |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 1133 | scan_config->tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1134 | scan_config->rx_chains = cpu_to_le32(iwl_mvm_scan_rx_ant(mvm)); |
| 1135 | scan_config->legacy_rates = iwl_mvm_scan_config_rates(mvm); |
| 1136 | scan_config->out_of_channel_time = cpu_to_le32(170); |
| 1137 | scan_config->suspend_time = cpu_to_le32(30); |
| 1138 | scan_config->dwell_active = 20; |
| 1139 | scan_config->dwell_passive = 110; |
| 1140 | scan_config->dwell_fragmented = 20; |
| 1141 | |
| 1142 | memcpy(&scan_config->mac_addr, &mvm->addresses[0].addr, ETH_ALEN); |
| 1143 | |
| 1144 | scan_config->bcast_sta_id = mvm->aux_sta.sta_id; |
| 1145 | scan_config->channel_flags = IWL_CHANNEL_FLAG_EBS | |
| 1146 | IWL_CHANNEL_FLAG_ACCURATE_EBS | |
| 1147 | IWL_CHANNEL_FLAG_EBS_ADD | |
| 1148 | IWL_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE; |
| 1149 | |
| 1150 | band = &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; |
| 1151 | for (i = 0; i < band->n_channels; i++, j++) |
Ilan Peer | a25d40e | 2015-01-23 21:13:01 +0200 | [diff] [blame] | 1152 | scan_config->channel_array[j] = band->channels[i].hw_value; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1153 | band = &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; |
| 1154 | for (i = 0; i < band->n_channels; i++, j++) |
Ilan Peer | a25d40e | 2015-01-23 21:13:01 +0200 | [diff] [blame] | 1155 | scan_config->channel_array[j] = band->channels[i].hw_value; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1156 | |
| 1157 | cmd.data[0] = scan_config; |
| 1158 | cmd.len[0] = cmd_size; |
| 1159 | cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; |
| 1160 | |
| 1161 | IWL_DEBUG_SCAN(mvm, "Sending UMAC scan config\n"); |
| 1162 | |
| 1163 | ret = iwl_mvm_send_cmd(mvm, &cmd); |
| 1164 | |
| 1165 | kfree(scan_config); |
| 1166 | return ret; |
| 1167 | } |
| 1168 | |
| 1169 | static int iwl_mvm_find_scan_uid(struct iwl_mvm *mvm, u32 uid) |
| 1170 | { |
| 1171 | int i; |
| 1172 | |
| 1173 | for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) |
| 1174 | if (mvm->scan_uid[i] == uid) |
| 1175 | return i; |
| 1176 | |
| 1177 | return i; |
| 1178 | } |
| 1179 | |
| 1180 | static int iwl_mvm_find_free_scan_uid(struct iwl_mvm *mvm) |
| 1181 | { |
| 1182 | return iwl_mvm_find_scan_uid(mvm, 0); |
| 1183 | } |
| 1184 | |
| 1185 | static bool iwl_mvm_find_scan_type(struct iwl_mvm *mvm, |
| 1186 | enum iwl_umac_scan_uid_type type) |
| 1187 | { |
| 1188 | int i; |
| 1189 | |
| 1190 | for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) |
| 1191 | if (mvm->scan_uid[i] & type) |
| 1192 | return true; |
| 1193 | |
| 1194 | return false; |
| 1195 | } |
| 1196 | |
Alexander Bondar | 963221b | 2015-03-26 11:07:35 +0200 | [diff] [blame] | 1197 | static int iwl_mvm_find_first_scan(struct iwl_mvm *mvm, |
| 1198 | enum iwl_umac_scan_uid_type type) |
| 1199 | { |
| 1200 | int i; |
| 1201 | |
| 1202 | for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) |
| 1203 | if (mvm->scan_uid[i] & type) |
| 1204 | return i; |
| 1205 | |
| 1206 | return i; |
| 1207 | } |
| 1208 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1209 | static u32 iwl_generate_scan_uid(struct iwl_mvm *mvm, |
| 1210 | enum iwl_umac_scan_uid_type type) |
| 1211 | { |
| 1212 | u32 uid; |
| 1213 | |
| 1214 | /* make sure exactly one bit is on in scan type */ |
| 1215 | WARN_ON(hweight8(type) != 1); |
| 1216 | |
| 1217 | /* |
| 1218 | * Make sure scan uids are unique. If one scan lasts long time while |
| 1219 | * others are completing frequently, the seq number will wrap up and |
| 1220 | * we may have more than one scan with the same uid. |
| 1221 | */ |
| 1222 | do { |
| 1223 | uid = type | (mvm->scan_seq_num << |
| 1224 | IWL_UMAC_SCAN_UID_SEQ_OFFSET); |
| 1225 | mvm->scan_seq_num++; |
| 1226 | } while (iwl_mvm_find_scan_uid(mvm, uid) < |
| 1227 | IWL_MVM_MAX_SIMULTANEOUS_SCANS); |
| 1228 | |
| 1229 | IWL_DEBUG_SCAN(mvm, "Generated scan UID %u\n", uid); |
| 1230 | |
| 1231 | return uid; |
| 1232 | } |
| 1233 | |
| 1234 | static void |
| 1235 | iwl_mvm_build_generic_umac_scan_cmd(struct iwl_mvm *mvm, |
| 1236 | struct iwl_scan_req_umac *cmd, |
| 1237 | struct iwl_mvm_scan_params *params) |
| 1238 | { |
| 1239 | memset(cmd, 0, ksize(cmd)); |
| 1240 | cmd->hdr.size = cpu_to_le16(iwl_mvm_scan_size(mvm) - |
| 1241 | sizeof(struct iwl_mvm_umac_cmd_hdr)); |
| 1242 | cmd->active_dwell = params->dwell[IEEE80211_BAND_2GHZ].active; |
| 1243 | cmd->passive_dwell = params->dwell[IEEE80211_BAND_2GHZ].passive; |
| 1244 | if (params->passive_fragmented) |
| 1245 | cmd->fragmented_dwell = |
David Spinadel | 190f102 | 2015-02-17 12:45:21 +0200 | [diff] [blame] | 1246 | params->dwell[IEEE80211_BAND_2GHZ].fragmented; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1247 | cmd->max_out_time = cpu_to_le32(params->max_out_time); |
| 1248 | cmd->suspend_time = cpu_to_le32(params->suspend_time); |
| 1249 | cmd->scan_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH); |
| 1250 | } |
| 1251 | |
| 1252 | static void |
| 1253 | iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm, |
| 1254 | struct ieee80211_channel **channels, |
| 1255 | int n_channels, u32 ssid_bitmap, |
| 1256 | struct iwl_scan_req_umac *cmd) |
| 1257 | { |
| 1258 | struct iwl_scan_channel_cfg_umac *channel_cfg = (void *)&cmd->data; |
| 1259 | int i; |
| 1260 | |
| 1261 | for (i = 0; i < n_channels; i++) { |
| 1262 | channel_cfg[i].flags = cpu_to_le32(ssid_bitmap); |
| 1263 | channel_cfg[i].channel_num = channels[i]->hw_value; |
| 1264 | channel_cfg[i].iter_count = 1; |
| 1265 | channel_cfg[i].iter_interval = 0; |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids, |
| 1270 | struct cfg80211_ssid *ssids, |
| 1271 | int fragmented) |
| 1272 | { |
| 1273 | int flags = 0; |
| 1274 | |
| 1275 | if (n_ssids == 0) |
| 1276 | flags = IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE; |
| 1277 | |
| 1278 | if (n_ssids == 1 && ssids[0].ssid_len != 0) |
| 1279 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT; |
| 1280 | |
| 1281 | if (fragmented) |
| 1282 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED; |
| 1283 | |
| 1284 | if (iwl_mvm_rrm_scan_needed(mvm)) |
| 1285 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED; |
| 1286 | |
| 1287 | return flags; |
| 1288 | } |
| 1289 | |
| 1290 | int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 1291 | struct ieee80211_scan_request *req) |
| 1292 | { |
| 1293 | struct iwl_host_cmd hcmd = { |
| 1294 | .id = SCAN_REQ_UMAC, |
| 1295 | .len = { iwl_mvm_scan_size(mvm), }, |
| 1296 | .data = { mvm->scan_cmd, }, |
| 1297 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, |
| 1298 | }; |
| 1299 | struct iwl_scan_req_umac *cmd = mvm->scan_cmd; |
| 1300 | struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data + |
| 1301 | sizeof(struct iwl_scan_channel_cfg_umac) * |
| 1302 | mvm->fw->ucode_capa.n_scan_channels; |
| 1303 | struct iwl_mvm_scan_params params = {}; |
| 1304 | u32 uid, flags; |
Johannes Berg | c8660dd | 2014-11-17 15:06:52 +0100 | [diff] [blame] | 1305 | u32 ssid_bitmap = 0; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1306 | int ret, i, uid_idx; |
| 1307 | |
| 1308 | lockdep_assert_held(&mvm->mutex); |
| 1309 | |
| 1310 | uid_idx = iwl_mvm_find_free_scan_uid(mvm); |
| 1311 | if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS) |
| 1312 | return -EBUSY; |
| 1313 | |
| 1314 | /* we should have failed registration if scan_cmd was NULL */ |
| 1315 | if (WARN_ON(mvm->scan_cmd == NULL)) |
| 1316 | return -ENOMEM; |
| 1317 | |
| 1318 | if (WARN_ON(req->req.n_ssids > PROBE_OPTION_MAX || |
| 1319 | req->ies.common_ie_len + |
| 1320 | req->ies.len[NL80211_BAND_2GHZ] + |
| 1321 | req->ies.len[NL80211_BAND_5GHZ] + 24 + 2 > |
| 1322 | SCAN_OFFLOAD_PROBE_REQ_SIZE || req->req.n_channels > |
| 1323 | mvm->fw->ucode_capa.n_scan_channels)) |
| 1324 | return -ENOBUFS; |
| 1325 | |
| 1326 | iwl_mvm_scan_calc_params(mvm, vif, req->req.n_ssids, req->req.flags, |
| 1327 | ¶ms); |
| 1328 | |
| 1329 | iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, ¶ms); |
| 1330 | |
| 1331 | uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN); |
| 1332 | mvm->scan_uid[uid_idx] = uid; |
| 1333 | cmd->uid = cpu_to_le32(uid); |
| 1334 | |
| 1335 | cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH); |
| 1336 | |
| 1337 | flags = iwl_mvm_scan_umac_common_flags(mvm, req->req.n_ssids, |
| 1338 | req->req.ssids, |
| 1339 | params.passive_fragmented); |
| 1340 | |
| 1341 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL; |
| 1342 | |
| 1343 | cmd->general_flags = cpu_to_le32(flags); |
Haim Dreyfuss | 4db6558 | 2015-01-05 15:00:35 +0200 | [diff] [blame] | 1344 | |
| 1345 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS && |
| 1346 | mvm->last_ebs_successful) |
| 1347 | cmd->channel_flags = IWL_SCAN_CHANNEL_FLAG_EBS | |
| 1348 | IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | |
| 1349 | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD; |
| 1350 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1351 | cmd->n_channels = req->req.n_channels; |
| 1352 | |
| 1353 | for (i = 0; i < req->req.n_ssids; i++) |
| 1354 | ssid_bitmap |= BIT(i); |
| 1355 | |
| 1356 | iwl_mvm_umac_scan_cfg_channels(mvm, req->req.channels, |
| 1357 | req->req.n_channels, ssid_bitmap, cmd); |
| 1358 | |
| 1359 | sec_part->schedule[0].iter_count = 1; |
| 1360 | sec_part->delay = 0; |
| 1361 | |
Johannes Berg | effd05a | 2014-11-18 17:21:19 +0100 | [diff] [blame] | 1362 | iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, &sec_part->preq, |
| 1363 | req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ? |
| 1364 | req->req.mac_addr : NULL, |
| 1365 | req->req.mac_addr_mask); |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1366 | |
| 1367 | iwl_mvm_scan_fill_ssids(sec_part->direct_scan, req->req.ssids, |
| 1368 | req->req.n_ssids, 0); |
| 1369 | |
| 1370 | ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 1371 | if (!ret) { |
| 1372 | IWL_DEBUG_SCAN(mvm, |
| 1373 | "Scan request was sent successfully\n"); |
| 1374 | } else { |
| 1375 | /* |
| 1376 | * If the scan failed, it usually means that the FW was unable |
| 1377 | * to allocate the time events. Warn on it, but maybe we |
| 1378 | * should try to send the command again with different params. |
| 1379 | */ |
| 1380 | IWL_ERR(mvm, "Scan failed! ret %d\n", ret); |
| 1381 | } |
| 1382 | return ret; |
| 1383 | } |
| 1384 | |
| 1385 | int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
| 1386 | struct cfg80211_sched_scan_request *req, |
| 1387 | struct ieee80211_scan_ies *ies) |
| 1388 | { |
| 1389 | |
| 1390 | struct iwl_host_cmd hcmd = { |
| 1391 | .id = SCAN_REQ_UMAC, |
| 1392 | .len = { iwl_mvm_scan_size(mvm), }, |
| 1393 | .data = { mvm->scan_cmd, }, |
| 1394 | .dataflags = { IWL_HCMD_DFL_NOCOPY, }, |
| 1395 | }; |
| 1396 | struct iwl_scan_req_umac *cmd = mvm->scan_cmd; |
| 1397 | struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data + |
| 1398 | sizeof(struct iwl_scan_channel_cfg_umac) * |
| 1399 | mvm->fw->ucode_capa.n_scan_channels; |
| 1400 | struct iwl_mvm_scan_params params = {}; |
| 1401 | u32 uid, flags; |
Johannes Berg | c8660dd | 2014-11-17 15:06:52 +0100 | [diff] [blame] | 1402 | u32 ssid_bitmap = 0; |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1403 | int ret, uid_idx; |
| 1404 | |
| 1405 | lockdep_assert_held(&mvm->mutex); |
| 1406 | |
| 1407 | uid_idx = iwl_mvm_find_free_scan_uid(mvm); |
| 1408 | if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS) |
| 1409 | return -EBUSY; |
| 1410 | |
| 1411 | /* we should have failed registration if scan_cmd was NULL */ |
| 1412 | if (WARN_ON(mvm->scan_cmd == NULL)) |
| 1413 | return -ENOMEM; |
| 1414 | |
| 1415 | if (WARN_ON(req->n_ssids > PROBE_OPTION_MAX || |
| 1416 | ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] + |
| 1417 | ies->len[NL80211_BAND_5GHZ] + 24 + 2 > |
| 1418 | SCAN_OFFLOAD_PROBE_REQ_SIZE || req->n_channels > |
| 1419 | mvm->fw->ucode_capa.n_scan_channels)) |
| 1420 | return -ENOBUFS; |
| 1421 | |
| 1422 | iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, |
| 1423 | ¶ms); |
| 1424 | |
| 1425 | iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, ¶ms); |
| 1426 | |
| 1427 | cmd->flags = cpu_to_le32(IWL_UMAC_SCAN_FLAG_PREEMPTIVE); |
| 1428 | |
| 1429 | uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN); |
| 1430 | mvm->scan_uid[uid_idx] = uid; |
| 1431 | cmd->uid = cpu_to_le32(uid); |
| 1432 | |
| 1433 | cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW); |
| 1434 | |
| 1435 | flags = iwl_mvm_scan_umac_common_flags(mvm, req->n_ssids, req->ssids, |
| 1436 | params.passive_fragmented); |
| 1437 | |
| 1438 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC; |
| 1439 | |
| 1440 | if (iwl_mvm_scan_pass_all(mvm, req)) |
| 1441 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL; |
| 1442 | else |
| 1443 | flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH; |
| 1444 | |
| 1445 | cmd->general_flags = cpu_to_le32(flags); |
| 1446 | |
| 1447 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT && |
| 1448 | mvm->last_ebs_successful) |
| 1449 | cmd->channel_flags = IWL_SCAN_CHANNEL_FLAG_EBS | |
| 1450 | IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE | |
| 1451 | IWL_SCAN_CHANNEL_FLAG_CACHE_ADD; |
| 1452 | |
| 1453 | cmd->n_channels = req->n_channels; |
| 1454 | |
| 1455 | iwl_scan_offload_build_ssid(req, sec_part->direct_scan, &ssid_bitmap, |
| 1456 | false); |
| 1457 | |
| 1458 | /* This API uses bits 0-19 instead of 1-20. */ |
| 1459 | ssid_bitmap = ssid_bitmap >> 1; |
| 1460 | |
| 1461 | iwl_mvm_umac_scan_cfg_channels(mvm, req->channels, req->n_channels, |
| 1462 | ssid_bitmap, cmd); |
| 1463 | |
| 1464 | sec_part->schedule[0].interval = |
| 1465 | cpu_to_le16(req->interval / MSEC_PER_SEC); |
| 1466 | sec_part->schedule[0].iter_count = 0xff; |
| 1467 | |
Luciano Coelho | 2250fd9 | 2014-12-03 10:52:26 +0200 | [diff] [blame] | 1468 | if (req->delay > U16_MAX) { |
| 1469 | IWL_DEBUG_SCAN(mvm, |
| 1470 | "delay value is > 16-bits, set to max possible\n"); |
| 1471 | sec_part->delay = cpu_to_le16(U16_MAX); |
| 1472 | } else { |
| 1473 | sec_part->delay = cpu_to_le16(req->delay); |
| 1474 | } |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1475 | |
Johannes Berg | effd05a | 2014-11-18 17:21:19 +0100 | [diff] [blame] | 1476 | iwl_mvm_build_unified_scan_probe(mvm, vif, ies, &sec_part->preq, |
| 1477 | req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ? |
| 1478 | req->mac_addr : NULL, |
| 1479 | req->mac_addr_mask); |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1480 | |
| 1481 | ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 1482 | if (!ret) { |
| 1483 | IWL_DEBUG_SCAN(mvm, |
| 1484 | "Sched scan request was sent successfully\n"); |
| 1485 | } else { |
| 1486 | /* |
| 1487 | * If the scan failed, it usually means that the FW was unable |
| 1488 | * to allocate the time events. Warn on it, but maybe we |
| 1489 | * should try to send the command again with different params. |
| 1490 | */ |
| 1491 | IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret); |
| 1492 | } |
| 1493 | return ret; |
| 1494 | } |
| 1495 | |
| 1496 | int iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm, |
| 1497 | struct iwl_rx_cmd_buffer *rxb, |
| 1498 | struct iwl_device_cmd *cmd) |
| 1499 | { |
| 1500 | struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 1501 | struct iwl_umac_scan_complete *notif = (void *)pkt->data; |
| 1502 | u32 uid = __le32_to_cpu(notif->uid); |
| 1503 | bool sched = !!(uid & IWL_UMAC_SCAN_UID_SCHED_SCAN); |
| 1504 | int uid_idx = iwl_mvm_find_scan_uid(mvm, uid); |
| 1505 | |
David Spinadel | 2992a32 | 2014-11-10 11:16:53 +0200 | [diff] [blame] | 1506 | /* |
| 1507 | * Scan uid may be set to zero in case of scan abort request from above. |
| 1508 | */ |
| 1509 | if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS) |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1510 | return 0; |
| 1511 | |
| 1512 | IWL_DEBUG_SCAN(mvm, |
| 1513 | "Scan completed, uid %u type %s, status %s, EBS status %s\n", |
| 1514 | uid, sched ? "sched" : "regular", |
| 1515 | notif->status == IWL_SCAN_OFFLOAD_COMPLETED ? |
| 1516 | "completed" : "aborted", |
| 1517 | notif->ebs_status == IWL_SCAN_EBS_SUCCESS ? |
| 1518 | "success" : "failed"); |
| 1519 | |
Haim Dreyfuss | 5a4b2af | 2015-01-13 11:54:51 +0200 | [diff] [blame] | 1520 | if (notif->ebs_status) |
| 1521 | mvm->last_ebs_successful = false; |
| 1522 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1523 | mvm->scan_uid[uid_idx] = 0; |
| 1524 | |
| 1525 | if (!sched) { |
| 1526 | ieee80211_scan_completed(mvm->hw, |
| 1527 | notif->status == |
| 1528 | IWL_SCAN_OFFLOAD_ABORTED); |
| 1529 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
| 1530 | } else if (!iwl_mvm_find_scan_type(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN)) { |
| 1531 | ieee80211_sched_scan_stopped(mvm->hw); |
| 1532 | } else { |
| 1533 | IWL_DEBUG_SCAN(mvm, "Another sched scan is running\n"); |
| 1534 | } |
| 1535 | |
| 1536 | return 0; |
| 1537 | } |
| 1538 | |
| 1539 | static bool iwl_scan_umac_done_check(struct iwl_notif_wait_data *notif_wait, |
| 1540 | struct iwl_rx_packet *pkt, void *data) |
| 1541 | { |
| 1542 | struct iwl_umac_scan_done *scan_done = data; |
| 1543 | struct iwl_umac_scan_complete *notif = (void *)pkt->data; |
| 1544 | u32 uid = __le32_to_cpu(notif->uid); |
| 1545 | int uid_idx = iwl_mvm_find_scan_uid(scan_done->mvm, uid); |
| 1546 | |
| 1547 | if (WARN_ON(pkt->hdr.cmd != SCAN_COMPLETE_UMAC)) |
| 1548 | return false; |
| 1549 | |
| 1550 | if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS) |
| 1551 | return false; |
| 1552 | |
| 1553 | /* |
| 1554 | * Clear scan uid of scans that was aborted from above and completed |
Haim Dreyfuss | 5a4b2af | 2015-01-13 11:54:51 +0200 | [diff] [blame] | 1555 | * in FW so the RX handler does nothing. Set last_ebs_successful here if |
| 1556 | * needed. |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1557 | */ |
| 1558 | scan_done->mvm->scan_uid[uid_idx] = 0; |
| 1559 | |
Haim Dreyfuss | 5a4b2af | 2015-01-13 11:54:51 +0200 | [diff] [blame] | 1560 | if (notif->ebs_status) |
| 1561 | scan_done->mvm->last_ebs_successful = false; |
| 1562 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1563 | return !iwl_mvm_find_scan_type(scan_done->mvm, scan_done->type); |
| 1564 | } |
| 1565 | |
| 1566 | static int iwl_umac_scan_abort_one(struct iwl_mvm *mvm, u32 uid) |
| 1567 | { |
| 1568 | struct iwl_umac_scan_abort cmd = { |
| 1569 | .hdr.size = cpu_to_le16(sizeof(struct iwl_umac_scan_abort) - |
| 1570 | sizeof(struct iwl_mvm_umac_cmd_hdr)), |
| 1571 | .uid = cpu_to_le32(uid), |
| 1572 | }; |
| 1573 | |
| 1574 | lockdep_assert_held(&mvm->mutex); |
| 1575 | |
| 1576 | IWL_DEBUG_SCAN(mvm, "Sending scan abort, uid %u\n", uid); |
| 1577 | |
| 1578 | return iwl_mvm_send_cmd_pdu(mvm, SCAN_ABORT_UMAC, 0, sizeof(cmd), &cmd); |
| 1579 | } |
| 1580 | |
| 1581 | static int iwl_umac_scan_stop(struct iwl_mvm *mvm, |
| 1582 | enum iwl_umac_scan_uid_type type, bool notify) |
| 1583 | { |
| 1584 | struct iwl_notification_wait wait_scan_done; |
| 1585 | static const u8 scan_done_notif[] = { SCAN_COMPLETE_UMAC, }; |
| 1586 | struct iwl_umac_scan_done scan_done = { |
| 1587 | .mvm = mvm, |
| 1588 | .type = type, |
| 1589 | }; |
| 1590 | int i, ret = -EIO; |
| 1591 | |
| 1592 | iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_done, |
| 1593 | scan_done_notif, |
| 1594 | ARRAY_SIZE(scan_done_notif), |
| 1595 | iwl_scan_umac_done_check, &scan_done); |
| 1596 | |
| 1597 | IWL_DEBUG_SCAN(mvm, "Preparing to stop scan, type %x\n", type); |
| 1598 | |
| 1599 | for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) { |
| 1600 | if (mvm->scan_uid[i] & type) { |
| 1601 | int err; |
| 1602 | |
| 1603 | if (iwl_mvm_is_radio_killed(mvm) && |
| 1604 | (type & IWL_UMAC_SCAN_UID_REG_SCAN)) { |
| 1605 | ieee80211_scan_completed(mvm->hw, true); |
| 1606 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
| 1607 | break; |
| 1608 | } |
| 1609 | |
| 1610 | err = iwl_umac_scan_abort_one(mvm, mvm->scan_uid[i]); |
| 1611 | if (!err) |
| 1612 | ret = 0; |
| 1613 | } |
| 1614 | } |
| 1615 | |
| 1616 | if (ret) { |
| 1617 | IWL_DEBUG_SCAN(mvm, "Couldn't stop scan\n"); |
| 1618 | iwl_remove_notification(&mvm->notif_wait, &wait_scan_done); |
| 1619 | return ret; |
| 1620 | } |
| 1621 | |
| 1622 | ret = iwl_wait_notification(&mvm->notif_wait, &wait_scan_done, 1 * HZ); |
| 1623 | if (ret) |
| 1624 | return ret; |
| 1625 | |
| 1626 | if (notify) { |
| 1627 | if (type & IWL_UMAC_SCAN_UID_SCHED_SCAN) |
| 1628 | ieee80211_sched_scan_stopped(mvm->hw); |
| 1629 | if (type & IWL_UMAC_SCAN_UID_REG_SCAN) { |
| 1630 | ieee80211_scan_completed(mvm->hw, true); |
| 1631 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); |
| 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | return ret; |
| 1636 | } |
| 1637 | |
| 1638 | int iwl_mvm_scan_size(struct iwl_mvm *mvm) |
| 1639 | { |
| 1640 | if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) |
| 1641 | return sizeof(struct iwl_scan_req_umac) + |
| 1642 | sizeof(struct iwl_scan_channel_cfg_umac) * |
| 1643 | mvm->fw->ucode_capa.n_scan_channels + |
| 1644 | sizeof(struct iwl_scan_req_umac_tail); |
| 1645 | |
Luciano Coelho | 1f94038 | 2015-02-10 13:03:38 +0200 | [diff] [blame] | 1646 | return sizeof(struct iwl_scan_req_unified_lmac) + |
| 1647 | sizeof(struct iwl_scan_channel_cfg_lmac) * |
| 1648 | mvm->fw->ucode_capa.n_scan_channels + |
| 1649 | sizeof(struct iwl_scan_probe_req); |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1650 | } |
David Spinadel | 4ffb365 | 2015-03-10 10:06:02 +0200 | [diff] [blame] | 1651 | |
| 1652 | /* |
| 1653 | * This function is used in nic restart flow, to inform mac80211 about scans |
| 1654 | * that was aborted by restart flow or by an assert. |
| 1655 | */ |
| 1656 | void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm) |
| 1657 | { |
| 1658 | if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) { |
Alexander Bondar | 963221b | 2015-03-26 11:07:35 +0200 | [diff] [blame] | 1659 | u32 uid, i; |
| 1660 | |
| 1661 | uid = iwl_mvm_find_first_scan(mvm, IWL_UMAC_SCAN_UID_REG_SCAN); |
| 1662 | if (uid < IWL_MVM_MAX_SIMULTANEOUS_SCANS) { |
David Spinadel | 4ffb365 | 2015-03-10 10:06:02 +0200 | [diff] [blame] | 1663 | ieee80211_scan_completed(mvm->hw, true); |
Alexander Bondar | 963221b | 2015-03-26 11:07:35 +0200 | [diff] [blame] | 1664 | mvm->scan_uid[uid] = 0; |
| 1665 | } |
| 1666 | uid = iwl_mvm_find_first_scan(mvm, |
| 1667 | IWL_UMAC_SCAN_UID_SCHED_SCAN); |
| 1668 | if (uid < IWL_MVM_MAX_SIMULTANEOUS_SCANS && !mvm->restart_fw) { |
David Spinadel | 4ffb365 | 2015-03-10 10:06:02 +0200 | [diff] [blame] | 1669 | ieee80211_sched_scan_stopped(mvm->hw); |
Alexander Bondar | 963221b | 2015-03-26 11:07:35 +0200 | [diff] [blame] | 1670 | mvm->scan_uid[uid] = 0; |
| 1671 | } |
| 1672 | |
| 1673 | /* We shouldn't have any UIDs still set. Loop over all the |
| 1674 | * UIDs to make sure there's nothing left there and warn if |
| 1675 | * any is found. |
| 1676 | */ |
| 1677 | for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) { |
| 1678 | if (WARN_ONCE(mvm->scan_uid[i], |
| 1679 | "UMAC scan UID %d was not cleaned\n", |
| 1680 | mvm->scan_uid[i])) |
| 1681 | mvm->scan_uid[i] = 0; |
| 1682 | } |
David Spinadel | 4ffb365 | 2015-03-10 10:06:02 +0200 | [diff] [blame] | 1683 | } else { |
| 1684 | switch (mvm->scan_status) { |
| 1685 | case IWL_MVM_SCAN_NONE: |
| 1686 | break; |
| 1687 | case IWL_MVM_SCAN_OS: |
| 1688 | ieee80211_scan_completed(mvm->hw, true); |
| 1689 | break; |
| 1690 | case IWL_MVM_SCAN_SCHED: |
| 1691 | /* |
| 1692 | * Sched scan will be restarted by mac80211 in |
| 1693 | * restart_hw, so do not report if FW is about to be |
| 1694 | * restarted. |
| 1695 | */ |
| 1696 | if (!mvm->restart_fw) |
| 1697 | ieee80211_sched_scan_stopped(mvm->hw); |
| 1698 | break; |
| 1699 | } |
| 1700 | } |
| 1701 | } |