Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
Kiet Lam | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 26 | * |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 27 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 28 | |
| 29 | |
Kiet Lam | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 30 | |
| 31 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 32 | /**======================================================================== |
| 33 | |
| 34 | \file wlan_hdd_cfg80211.c |
| 35 | |
| 36 | \brief WLAN Host Device Driver implementation |
| 37 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 38 | ========================================================================*/ |
| 39 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 40 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 42 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 43 | |
| 44 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 45 | This section contains comments describing changes made to the module. |
| 46 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | |
| 48 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 49 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 50 | |
| 51 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 52 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 53 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 54 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 55 | |
| 56 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 57 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 58 | ==========================================================================*/ |
| 59 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 60 | |
| 61 | #include <linux/version.h> |
| 62 | #include <linux/module.h> |
| 63 | #include <linux/kernel.h> |
| 64 | #include <linux/init.h> |
| 65 | #include <linux/wireless.h> |
| 66 | #include <wlan_hdd_includes.h> |
| 67 | #include <net/arp.h> |
| 68 | #include <net/cfg80211.h> |
| 69 | #include <linux/wireless.h> |
| 70 | #include <wlan_hdd_wowl.h> |
| 71 | #include <aniGlobal.h> |
| 72 | #include "ccmApi.h" |
| 73 | #include "sirParams.h" |
| 74 | #include "dot11f.h" |
| 75 | #include "wlan_hdd_assoc.h" |
| 76 | #include "wlan_hdd_wext.h" |
| 77 | #include "sme_Api.h" |
| 78 | #include "wlan_hdd_p2p.h" |
| 79 | #include "wlan_hdd_cfg80211.h" |
| 80 | #include "wlan_hdd_hostapd.h" |
| 81 | #include "sapInternal.h" |
| 82 | #include "wlan_hdd_softap_tx_rx.h" |
| 83 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 84 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 85 | #include "wlan_hdd_power.h" |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 86 | #include "wlan_hdd_trace.h" |
| 87 | #include "vos_types.h" |
| 88 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 89 | #ifdef WLAN_BTAMP_FEATURE |
| 90 | #include "bap_hdd_misc.h" |
| 91 | #endif |
| 92 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 93 | #include "wlan_hdd_tdls.h" |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 94 | #include "wlan_hdd_wmm.h" |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 95 | #include "wlan_qct_wda.h" |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 96 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 97 | #include "wlan_hdd_dev_pwr.h" |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 98 | #include "qwlan_version.h" |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 99 | #include "wlan_logging_sock_svc.h" |
Agrawal Ashish | cfe8328 | 2016-09-29 13:03:45 +0530 | [diff] [blame] | 100 | #include "wlan_hdd_misc.h" |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 101 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 102 | |
| 103 | #define g_mode_rates_size (12) |
| 104 | #define a_mode_rates_size (8) |
| 105 | #define FREQ_BASE_80211G (2407) |
| 106 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 107 | #define MAX_SCAN_SSID 9 |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 108 | #define MAX_PENDING_LOG 5 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 109 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
krunal soni | 2a6a906 | 2014-02-11 14:14:23 -0800 | [diff] [blame] | 110 | ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | |
| 112 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 113 | .band = IEEE80211_BAND_2GHZ, \ |
| 114 | .center_freq = (freq), \ |
| 115 | .hw_value = (chan),\ |
| 116 | .flags = (flag), \ |
| 117 | .max_antenna_gain = 0 ,\ |
| 118 | .max_power = 30, \ |
| 119 | } |
| 120 | |
| 121 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 122 | .band = IEEE80211_BAND_5GHZ, \ |
| 123 | .center_freq = (freq), \ |
| 124 | .hw_value = (chan),\ |
| 125 | .flags = (flag), \ |
| 126 | .max_antenna_gain = 0 ,\ |
| 127 | .max_power = 30, \ |
| 128 | } |
| 129 | |
| 130 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 131 | {\ |
| 132 | .bitrate = rate, \ |
| 133 | .hw_value = rate_id, \ |
| 134 | .flags = flag, \ |
| 135 | } |
| 136 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 137 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 138 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 139 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 140 | #endif |
| 141 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 142 | #define HDD_CHANNEL_14 14 |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 143 | #define WLAN_HDD_MAX_FEATURE_SET 8 |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 144 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 145 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 146 | /* |
| 147 | * Used to allocate the size of 4096 for the link layer stats. |
| 148 | * The size of 4096 is considered assuming that all data per |
| 149 | * respective event fit with in the limit.Please take a call |
| 150 | * on the limit based on the data requirements on link layer |
| 151 | * statistics. |
| 152 | */ |
| 153 | #define LL_STATS_EVENT_BUF_SIZE 4096 |
| 154 | #endif |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 155 | #ifdef WLAN_FEATURE_EXTSCAN |
| 156 | /* |
| 157 | * Used to allocate the size of 4096 for the EXTScan NL data. |
| 158 | * The size of 4096 is considered assuming that all data per |
| 159 | * respective event fit with in the limit.Please take a call |
| 160 | * on the limit based on the data requirements. |
| 161 | */ |
| 162 | |
| 163 | #define EXTSCAN_EVENT_BUF_SIZE 4096 |
| 164 | #define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32 |
| 165 | #endif |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 166 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 167 | /*EXT TDLS*/ |
| 168 | /* |
| 169 | * Used to allocate the size of 4096 for the TDLS. |
| 170 | * The size of 4096 is considered assuming that all data per |
| 171 | * respective event fit with in the limit.Please take a call |
| 172 | * on the limit based on the data requirements on link layer |
| 173 | * statistics. |
| 174 | */ |
| 175 | #define EXTTDLS_EVENT_BUF_SIZE 4096 |
| 176 | |
Hanumantha Reddy Pothula | ca1d1cc | 2015-10-26 15:37:35 +0530 | [diff] [blame] | 177 | /* |
| 178 | * Values for Mac spoofing feature |
| 179 | * |
| 180 | */ |
| 181 | #define MAC_ADDR_SPOOFING_FW_HOST_DISABLE 0 |
| 182 | #define MAC_ADDR_SPOOFING_FW_HOST_ENABLE 1 |
| 183 | #define MAC_ADDR_SPOOFING_FW_ENABLE_HOST_DISABLE 2 |
Padma, Santhosh Kumar | db2d75b | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 184 | #define MAC_ADDR_SPOOFING_DEFER_INTERVAL 10 //in ms |
| 185 | |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 186 | /* |
| 187 | * max_sched_scan_plans defined to 10 |
| 188 | */ |
| 189 | #define MAX_SCHED_SCAN_PLANS 10 |
Hanumantha Reddy Pothula | ca1d1cc | 2015-10-26 15:37:35 +0530 | [diff] [blame] | 190 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 191 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 192 | { |
| 193 | WLAN_CIPHER_SUITE_WEP40, |
| 194 | WLAN_CIPHER_SUITE_WEP104, |
| 195 | WLAN_CIPHER_SUITE_TKIP, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 196 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 197 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 198 | WLAN_CIPHER_SUITE_KRK, |
| 199 | WLAN_CIPHER_SUITE_CCMP, |
| 200 | #else |
| 201 | WLAN_CIPHER_SUITE_CCMP, |
| 202 | #endif |
| 203 | #ifdef FEATURE_WLAN_WAPI |
| 204 | WLAN_CIPHER_SUITE_SMS4, |
| 205 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 206 | #ifdef WLAN_FEATURE_11W |
| 207 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 208 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 209 | }; |
| 210 | |
| 211 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 212 | { |
| 213 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 214 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 215 | } |
| 216 | |
Agrawal Ashish | 97dec50 | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 217 | const static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 218 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 219 | HDD2GHZCHAN(2412, 1, 0) , |
| 220 | HDD2GHZCHAN(2417, 2, 0) , |
| 221 | HDD2GHZCHAN(2422, 3, 0) , |
| 222 | HDD2GHZCHAN(2427, 4, 0) , |
| 223 | HDD2GHZCHAN(2432, 5, 0) , |
| 224 | HDD2GHZCHAN(2437, 6, 0) , |
| 225 | HDD2GHZCHAN(2442, 7, 0) , |
| 226 | HDD2GHZCHAN(2447, 8, 0) , |
| 227 | HDD2GHZCHAN(2452, 9, 0) , |
| 228 | HDD2GHZCHAN(2457, 10, 0) , |
| 229 | HDD2GHZCHAN(2462, 11, 0) , |
| 230 | HDD2GHZCHAN(2467, 12, 0) , |
| 231 | HDD2GHZCHAN(2472, 13, 0) , |
| 232 | HDD2GHZCHAN(2484, 14, 0) , |
| 233 | }; |
| 234 | |
Agrawal Ashish | 97dec50 | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 235 | const static struct ieee80211_channel hdd_channels_5_GHZ[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 236 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 237 | HDD5GHZCHAN(4920, 240, 0) , |
| 238 | HDD5GHZCHAN(4940, 244, 0) , |
| 239 | HDD5GHZCHAN(4960, 248, 0) , |
| 240 | HDD5GHZCHAN(4980, 252, 0) , |
| 241 | HDD5GHZCHAN(5040, 208, 0) , |
| 242 | HDD5GHZCHAN(5060, 212, 0) , |
| 243 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 244 | HDD5GHZCHAN(5180, 36, 0) , |
| 245 | HDD5GHZCHAN(5200, 40, 0) , |
| 246 | HDD5GHZCHAN(5220, 44, 0) , |
| 247 | HDD5GHZCHAN(5240, 48, 0) , |
| 248 | HDD5GHZCHAN(5260, 52, 0) , |
| 249 | HDD5GHZCHAN(5280, 56, 0) , |
| 250 | HDD5GHZCHAN(5300, 60, 0) , |
| 251 | HDD5GHZCHAN(5320, 64, 0) , |
| 252 | HDD5GHZCHAN(5500,100, 0) , |
| 253 | HDD5GHZCHAN(5520,104, 0) , |
| 254 | HDD5GHZCHAN(5540,108, 0) , |
| 255 | HDD5GHZCHAN(5560,112, 0) , |
| 256 | HDD5GHZCHAN(5580,116, 0) , |
| 257 | HDD5GHZCHAN(5600,120, 0) , |
| 258 | HDD5GHZCHAN(5620,124, 0) , |
| 259 | HDD5GHZCHAN(5640,128, 0) , |
| 260 | HDD5GHZCHAN(5660,132, 0) , |
| 261 | HDD5GHZCHAN(5680,136, 0) , |
| 262 | HDD5GHZCHAN(5700,140, 0) , |
Leo Chang | 80de3c2 | 2013-11-26 10:52:12 -0800 | [diff] [blame] | 263 | #ifdef FEATURE_WLAN_CH144 |
| 264 | HDD5GHZCHAN(5720,144, 0) , |
| 265 | #endif /* FEATURE_WLAN_CH144 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 266 | HDD5GHZCHAN(5745,149, 0) , |
| 267 | HDD5GHZCHAN(5765,153, 0) , |
| 268 | HDD5GHZCHAN(5785,157, 0) , |
| 269 | HDD5GHZCHAN(5805,161, 0) , |
| 270 | HDD5GHZCHAN(5825,165, 0) , |
| 271 | }; |
| 272 | |
| 273 | static struct ieee80211_rate g_mode_rates[] = |
| 274 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 275 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 276 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 277 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 278 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 279 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 280 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 281 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 282 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 283 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 284 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 285 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 286 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 287 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 288 | |
| 289 | static struct ieee80211_rate a_mode_rates[] = |
| 290 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 291 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 292 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 293 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 294 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 295 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 296 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 297 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 298 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 299 | }; |
| 300 | |
| 301 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 302 | { |
Agrawal Ashish | 97dec50 | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 303 | .channels = NULL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 304 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 305 | .band = IEEE80211_BAND_2GHZ, |
| 306 | .bitrates = g_mode_rates, |
| 307 | .n_bitrates = g_mode_rates_size, |
| 308 | .ht_cap.ht_supported = 1, |
| 309 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 310 | | IEEE80211_HT_CAP_GRN_FLD |
| 311 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 312 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 313 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 314 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 315 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 316 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 317 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 318 | }; |
| 319 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 321 | { |
Agrawal Ashish | 97dec50 | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 322 | .channels = NULL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 323 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 324 | .band = IEEE80211_BAND_5GHZ, |
| 325 | .bitrates = a_mode_rates, |
| 326 | .n_bitrates = a_mode_rates_size, |
| 327 | .ht_cap.ht_supported = 1, |
| 328 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 329 | | IEEE80211_HT_CAP_GRN_FLD |
| 330 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 331 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 332 | | IEEE80211_HT_CAP_SGI_40 |
| 333 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 334 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 335 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 336 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 337 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 338 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 339 | }; |
| 340 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 341 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 342 | TX/RX direction for each kind of interface */ |
| 343 | static const struct ieee80211_txrx_stypes |
| 344 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 345 | [NL80211_IFTYPE_STATION] = { |
| 346 | .tx = 0xffff, |
| 347 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 348 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 349 | }, |
| 350 | [NL80211_IFTYPE_AP] = { |
| 351 | .tx = 0xffff, |
| 352 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 353 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 354 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 355 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 356 | BIT(SIR_MAC_MGMT_AUTH) | |
| 357 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 358 | BIT(SIR_MAC_MGMT_ACTION), |
| 359 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 360 | [NL80211_IFTYPE_ADHOC] = { |
| 361 | .tx = 0xffff, |
| 362 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 363 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 364 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 365 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 366 | BIT(SIR_MAC_MGMT_AUTH) | |
| 367 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 368 | BIT(SIR_MAC_MGMT_ACTION), |
| 369 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 370 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 371 | .tx = 0xffff, |
| 372 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 373 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 374 | }, |
| 375 | [NL80211_IFTYPE_P2P_GO] = { |
| 376 | /* This is also same as for SoftAP */ |
| 377 | .tx = 0xffff, |
| 378 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 379 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 380 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 381 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 382 | BIT(SIR_MAC_MGMT_AUTH) | |
| 383 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 384 | BIT(SIR_MAC_MGMT_ACTION), |
| 385 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 386 | }; |
| 387 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 388 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 389 | static const struct ieee80211_iface_limit |
| 390 | wlan_hdd_iface_limit[] = { |
| 391 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 392 | /* max = 3 ; Our driver create two interfaces during driver init |
| 393 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 394 | * interface until a group is formed. In JB architecture, once the |
| 395 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 396 | * Client. |
| 397 | * When supplicant remove the group, it first issue a set interface |
| 398 | * cmd to change the mode back to Station. In JB this works fine as |
| 399 | * we advertize two station type interface during driver init. |
| 400 | * Some vendors create separate interface for P2P GO/Client, |
| 401 | * after group formation(Third one). But while group remove |
| 402 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 403 | * But as we advertized only two sta type interfaces nl80211 was |
| 404 | * returning error for the third one which was leading to failure in |
| 405 | * delete interface. Ideally while removing the group, supplicant |
| 406 | * should not try to change the 3rd interface mode to Station type. |
| 407 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 408 | * interface type to 3 |
| 409 | */ |
| 410 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 411 | .types = BIT(NL80211_IFTYPE_STATION), |
| 412 | }, |
| 413 | { |
| 414 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 415 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 416 | }, |
| 417 | { |
| 418 | .max = 1, |
| 419 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 420 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 421 | }, |
| 422 | }; |
| 423 | |
| 424 | /* By default, only single channel concurrency is allowed */ |
| 425 | static struct ieee80211_iface_combination |
| 426 | wlan_hdd_iface_combination = { |
| 427 | .limits = wlan_hdd_iface_limit, |
| 428 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 429 | /* |
| 430 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 431 | * and p2p0 interfaces during driver init |
| 432 | * Some vendors create separate interface for P2P operations. |
| 433 | * wlan0: STA interface |
| 434 | * p2p0: P2P Device interface, action frames goes |
| 435 | * through this interface. |
| 436 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 437 | * created for p2p operations(GO/CLIENT interface). |
| 438 | */ |
| 439 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 440 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 441 | .beacon_int_infra_match = false, |
| 442 | }; |
| 443 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 444 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 445 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 446 | |
| 447 | /* Data rate 100KBPS based on IE Index */ |
| 448 | struct index_data_rate_type |
| 449 | { |
| 450 | v_U8_t beacon_rate_index; |
| 451 | v_U16_t supported_rate[4]; |
| 452 | }; |
| 453 | |
| 454 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 455 | The IDX field is the rate index |
| 456 | The HI field is the rate when RSSI is strong or being ignored |
| 457 | (in this case we report actual rate) |
| 458 | The MID field is the rate when RSSI is moderate |
| 459 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 460 | The LO field is the rate when RSSI is low |
| 461 | (in this case we don't report rates, actual current rate used) |
| 462 | */ |
| 463 | static const struct |
| 464 | { |
| 465 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 466 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 467 | } supported_data_rate[] = |
| 468 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 469 | /* IDX HI HM LM LO (RSSI-based index */ |
| 470 | {2, { 10, 10, 10, 0}}, |
| 471 | {4, { 20, 20, 10, 0}}, |
| 472 | {11, { 55, 20, 10, 0}}, |
| 473 | {12, { 60, 55, 20, 0}}, |
| 474 | {18, { 90, 55, 20, 0}}, |
| 475 | {22, {110, 55, 20, 0}}, |
| 476 | {24, {120, 90, 60, 0}}, |
| 477 | {36, {180, 120, 60, 0}}, |
| 478 | {44, {220, 180, 60, 0}}, |
| 479 | {48, {240, 180, 90, 0}}, |
| 480 | {66, {330, 180, 90, 0}}, |
| 481 | {72, {360, 240, 90, 0}}, |
| 482 | {96, {480, 240, 120, 0}}, |
| 483 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 484 | }; |
| 485 | |
| 486 | /* MCS Based rate table */ |
| 487 | static struct index_data_rate_type supported_mcs_rate[] = |
| 488 | { |
| 489 | /* MCS L20 L40 S20 S40 */ |
| 490 | {0, {65, 135, 72, 150}}, |
| 491 | {1, {130, 270, 144, 300}}, |
| 492 | {2, {195, 405, 217, 450}}, |
| 493 | {3, {260, 540, 289, 600}}, |
| 494 | {4, {390, 810, 433, 900}}, |
| 495 | {5, {520, 1080, 578, 1200}}, |
| 496 | {6, {585, 1215, 650, 1350}}, |
| 497 | {7, {650, 1350, 722, 1500}} |
| 498 | }; |
| 499 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 500 | #ifdef WLAN_FEATURE_11AC |
| 501 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 502 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 503 | |
| 504 | struct index_vht_data_rate_type |
| 505 | { |
| 506 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 507 | v_U16_t supported_VHT80_rate[2]; |
| 508 | v_U16_t supported_VHT40_rate[2]; |
| 509 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 510 | }; |
| 511 | |
| 512 | typedef enum |
| 513 | { |
| 514 | DATA_RATE_11AC_MAX_MCS_7, |
| 515 | DATA_RATE_11AC_MAX_MCS_8, |
| 516 | DATA_RATE_11AC_MAX_MCS_9, |
| 517 | DATA_RATE_11AC_MAX_MCS_NA |
| 518 | } eDataRate11ACMaxMcs; |
| 519 | |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 520 | /* SSID broadcast type */ |
| 521 | typedef enum eSSIDBcastType |
| 522 | { |
| 523 | eBCAST_UNKNOWN = 0, |
| 524 | eBCAST_NORMAL = 1, |
| 525 | eBCAST_HIDDEN = 2, |
| 526 | } tSSIDBcastType; |
| 527 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 528 | /* MCS Based VHT rate table */ |
| 529 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 530 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 531 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 532 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 533 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 534 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 535 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 536 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 537 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 538 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 539 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 540 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 541 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 542 | }; |
| 543 | #endif /* WLAN_FEATURE_11AC */ |
| 544 | |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 545 | /*array index points to MCS and array value points respective rssi*/ |
| 546 | static int rssiMcsTbl[][10] = |
| 547 | { |
| 548 | /*MCS 0 1 2 3 4 5 6 7 8 9*/ |
| 549 | {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20 |
| 550 | {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40 |
| 551 | {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80 |
| 552 | }; |
| 553 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 554 | extern struct net_device_ops net_ops_struct; |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 555 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 556 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter); |
| 557 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 558 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 559 | #ifdef WLAN_NL80211_TESTMODE |
| 560 | enum wlan_hdd_tm_attr |
| 561 | { |
| 562 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 563 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 564 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 565 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 566 | /* keep last */ |
| 567 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 568 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 569 | }; |
| 570 | |
| 571 | enum wlan_hdd_tm_cmd |
| 572 | { |
| 573 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 574 | }; |
| 575 | |
| 576 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 577 | |
| 578 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 579 | { |
| 580 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 581 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 582 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 583 | }; |
| 584 | #endif /* WLAN_NL80211_TESTMODE */ |
| 585 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 586 | #ifdef FEATURE_WLAN_CH_AVOID |
| 587 | /* |
| 588 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 589 | * This is called when wlan driver needs to send vendor specific |
| 590 | * avoid frequency range event to userspace |
| 591 | */ |
| 592 | int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx, |
| 593 | tHddAvoidFreqList *pAvoidFreqList) |
| 594 | { |
| 595 | struct sk_buff *vendor_event; |
| 596 | |
| 597 | ENTER(); |
| 598 | |
| 599 | if (!pHddCtx) |
| 600 | { |
| 601 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 602 | "%s: HDD context is null", __func__); |
| 603 | return -1; |
| 604 | } |
| 605 | |
| 606 | if (!pAvoidFreqList) |
| 607 | { |
| 608 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 609 | "%s: pAvoidFreqList is null", __func__); |
| 610 | return -1; |
| 611 | } |
| 612 | |
| 613 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 614 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 615 | NULL, |
| 616 | #endif |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 617 | sizeof(tHddAvoidFreqList), |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 618 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 619 | GFP_KERNEL); |
| 620 | if (!vendor_event) |
| 621 | { |
| 622 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 623 | "%s: cfg80211_vendor_event_alloc failed", __func__); |
| 624 | return -1; |
| 625 | } |
| 626 | |
| 627 | memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)), |
| 628 | (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList)); |
| 629 | |
| 630 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 631 | |
| 632 | EXIT(); |
| 633 | return 0; |
| 634 | } |
| 635 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 636 | |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 637 | /* |
| 638 | * FUNCTION: __wlan_hdd_cfg80211_nan_request |
| 639 | * This is called when wlan driver needs to send vendor specific |
| 640 | * nan request event. |
| 641 | */ |
| 642 | static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy, |
| 643 | struct wireless_dev *wdev, |
| 644 | const void *data, int data_len) |
| 645 | { |
| 646 | tNanRequestReq nan_req; |
| 647 | VOS_STATUS status; |
| 648 | int ret_val = -1; |
Srinivas Dasari | a3f11c0 | 2015-03-20 13:15:20 +0530 | [diff] [blame] | 649 | struct net_device *dev = wdev->netdev; |
| 650 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 651 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 652 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 653 | |
| 654 | if (0 == data_len) |
| 655 | { |
| 656 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 657 | FL("NAN - Invalid Request, length = 0")); |
| 658 | return ret_val; |
| 659 | } |
| 660 | |
| 661 | if (NULL == data) |
| 662 | { |
| 663 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 664 | FL("NAN - Invalid Request, data is NULL")); |
| 665 | return ret_val; |
| 666 | } |
| 667 | |
| 668 | status = wlan_hdd_validate_context(pHddCtx); |
| 669 | if (0 != status) |
| 670 | { |
| 671 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 672 | FL("HDD context is not valid")); |
| 673 | return -EINVAL; |
| 674 | } |
| 675 | |
| 676 | hddLog(LOG1, FL("Received NAN command")); |
| 677 | vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 678 | (tANI_U8 *)data, data_len); |
| 679 | |
| 680 | /* check the NAN Capability */ |
| 681 | if (TRUE != sme_IsFeatureSupportedByFW(NAN)) |
| 682 | { |
| 683 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 684 | FL("NAN is not supported by Firmware")); |
| 685 | return -EINVAL; |
| 686 | } |
| 687 | |
| 688 | nan_req.request_data_len = data_len; |
| 689 | nan_req.request_data = data; |
| 690 | |
Srinivas Dasari | a3f11c0 | 2015-03-20 13:15:20 +0530 | [diff] [blame] | 691 | status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId); |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 692 | if (VOS_STATUS_SUCCESS == status) |
| 693 | { |
| 694 | ret_val = 0; |
| 695 | } |
| 696 | return ret_val; |
| 697 | } |
| 698 | |
| 699 | /* |
| 700 | * FUNCTION: wlan_hdd_cfg80211_nan_request |
| 701 | * Wrapper to protect the nan vendor command from ssr |
| 702 | */ |
| 703 | static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy, |
| 704 | struct wireless_dev *wdev, |
| 705 | const void *data, int data_len) |
| 706 | { |
| 707 | int ret; |
| 708 | |
| 709 | vos_ssr_protect(__func__); |
| 710 | ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len); |
| 711 | vos_ssr_unprotect(__func__); |
| 712 | |
| 713 | return ret; |
| 714 | } |
| 715 | |
| 716 | /* |
| 717 | * FUNCTION: wlan_hdd_cfg80211_nan_callback |
| 718 | * This is a callback function and it gets called |
| 719 | * when we need to report nan response event to |
| 720 | * upper layers. |
| 721 | */ |
| 722 | static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg) |
| 723 | { |
| 724 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 725 | struct sk_buff *vendor_event; |
| 726 | int status; |
| 727 | tSirNanEvent *data; |
| 728 | |
| 729 | ENTER(); |
| 730 | if (NULL == msg) |
| 731 | { |
| 732 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 733 | FL(" msg received here is null")); |
| 734 | return; |
| 735 | } |
| 736 | data = msg; |
| 737 | |
| 738 | status = wlan_hdd_validate_context(pHddCtx); |
| 739 | |
| 740 | if (0 != status) |
| 741 | { |
| 742 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 743 | FL("HDD context is not valid")); |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 748 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 749 | NULL, |
| 750 | #endif |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 751 | data->event_data_len + |
| 752 | NLMSG_HDRLEN, |
| 753 | QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX, |
| 754 | GFP_KERNEL); |
| 755 | |
| 756 | if (!vendor_event) |
| 757 | { |
| 758 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 759 | FL("cfg80211_vendor_event_alloc failed")); |
| 760 | return; |
| 761 | } |
| 762 | if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN, |
| 763 | data->event_data_len, data->event_data)) |
| 764 | { |
| 765 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 766 | FL("QCA_WLAN_VENDOR_ATTR_NAN put fail")); |
| 767 | kfree_skb(vendor_event); |
| 768 | return; |
| 769 | } |
| 770 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 771 | EXIT(); |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | * FUNCTION: wlan_hdd_cfg80211_nan_init |
| 776 | * This function is called to register the callback to sme layer |
| 777 | */ |
| 778 | inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx) |
| 779 | { |
| 780 | sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback); |
| 781 | } |
| 782 | |
| 783 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 784 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 785 | |
| 786 | static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats, |
| 787 | struct sk_buff *vendor_event) |
| 788 | { |
| 789 | if (nla_put_u8(vendor_event, |
| 790 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE, |
| 791 | stats->rate.preamble) || |
| 792 | nla_put_u8(vendor_event, |
| 793 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS, |
| 794 | stats->rate.nss) || |
| 795 | nla_put_u8(vendor_event, |
| 796 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW, |
| 797 | stats->rate.bw) || |
| 798 | nla_put_u8(vendor_event, |
| 799 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX, |
| 800 | stats->rate.rateMcsIdx) || |
| 801 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE, |
| 802 | stats->rate.bitrate ) || |
| 803 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU, |
| 804 | stats->txMpdu ) || |
| 805 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU, |
| 806 | stats->rxMpdu ) || |
| 807 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST, |
| 808 | stats->mpduLost ) || |
| 809 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES, |
| 810 | stats->retries) || |
| 811 | nla_put_u32(vendor_event, |
| 812 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT, |
| 813 | stats->retriesShort ) || |
| 814 | nla_put_u32(vendor_event, |
| 815 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG, |
| 816 | stats->retriesLong)) |
| 817 | { |
| 818 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 819 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 820 | return FALSE; |
| 821 | } |
| 822 | return TRUE; |
| 823 | } |
| 824 | |
| 825 | static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats, |
| 826 | struct sk_buff *vendor_event) |
| 827 | { |
| 828 | u32 i = 0; |
| 829 | struct nlattr *rateInfo; |
| 830 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE, |
| 831 | stats->type) || |
| 832 | nla_put(vendor_event, |
| 833 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS, |
| 834 | VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) || |
| 835 | nla_put_u32(vendor_event, |
| 836 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES, |
| 837 | stats->capabilities) || |
| 838 | nla_put_u32(vendor_event, |
| 839 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES, |
| 840 | stats->numRate)) |
| 841 | { |
| 842 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 843 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 844 | goto error; |
| 845 | } |
| 846 | |
| 847 | rateInfo = nla_nest_start(vendor_event, |
| 848 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 849 | if(!rateInfo) |
| 850 | return FALSE; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 851 | for (i = 0; i < stats->numRate; i++) |
| 852 | { |
| 853 | struct nlattr *rates; |
| 854 | tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *) |
| 855 | stats->rateStats + |
| 856 | (i * sizeof(tSirWifiRateStat))); |
| 857 | rates = nla_nest_start(vendor_event, i); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 858 | if(!rates) |
| 859 | return FALSE; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 860 | |
| 861 | if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event)) |
| 862 | { |
| 863 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 864 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 865 | return FALSE; |
| 866 | } |
| 867 | nla_nest_end(vendor_event, rates); |
| 868 | } |
| 869 | nla_nest_end(vendor_event, rateInfo); |
| 870 | |
| 871 | return TRUE; |
| 872 | error: |
| 873 | return FALSE; |
| 874 | } |
| 875 | |
| 876 | static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats, |
| 877 | struct sk_buff *vendor_event) |
| 878 | { |
| 879 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC, |
| 880 | stats->ac ) || |
| 881 | nla_put_u32(vendor_event, |
| 882 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU, |
| 883 | stats->txMpdu ) || |
| 884 | nla_put_u32(vendor_event, |
| 885 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU, |
| 886 | stats->rxMpdu ) || |
| 887 | nla_put_u32(vendor_event, |
| 888 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST, |
| 889 | stats->txMcast ) || |
| 890 | nla_put_u32(vendor_event, |
| 891 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST, |
| 892 | stats->rxMcast ) || |
| 893 | nla_put_u32(vendor_event, |
| 894 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU, |
| 895 | stats->rxAmpdu ) || |
| 896 | nla_put_u32(vendor_event, |
| 897 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU, |
| 898 | stats->txAmpdu ) || |
| 899 | nla_put_u32(vendor_event, |
| 900 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST, |
| 901 | stats->mpduLost )|| |
| 902 | nla_put_u32(vendor_event, |
| 903 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES, |
| 904 | stats->retries ) || |
| 905 | nla_put_u32(vendor_event, |
| 906 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT, |
| 907 | stats->retriesShort ) || |
| 908 | nla_put_u32(vendor_event, |
| 909 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG, |
| 910 | stats->retriesLong ) || |
| 911 | nla_put_u32(vendor_event, |
| 912 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN, |
| 913 | stats->contentionTimeMin ) || |
| 914 | nla_put_u32(vendor_event, |
| 915 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX, |
| 916 | stats->contentionTimeMax ) || |
| 917 | nla_put_u32(vendor_event, |
| 918 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG, |
| 919 | stats->contentionTimeAvg ) || |
| 920 | nla_put_u32(vendor_event, |
| 921 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES, |
| 922 | stats->contentionNumSamples )) |
| 923 | { |
| 924 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 925 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 926 | return FALSE; |
| 927 | } |
| 928 | return TRUE; |
| 929 | } |
| 930 | |
| 931 | static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats, |
| 932 | struct sk_buff *vendor_event) |
| 933 | { |
Dino Mycle | c8f3f33 | 2014-07-21 16:48:27 +0530 | [diff] [blame] | 934 | if (nla_put_s32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 935 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) || |
| 936 | nla_put(vendor_event, |
| 937 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR, |
| 938 | VOS_MAC_ADDR_SIZE, stats->macAddr) || |
| 939 | nla_put_u32(vendor_event, |
| 940 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE, |
| 941 | stats->state ) || |
| 942 | nla_put_u32(vendor_event, |
| 943 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING, |
| 944 | stats->roaming ) || |
| 945 | nla_put_u32(vendor_event, |
| 946 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES, |
| 947 | stats->capabilities ) || |
| 948 | nla_put(vendor_event, |
| 949 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID, |
| 950 | strlen(stats->ssid), stats->ssid) || |
| 951 | nla_put(vendor_event, |
| 952 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID, |
| 953 | WNI_CFG_BSSID_LEN, stats->bssid) || |
| 954 | nla_put(vendor_event, |
| 955 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR, |
| 956 | WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) || |
| 957 | nla_put(vendor_event, |
| 958 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR, |
| 959 | WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr) |
| 960 | ) |
| 961 | { |
| 962 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 963 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 964 | return FALSE; |
| 965 | } |
| 966 | return TRUE; |
| 967 | } |
| 968 | |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 969 | static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter, |
| 970 | tpSirWifiIfaceStat pWifiIfaceStat, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 971 | struct sk_buff *vendor_event) |
| 972 | { |
| 973 | int i = 0; |
| 974 | struct nlattr *wmmInfo; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 975 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 976 | WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL; |
Srinivas Dasari | a8a304f | 2014-11-15 16:13:37 +0530 | [diff] [blame] | 977 | tSirWifiWmmAcStat accessclassStats; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 978 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 979 | if (FALSE == put_wifi_interface_info( |
| 980 | &pWifiIfaceStat->info, |
| 981 | vendor_event)) |
| 982 | { |
| 983 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 984 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 985 | return FALSE; |
| 986 | |
| 987 | } |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 988 | pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *) |
| 989 | vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType)); |
| 990 | if (NULL == pWifiIfaceStatTL) |
| 991 | { |
| 992 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed")); |
| 993 | return FALSE; |
| 994 | } |
| 995 | |
Srinivas Dasari | a8a304f | 2014-11-15 16:13:37 +0530 | [diff] [blame] | 996 | accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK]; |
| 997 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] = |
| 998 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE]; |
| 999 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats; |
| 1000 | |
| 1001 | accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac; |
| 1002 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac = |
| 1003 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac; |
| 1004 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1005 | |
| 1006 | if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED) |
| 1007 | { |
| 1008 | if (VOS_STATUS_SUCCESS == |
| 1009 | WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 1010 | pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL)) |
| 1011 | { |
| 1012 | /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are |
| 1013 | * obtained from TL structure |
| 1014 | */ |
| 1015 | |
| 1016 | pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx + |
| 1017 | pWifiIfaceStatTL->mgmtRx; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1018 | pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData; |
| 1019 | |
Srinivas Dasari | 9894743 | 2014-11-07 19:41:24 +0530 | [diff] [blame] | 1020 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast |
| 1021 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast; |
| 1022 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast |
| 1023 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast; |
| 1024 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast |
| 1025 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast; |
| 1026 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast |
| 1027 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1028 | |
Srinivas Dasari | 9894743 | 2014-11-07 19:41:24 +0530 | [diff] [blame] | 1029 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu |
| 1030 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu; |
| 1031 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu |
| 1032 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu; |
| 1033 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu |
| 1034 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu; |
| 1035 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu |
| 1036 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1037 | |
Srinivas Dasari | 9894743 | 2014-11-07 19:41:24 +0530 | [diff] [blame] | 1038 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu |
| 1039 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu; |
| 1040 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu |
| 1041 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu; |
| 1042 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu |
| 1043 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu; |
| 1044 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu |
| 1045 | = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu; |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1046 | } |
| 1047 | else |
| 1048 | { |
| 1049 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL")); |
| 1050 | } |
| 1051 | |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1052 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast = |
| 1053 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO]; |
| 1054 | pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast = |
| 1055 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI]; |
| 1056 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast = |
| 1057 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE]; |
| 1058 | pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast = |
| 1059 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK]; |
| 1060 | } |
| 1061 | else |
| 1062 | { |
| 1063 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated")); |
| 1064 | } |
| 1065 | |
| 1066 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1067 | |
| 1068 | if (nla_put_u32(vendor_event, |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1069 | QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE, |
| 1070 | QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) || |
| 1071 | nla_put_u32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1072 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX, |
| 1073 | pWifiIfaceStat->beaconRx) || |
| 1074 | nla_put_u32(vendor_event, |
| 1075 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX, |
| 1076 | pWifiIfaceStat->mgmtRx) || |
| 1077 | nla_put_u32(vendor_event, |
| 1078 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX, |
| 1079 | pWifiIfaceStat->mgmtActionRx) || |
| 1080 | nla_put_u32(vendor_event, |
| 1081 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX, |
| 1082 | pWifiIfaceStat->mgmtActionTx) || |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1083 | nla_put_s32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1084 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT, |
| 1085 | pWifiIfaceStat->rssiMgmt) || |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1086 | nla_put_s32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1087 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA, |
| 1088 | pWifiIfaceStat->rssiData) || |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1089 | nla_put_s32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1090 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK, |
| 1091 | pWifiIfaceStat->rssiAck)) |
| 1092 | { |
| 1093 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Mukul Sharma | f1bd932 | 2015-10-20 16:03:42 +0530 | [diff] [blame] | 1094 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 1095 | vos_mem_free(pWifiIfaceStatTL); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1096 | return FALSE; |
| 1097 | } |
| 1098 | |
Mukul Sharma | f1bd932 | 2015-10-20 16:03:42 +0530 | [diff] [blame] | 1099 | #ifdef FEATURE_EXT_LL_STAT |
| 1100 | /* |
| 1101 | * Ensure when EXT_LL_STAT is supported by both host and fwr, |
| 1102 | * then host should send Leaky AP stats to upper layer, |
| 1103 | * otherwise no need to send these stats. |
| 1104 | */ |
| 1105 | if(sme_IsFeatureSupportedByFW(EXT_LL_STAT) && |
| 1106 | sme_IsFeatureSupportedByDriver(EXT_LL_STAT) |
| 1107 | ) |
| 1108 | { |
| 1109 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1110 | FL("EXT_LL_STAT is supported by fwr and host %u %u %u %llu"), |
| 1111 | pWifiIfaceStat->leakyApStat.is_leaky_ap, |
| 1112 | pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked, |
| 1113 | pWifiIfaceStat->leakyApStat.rx_leak_window, |
| 1114 | pWifiIfaceStat->leakyApStat.avg_bcn_spread); |
| 1115 | if (nla_put_u32(vendor_event, |
| 1116 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_DETECTED, |
| 1117 | pWifiIfaceStat->leakyApStat.is_leaky_ap) || |
| 1118 | nla_put_u32(vendor_event, |
| 1119 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_AVG_NUM_FRAMES_LEAKED, |
| 1120 | pWifiIfaceStat->leakyApStat.avg_rx_frms_leaked) || |
| 1121 | nla_put_u32(vendor_event, |
| 1122 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_LEAKY_AP_GUARD_TIME, |
| 1123 | pWifiIfaceStat->leakyApStat.rx_leak_window) || |
| 1124 | nla_put_u64(vendor_event, |
| 1125 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_AVERAGE_TSF_OFFSET, |
| 1126 | pWifiIfaceStat->leakyApStat.avg_bcn_spread)) |
| 1127 | { |
| 1128 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1129 | FL("EXT_LL_STAT put fail")); |
| 1130 | vos_mem_free(pWifiIfaceStatTL); |
| 1131 | return FALSE; |
| 1132 | } |
| 1133 | } |
| 1134 | #endif |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1135 | wmmInfo = nla_nest_start(vendor_event, |
| 1136 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1137 | if(!wmmInfo) |
| 1138 | { |
| 1139 | vos_mem_free(pWifiIfaceStatTL); |
| 1140 | return FALSE; |
| 1141 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1142 | for (i = 0; i < WIFI_AC_MAX; i++) |
| 1143 | { |
| 1144 | struct nlattr *wmmStats; |
| 1145 | wmmStats = nla_nest_start(vendor_event, i); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1146 | if(!wmmStats) |
| 1147 | { |
| 1148 | vos_mem_free(pWifiIfaceStatTL); |
| 1149 | return FALSE; |
| 1150 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1151 | if (FALSE == put_wifi_wmm_ac_stat( |
| 1152 | &pWifiIfaceStat->AccessclassStats[i], |
| 1153 | vendor_event)) |
| 1154 | { |
| 1155 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1156 | FL("QCA_WLAN_VENDOR_ATTR put Fail")); |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1157 | vos_mem_free(pWifiIfaceStatTL); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1158 | return FALSE; |
| 1159 | } |
| 1160 | |
| 1161 | nla_nest_end(vendor_event, wmmStats); |
| 1162 | } |
| 1163 | nla_nest_end(vendor_event, wmmInfo); |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1164 | vos_mem_free(pWifiIfaceStatTL); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1165 | return TRUE; |
| 1166 | } |
| 1167 | |
| 1168 | static tSirWifiInterfaceMode |
| 1169 | hdd_map_device_to_ll_iface_mode ( int deviceMode ) |
| 1170 | { |
| 1171 | switch (deviceMode) |
| 1172 | { |
| 1173 | case WLAN_HDD_INFRA_STATION: |
| 1174 | return WIFI_INTERFACE_STA; |
| 1175 | case WLAN_HDD_SOFTAP: |
| 1176 | return WIFI_INTERFACE_SOFTAP; |
| 1177 | case WLAN_HDD_P2P_CLIENT: |
| 1178 | return WIFI_INTERFACE_P2P_CLIENT; |
| 1179 | case WLAN_HDD_P2P_GO: |
| 1180 | return WIFI_INTERFACE_P2P_GO; |
| 1181 | case WLAN_HDD_IBSS: |
| 1182 | return WIFI_INTERFACE_IBSS; |
| 1183 | default: |
Dino Mycle | c8f3f33 | 2014-07-21 16:48:27 +0530 | [diff] [blame] | 1184 | return WIFI_INTERFACE_UNKNOWN; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter, |
| 1189 | tpSirWifiInterfaceInfo pInfo) |
| 1190 | { |
| 1191 | v_U8_t *staMac = NULL; |
| 1192 | hdd_station_ctx_t *pHddStaCtx; |
| 1193 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1194 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
| 1195 | |
| 1196 | pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode); |
| 1197 | |
| 1198 | vos_mem_copy(pInfo->macAddr, |
| 1199 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
| 1200 | |
| 1201 | if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 1202 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 1203 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))) |
| 1204 | { |
| 1205 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1206 | if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) |
| 1207 | { |
| 1208 | pInfo->state = WIFI_DISCONNECTED; |
| 1209 | } |
| 1210 | if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) |
| 1211 | { |
| 1212 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1213 | "%s: Session ID %d, Connection is in progress", __func__, |
| 1214 | pAdapter->sessionId); |
| 1215 | pInfo->state = WIFI_ASSOCIATING; |
| 1216 | } |
| 1217 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 1218 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 1219 | { |
| 1220 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 1221 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1222 | "%s: client " MAC_ADDRESS_STR |
| 1223 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 1224 | MAC_ADDR_ARRAY(staMac)); |
| 1225 | pInfo->state = WIFI_AUTHENTICATING; |
| 1226 | } |
| 1227 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 1228 | { |
| 1229 | pInfo->state = WIFI_ASSOCIATED; |
| 1230 | vos_mem_copy(pInfo->bssid, |
| 1231 | &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN); |
| 1232 | vos_mem_copy(pInfo->ssid, |
| 1233 | pHddStaCtx->conn_info.SSID.SSID.ssId, |
| 1234 | pHddStaCtx->conn_info.SSID.SSID.length); |
| 1235 | //NULL Terminate the string. |
| 1236 | pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0; |
| 1237 | } |
| 1238 | } |
| 1239 | vos_mem_copy(pInfo->countryStr, |
| 1240 | pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN); |
| 1241 | |
| 1242 | vos_mem_copy(pInfo->apCountryStr, |
| 1243 | pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN); |
| 1244 | |
| 1245 | return TRUE; |
| 1246 | } |
| 1247 | |
| 1248 | /* |
| 1249 | * hdd_link_layer_process_peer_stats () - This function is called after |
| 1250 | * receiving Link Layer Peer statistics from FW.This function converts |
| 1251 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1252 | * layers. |
| 1253 | */ |
| 1254 | static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter, |
| 1255 | v_VOID_t *pData) |
| 1256 | { |
| 1257 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1258 | tpSirWifiPeerStat pWifiPeerStat; |
| 1259 | tpSirWifiPeerInfo pWifiPeerInfo; |
| 1260 | struct nlattr *peerInfo; |
| 1261 | struct sk_buff *vendor_event; |
| 1262 | int status, i; |
| 1263 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1264 | ENTER(); |
| 1265 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1266 | status = wlan_hdd_validate_context(pHddCtx); |
| 1267 | if (0 != status) |
| 1268 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1269 | return; |
| 1270 | } |
| 1271 | |
| 1272 | pWifiPeerStat = (tpSirWifiPeerStat) pData; |
| 1273 | |
| 1274 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1275 | "LL_STATS_PEER_ALL : numPeers %u", |
| 1276 | pWifiPeerStat->numPeers); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1277 | /* |
| 1278 | * Allocate a size of 4096 for the peer stats comprising |
| 1279 | * each of size = sizeof (tSirWifiPeerInfo) + numRate * |
| 1280 | * sizeof (tSirWifiRateStat).Each field is put with an |
| 1281 | * NL attribute.The size of 4096 is considered assuming |
| 1282 | * that number of rates shall not exceed beyond 50 with |
| 1283 | * the sizeof (tSirWifiRateStat) being 32. |
| 1284 | */ |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1285 | vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, |
| 1286 | LL_STATS_EVENT_BUF_SIZE); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1287 | if (!vendor_event) |
| 1288 | { |
| 1289 | hddLog(VOS_TRACE_LEVEL_ERROR, |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1290 | "%s: cfg80211_vendor_cmd_alloc_reply_skb failed", |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1291 | __func__); |
| 1292 | return; |
| 1293 | } |
| 1294 | if (nla_put_u32(vendor_event, |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1295 | QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE, |
| 1296 | QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) || |
| 1297 | nla_put_u32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1298 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS, |
| 1299 | pWifiPeerStat->numPeers)) |
| 1300 | { |
| 1301 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1302 | "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__); |
| 1303 | kfree_skb(vendor_event); |
| 1304 | return; |
| 1305 | } |
| 1306 | |
| 1307 | peerInfo = nla_nest_start(vendor_event, |
| 1308 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1309 | if(!peerInfo) |
| 1310 | { |
| 1311 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1312 | "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail", |
| 1313 | __func__); |
| 1314 | kfree_skb(vendor_event); |
| 1315 | return; |
| 1316 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1317 | |
| 1318 | pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *) |
| 1319 | pWifiPeerStat->peerInfo); |
| 1320 | |
| 1321 | for (i = 1; i <= pWifiPeerStat->numPeers; i++) |
| 1322 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1323 | int numRate = pWifiPeerInfo->numRate; |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1324 | struct nlattr *peers = nla_nest_start(vendor_event, i); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1325 | |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1326 | if(!peers) |
| 1327 | { |
| 1328 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1329 | "%s: peer stats put fail", |
| 1330 | __func__); |
| 1331 | kfree_skb(vendor_event); |
| 1332 | return; |
| 1333 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1334 | if (FALSE == put_wifi_peer_info( |
| 1335 | pWifiPeerInfo, vendor_event)) |
| 1336 | { |
| 1337 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1338 | "%s: put_wifi_peer_info put fail", __func__); |
| 1339 | kfree_skb(vendor_event); |
| 1340 | return; |
| 1341 | } |
| 1342 | |
| 1343 | pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *) |
| 1344 | pWifiPeerStat->peerInfo + |
| 1345 | (i * sizeof(tSirWifiPeerInfo)) + |
| 1346 | (numRate * sizeof (tSirWifiRateStat))); |
| 1347 | nla_nest_end(vendor_event, peers); |
| 1348 | } |
| 1349 | nla_nest_end(vendor_event, peerInfo); |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1350 | cfg80211_vendor_cmd_reply(vendor_event); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1351 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1352 | } |
| 1353 | |
| 1354 | /* |
| 1355 | * hdd_link_layer_process_iface_stats () - This function is called after |
| 1356 | * receiving Link Layer Interface statistics from FW.This function converts |
| 1357 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1358 | * layers. |
| 1359 | */ |
| 1360 | static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter, |
| 1361 | v_VOID_t *pData) |
| 1362 | { |
| 1363 | tpSirWifiIfaceStat pWifiIfaceStat; |
| 1364 | struct sk_buff *vendor_event; |
| 1365 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1366 | int status; |
| 1367 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1368 | ENTER(); |
| 1369 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1370 | status = wlan_hdd_validate_context(pHddCtx); |
| 1371 | if (0 != status) |
| 1372 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1373 | return; |
| 1374 | } |
| 1375 | /* |
| 1376 | * Allocate a size of 4096 for the interface stats comprising |
| 1377 | * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered |
| 1378 | * assuming that all these fit with in the limit.Please take |
| 1379 | * a call on the limit based on the data requirements on |
| 1380 | * interface statistics. |
| 1381 | */ |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1382 | vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, |
| 1383 | LL_STATS_EVENT_BUF_SIZE); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1384 | if (!vendor_event) |
| 1385 | { |
| 1386 | hddLog(VOS_TRACE_LEVEL_ERROR, |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1387 | FL("cfg80211_vendor_cmd_alloc_reply_skb failed") ); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1388 | return; |
| 1389 | } |
| 1390 | |
| 1391 | pWifiIfaceStat = (tpSirWifiIfaceStat) pData; |
| 1392 | |
Dino Mycle | 3b9536d | 2014-07-09 22:05:24 +0530 | [diff] [blame] | 1393 | |
| 1394 | if (FALSE == hdd_get_interface_info( pAdapter, |
| 1395 | &pWifiIfaceStat->info)) |
| 1396 | { |
| 1397 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1398 | FL("hdd_get_interface_info get fail") ); |
| 1399 | kfree_skb(vendor_event); |
| 1400 | return; |
| 1401 | } |
| 1402 | |
| 1403 | if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat, |
| 1404 | vendor_event)) |
| 1405 | { |
| 1406 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1407 | FL("put_wifi_iface_stats fail") ); |
| 1408 | kfree_skb(vendor_event); |
| 1409 | return; |
| 1410 | } |
| 1411 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1412 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1413 | "WMI_LINK_STATS_IFACE Data"); |
| 1414 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1415 | cfg80211_vendor_cmd_reply(vendor_event); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1416 | |
| 1417 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1418 | } |
| 1419 | |
| 1420 | /* |
| 1421 | * hdd_link_layer_process_radio_stats () - This function is called after |
| 1422 | * receiving Link Layer Radio statistics from FW.This function converts |
| 1423 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1424 | * layers. |
| 1425 | */ |
| 1426 | static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter, |
| 1427 | v_VOID_t *pData) |
| 1428 | { |
| 1429 | int status, i; |
| 1430 | tpSirWifiRadioStat pWifiRadioStat; |
| 1431 | tpSirWifiChannelStats pWifiChannelStats; |
| 1432 | struct sk_buff *vendor_event; |
| 1433 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1434 | struct nlattr *chList; |
| 1435 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1436 | ENTER(); |
| 1437 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1438 | status = wlan_hdd_validate_context(pHddCtx); |
| 1439 | if (0 != status) |
| 1440 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1441 | return; |
| 1442 | } |
| 1443 | pWifiRadioStat = (tpSirWifiRadioStat) pData; |
| 1444 | |
| 1445 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1446 | "LL_STATS_RADIO" |
Ravi Kumar Bokka | 9306592 | 2016-10-27 13:52:34 +0530 | [diff] [blame] | 1447 | " number of radios = %u" |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1448 | " radio is %d onTime is %u " |
| 1449 | " txTime is %u rxTime is %u " |
| 1450 | " onTimeScan is %u onTimeNbd is %u " |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1451 | " onTimeEXTScan is %u onTimeRoamScan is %u " |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1452 | " onTimePnoScan is %u onTimeHs20 is %u " |
| 1453 | " numChannels is %u", |
Ravi Kumar Bokka | 9306592 | 2016-10-27 13:52:34 +0530 | [diff] [blame] | 1454 | NUM_RADIOS, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1455 | pWifiRadioStat->radio, pWifiRadioStat->onTime, |
| 1456 | pWifiRadioStat->txTime, pWifiRadioStat->rxTime, |
| 1457 | pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1458 | pWifiRadioStat->onTimeEXTScan, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1459 | pWifiRadioStat->onTimeRoamScan, |
| 1460 | pWifiRadioStat->onTimePnoScan, |
| 1461 | pWifiRadioStat->onTimeHs20, |
| 1462 | pWifiRadioStat->numChannels); |
| 1463 | /* |
| 1464 | * Allocate a size of 4096 for the Radio stats comprising |
| 1465 | * sizeof (tSirWifiRadioStat) + numChannels * sizeof |
| 1466 | * (tSirWifiChannelStats).Each channel data is put with an |
| 1467 | * NL attribute.The size of 4096 is considered assuming that |
| 1468 | * number of channels shall not exceed beyond 60 with the |
| 1469 | * sizeof (tSirWifiChannelStats) being 24 bytes. |
| 1470 | */ |
| 1471 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1472 | vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, |
| 1473 | LL_STATS_EVENT_BUF_SIZE); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1474 | if (!vendor_event) |
| 1475 | { |
| 1476 | hddLog(VOS_TRACE_LEVEL_ERROR, |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1477 | FL("cfg80211_vendor_cmd_alloc_reply_skb failed") ); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1478 | return; |
| 1479 | } |
| 1480 | |
| 1481 | if (nla_put_u32(vendor_event, |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1482 | QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE, |
| 1483 | QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) || |
| 1484 | nla_put_u32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1485 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID, |
| 1486 | pWifiRadioStat->radio) || |
| 1487 | nla_put_u32(vendor_event, |
Ravi Kumar Bokka | 9306592 | 2016-10-27 13:52:34 +0530 | [diff] [blame] | 1488 | QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS, |
| 1489 | NUM_RADIOS) || |
| 1490 | nla_put_u32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1491 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME, |
| 1492 | pWifiRadioStat->onTime) || |
| 1493 | nla_put_u32(vendor_event, |
| 1494 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME, |
| 1495 | pWifiRadioStat->txTime) || |
| 1496 | nla_put_u32(vendor_event, |
| 1497 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME, |
| 1498 | pWifiRadioStat->rxTime) || |
| 1499 | nla_put_u32(vendor_event, |
| 1500 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN, |
| 1501 | pWifiRadioStat->onTimeScan) || |
| 1502 | nla_put_u32(vendor_event, |
| 1503 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD, |
| 1504 | pWifiRadioStat->onTimeNbd) || |
| 1505 | nla_put_u32(vendor_event, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1506 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN, |
| 1507 | pWifiRadioStat->onTimeEXTScan)|| |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1508 | nla_put_u32(vendor_event, |
| 1509 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN, |
| 1510 | pWifiRadioStat->onTimeRoamScan) || |
| 1511 | nla_put_u32(vendor_event, |
| 1512 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN, |
| 1513 | pWifiRadioStat->onTimePnoScan) || |
| 1514 | nla_put_u32(vendor_event, |
| 1515 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20, |
| 1516 | pWifiRadioStat->onTimeHs20) || |
| 1517 | nla_put_u32(vendor_event, |
| 1518 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS, |
| 1519 | pWifiRadioStat->numChannels)) |
| 1520 | { |
| 1521 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1522 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 1523 | kfree_skb(vendor_event); |
| 1524 | return ; |
| 1525 | } |
| 1526 | |
| 1527 | chList = nla_nest_start(vendor_event, |
| 1528 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1529 | if(!chList) |
| 1530 | { |
| 1531 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1532 | "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail", |
| 1533 | __func__); |
| 1534 | kfree_skb(vendor_event); |
| 1535 | return; |
| 1536 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1537 | for (i = 0; i < pWifiRadioStat->numChannels; i++) |
| 1538 | { |
| 1539 | struct nlattr *chInfo; |
| 1540 | |
| 1541 | pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*) |
| 1542 | pWifiRadioStat->channels + |
| 1543 | (i * sizeof(tSirWifiChannelStats))); |
| 1544 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1545 | chInfo = nla_nest_start(vendor_event, i); |
Sushant Kaushik | ee1f55e | 2015-01-22 11:27:01 +0530 | [diff] [blame] | 1546 | if(!chInfo) |
| 1547 | { |
| 1548 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1549 | "%s: failed to put chInfo", |
| 1550 | __func__); |
| 1551 | kfree_skb(vendor_event); |
| 1552 | return; |
| 1553 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1554 | |
| 1555 | if (nla_put_u32(vendor_event, |
| 1556 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH, |
| 1557 | pWifiChannelStats->channel.width) || |
| 1558 | nla_put_u32(vendor_event, |
| 1559 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ, |
| 1560 | pWifiChannelStats->channel.centerFreq) || |
| 1561 | nla_put_u32(vendor_event, |
| 1562 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0, |
| 1563 | pWifiChannelStats->channel.centerFreq0) || |
| 1564 | nla_put_u32(vendor_event, |
| 1565 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1, |
| 1566 | pWifiChannelStats->channel.centerFreq1) || |
| 1567 | nla_put_u32(vendor_event, |
| 1568 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME, |
| 1569 | pWifiChannelStats->onTime) || |
| 1570 | nla_put_u32(vendor_event, |
| 1571 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME, |
| 1572 | pWifiChannelStats->ccaBusyTime)) |
| 1573 | { |
| 1574 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1575 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1576 | kfree_skb(vendor_event); |
| 1577 | return ; |
| 1578 | } |
| 1579 | nla_nest_end(vendor_event, chInfo); |
| 1580 | } |
| 1581 | nla_nest_end(vendor_event, chList); |
| 1582 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1583 | cfg80211_vendor_cmd_reply(vendor_event); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1584 | |
| 1585 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1586 | return; |
| 1587 | } |
| 1588 | |
| 1589 | /* |
| 1590 | * hdd_link_layer_stats_ind_callback () - This function is called after |
| 1591 | * receiving Link Layer indications from FW.This callback converts the firmware |
| 1592 | * data to the NL data and send the same to the kernel/upper layers. |
| 1593 | */ |
| 1594 | static void hdd_link_layer_stats_ind_callback ( void *pCtx, |
| 1595 | int indType, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1596 | void *pRsp, u8 *macAddr) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1597 | { |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1598 | hdd_context_t *pHddCtx = (hdd_context_t *)pCtx; |
| 1599 | hdd_adapter_t *pAdapter = NULL; |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1600 | struct hdd_ll_stats_context *context; |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1601 | tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1602 | int status; |
| 1603 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1604 | ENTER(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1605 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1606 | status = wlan_hdd_validate_context(pHddCtx); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1607 | if (0 != status) |
| 1608 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1609 | return; |
| 1610 | } |
| 1611 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1612 | pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr); |
| 1613 | if (NULL == pAdapter) |
| 1614 | { |
| 1615 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1616 | FL(" MAC address %pM does not exist with host"), |
| 1617 | macAddr); |
| 1618 | return; |
| 1619 | } |
| 1620 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1621 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1622 | "%s: Interface: %s LLStats indType: %d", __func__, |
| 1623 | pAdapter->dev->name, indType); |
| 1624 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1625 | switch (indType) |
| 1626 | { |
| 1627 | case SIR_HAL_LL_STATS_RESULTS_RSP: |
| 1628 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1629 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 81a730c | 2015-09-14 14:49:52 +0530 | [diff] [blame] | 1630 | "LL_STATS RESP paramID = 0x%x, ifaceId = %u MAC: %pM " |
| 1631 | "respId = %u, moreResultToFollow = %u", |
| 1632 | linkLayerStatsResults->paramId, linkLayerStatsResults->ifaceId, |
| 1633 | macAddr, linkLayerStatsResults->respId, |
| 1634 | linkLayerStatsResults->moreResultToFollow); |
| 1635 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1636 | spin_lock(&hdd_context_lock); |
| 1637 | context = &pHddCtx->ll_stats_context; |
| 1638 | /* validate response received from target */ |
| 1639 | if ((context->request_id != linkLayerStatsResults->respId) || |
| 1640 | !(context->request_bitmap & linkLayerStatsResults->paramId)) |
| 1641 | { |
| 1642 | spin_unlock(&hdd_context_lock); |
| 1643 | hddLog(LOGE, |
| 1644 | FL("Error : Request id %d response id %d request bitmap 0x%x" |
| 1645 | "response bitmap 0x%x"), |
| 1646 | context->request_id, linkLayerStatsResults->respId, |
| 1647 | context->request_bitmap, linkLayerStatsResults->paramId); |
| 1648 | return; |
| 1649 | } |
| 1650 | spin_unlock(&hdd_context_lock); |
| 1651 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1652 | if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO ) |
| 1653 | { |
| 1654 | hdd_link_layer_process_radio_stats(pAdapter, |
| 1655 | (v_VOID_t *)linkLayerStatsResults->result); |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1656 | spin_lock(&hdd_context_lock); |
| 1657 | context->request_bitmap &= ~(WMI_LINK_STATS_RADIO); |
| 1658 | spin_unlock(&hdd_context_lock); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1659 | } |
| 1660 | else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE ) |
| 1661 | { |
| 1662 | hdd_link_layer_process_iface_stats(pAdapter, |
| 1663 | (v_VOID_t *)linkLayerStatsResults->result); |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1664 | spin_lock(&hdd_context_lock); |
| 1665 | context->request_bitmap &= ~(WMI_LINK_STATS_IFACE); |
| 1666 | spin_unlock(&hdd_context_lock); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1667 | } |
| 1668 | else if ( linkLayerStatsResults->paramId & |
| 1669 | WMI_LINK_STATS_ALL_PEER ) |
| 1670 | { |
| 1671 | hdd_link_layer_process_peer_stats(pAdapter, |
| 1672 | (v_VOID_t *)linkLayerStatsResults->result); |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1673 | spin_lock(&hdd_context_lock); |
| 1674 | context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER); |
| 1675 | spin_unlock(&hdd_context_lock); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1676 | } /* WMI_LINK_STATS_ALL_PEER */ |
| 1677 | else |
| 1678 | { |
| 1679 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1680 | FL("INVALID LL_STATS_NOTIFY RESPONSE ***********")); |
| 1681 | } |
| 1682 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1683 | spin_lock(&hdd_context_lock); |
| 1684 | /* complete response event if all requests are completed */ |
| 1685 | if (0 == context->request_bitmap) |
| 1686 | complete(&context->response_event); |
| 1687 | spin_unlock(&hdd_context_lock); |
| 1688 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1689 | break; |
| 1690 | } |
| 1691 | default: |
| 1692 | hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType); |
| 1693 | break; |
| 1694 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1695 | |
| 1696 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1697 | return; |
| 1698 | } |
| 1699 | |
| 1700 | const struct |
| 1701 | nla_policy |
| 1702 | qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] = |
| 1703 | { |
| 1704 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] = |
| 1705 | { .type = NLA_U32 }, |
| 1706 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] = |
| 1707 | { .type = NLA_U32 }, |
| 1708 | }; |
| 1709 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 1710 | static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy, |
| 1711 | struct wireless_dev *wdev, |
| 1712 | const void *data, |
| 1713 | int data_len) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1714 | { |
| 1715 | int status; |
| 1716 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1]; |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1717 | tSirLLStatsSetReq linkLayerStatsSetReq; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1718 | struct net_device *dev = wdev->netdev; |
| 1719 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1720 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1721 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1722 | ENTER(); |
| 1723 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1724 | status = wlan_hdd_validate_context(pHddCtx); |
| 1725 | if (0 != status) |
| 1726 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1727 | return -EINVAL; |
| 1728 | } |
| 1729 | |
| 1730 | if (NULL == pAdapter) |
| 1731 | { |
| 1732 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1733 | FL("HDD adapter is Null")); |
| 1734 | return -ENODEV; |
| 1735 | } |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1736 | /* check the LLStats Capability */ |
| 1737 | if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) || |
| 1738 | (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) |
| 1739 | { |
Anurag Chouhan | 65ea6dc | 2016-10-25 19:59:14 +0530 | [diff] [blame] | 1740 | hddLog(VOS_TRACE_LEVEL_WARN, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1741 | FL("Link Layer Statistics not supported by Firmware")); |
| 1742 | return -EINVAL; |
| 1743 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1744 | |
| 1745 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX, |
| 1746 | (struct nlattr *)data, |
| 1747 | data_len, qca_wlan_vendor_ll_set_policy)) |
| 1748 | { |
| 1749 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1750 | return -EINVAL; |
| 1751 | } |
| 1752 | if (!tb_vendor |
| 1753 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]) |
| 1754 | { |
| 1755 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present")); |
| 1756 | return -EINVAL; |
| 1757 | } |
| 1758 | if (!tb_vendor[ |
| 1759 | QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]) |
| 1760 | { |
| 1761 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present")); |
| 1762 | return -EINVAL; |
| 1763 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1764 | // Shall take the request Id if the Upper layers pass. 1 For now. |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1765 | linkLayerStatsSetReq.reqId = 1; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1766 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1767 | linkLayerStatsSetReq.mpduSizeThreshold = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1768 | nla_get_u32( |
| 1769 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]); |
| 1770 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1771 | linkLayerStatsSetReq.aggressiveStatisticsGathering = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1772 | nla_get_u32( |
| 1773 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]); |
| 1774 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1775 | vos_mem_copy(linkLayerStatsSetReq.macAddr, |
| 1776 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1777 | |
| 1778 | |
| 1779 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 81a730c | 2015-09-14 14:49:52 +0530 | [diff] [blame] | 1780 | "LL_STATS_SET reqId = %d, MAC = %pM, mpduSizeThreshold = %d " |
| 1781 | "Statistics Gathering = %d ", |
| 1782 | linkLayerStatsSetReq.reqId, linkLayerStatsSetReq.macAddr, |
| 1783 | linkLayerStatsSetReq.mpduSizeThreshold, |
| 1784 | linkLayerStatsSetReq.aggressiveStatisticsGathering); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1785 | |
| 1786 | if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB( |
| 1787 | pHddCtx->hHal, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1788 | hdd_link_layer_stats_ind_callback)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1789 | { |
| 1790 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1791 | "sme_SetLinkLayerStatsIndCB Failed", __func__); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1792 | return -EINVAL; |
| 1793 | |
| 1794 | } |
Srinivas Dasari | 9894743 | 2014-11-07 19:41:24 +0530 | [diff] [blame] | 1795 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1796 | if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1797 | &linkLayerStatsSetReq)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1798 | { |
| 1799 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1800 | "sme_LLStatsSetReq Failed", __func__); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1801 | return -EINVAL; |
| 1802 | } |
| 1803 | |
| 1804 | pAdapter->isLinkLayerStatsSet = 1; |
| 1805 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1806 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1807 | return 0; |
| 1808 | } |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 1809 | static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy, |
| 1810 | struct wireless_dev *wdev, |
| 1811 | const void *data, |
| 1812 | int data_len) |
| 1813 | { |
| 1814 | int ret = 0; |
| 1815 | |
| 1816 | vos_ssr_protect(__func__); |
| 1817 | ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len); |
| 1818 | vos_ssr_unprotect(__func__); |
| 1819 | |
| 1820 | return ret; |
| 1821 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1822 | |
| 1823 | const struct |
| 1824 | nla_policy |
| 1825 | qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] = |
| 1826 | { |
| 1827 | /* Unsigned 32bit value provided by the caller issuing the GET stats |
| 1828 | * command. When reporting |
| 1829 | * the stats results, the driver uses the same value to indicate |
| 1830 | * which GET request the results |
| 1831 | * correspond to. |
| 1832 | */ |
| 1833 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 }, |
| 1834 | |
| 1835 | /* Unsigned 32bit value . bit mask to identify what statistics are |
| 1836 | requested for retrieval */ |
| 1837 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 }, |
| 1838 | }; |
| 1839 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 1840 | static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy, |
| 1841 | struct wireless_dev *wdev, |
| 1842 | const void *data, |
| 1843 | int data_len) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1844 | { |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1845 | unsigned long rc; |
| 1846 | struct hdd_ll_stats_context *context; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1847 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1848 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1]; |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1849 | tSirLLStatsGetReq linkLayerStatsGetReq; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1850 | struct net_device *dev = wdev->netdev; |
| 1851 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mukul Sharma | 10313ba | 2015-07-29 19:14:39 +0530 | [diff] [blame] | 1852 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1853 | int status; |
| 1854 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1855 | ENTER(); |
| 1856 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1857 | status = wlan_hdd_validate_context(pHddCtx); |
| 1858 | if (0 != status) |
| 1859 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1860 | return -EINVAL ; |
| 1861 | } |
| 1862 | |
| 1863 | if (NULL == pAdapter) |
| 1864 | { |
| 1865 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1866 | "%s: HDD adapter is Null", __func__); |
| 1867 | return -ENODEV; |
| 1868 | } |
Mukul Sharma | 10313ba | 2015-07-29 19:14:39 +0530 | [diff] [blame] | 1869 | |
| 1870 | if (pHddStaCtx == NULL) |
| 1871 | { |
| 1872 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1873 | "%s: HddStaCtx is Null", __func__); |
| 1874 | return -ENODEV; |
| 1875 | } |
| 1876 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1877 | /* check the LLStats Capability */ |
| 1878 | if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) || |
| 1879 | (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) |
| 1880 | { |
| 1881 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1882 | FL("Link Layer Statistics not supported by Firmware")); |
| 1883 | return -EINVAL; |
| 1884 | } |
| 1885 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1886 | |
| 1887 | if (!pAdapter->isLinkLayerStatsSet) |
| 1888 | { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 1889 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1890 | "%s: isLinkLayerStatsSet : %d", |
| 1891 | __func__, pAdapter->isLinkLayerStatsSet); |
| 1892 | return -EINVAL; |
| 1893 | } |
| 1894 | |
Mukul Sharma | 10313ba | 2015-07-29 19:14:39 +0530 | [diff] [blame] | 1895 | if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) |
| 1896 | { |
| 1897 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1898 | "%s: Roaming in progress, so unable to proceed this request", __func__); |
| 1899 | return -EBUSY; |
| 1900 | } |
| 1901 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1902 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX, |
| 1903 | (struct nlattr *)data, |
| 1904 | data_len, qca_wlan_vendor_ll_get_policy)) |
| 1905 | { |
| 1906 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1907 | return -EINVAL; |
| 1908 | } |
| 1909 | |
| 1910 | if (!tb_vendor |
| 1911 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]) |
| 1912 | { |
| 1913 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present")); |
| 1914 | return -EINVAL; |
| 1915 | } |
| 1916 | |
| 1917 | if (!tb_vendor |
| 1918 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]) |
| 1919 | { |
| 1920 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present")); |
| 1921 | return -EINVAL; |
| 1922 | } |
| 1923 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1924 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1925 | linkLayerStatsGetReq.reqId = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1926 | nla_get_u32( tb_vendor[ |
| 1927 | QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]); |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1928 | linkLayerStatsGetReq.paramIdMask = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1929 | nla_get_u32( tb_vendor[ |
| 1930 | QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]); |
| 1931 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1932 | vos_mem_copy(linkLayerStatsGetReq.macAddr, |
| 1933 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1934 | |
| 1935 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 81a730c | 2015-09-14 14:49:52 +0530 | [diff] [blame] | 1936 | "LL_STATS_GET reqId = %d, MAC = %pM, paramIdMask = %d", |
| 1937 | linkLayerStatsGetReq.reqId, linkLayerStatsGetReq.macAddr, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1938 | linkLayerStatsGetReq.paramIdMask); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1939 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1940 | spin_lock(&hdd_context_lock); |
| 1941 | context = &pHddCtx->ll_stats_context; |
| 1942 | context->request_id = linkLayerStatsGetReq.reqId; |
| 1943 | context->request_bitmap = linkLayerStatsGetReq.paramIdMask; |
| 1944 | INIT_COMPLETION(context->response_event); |
| 1945 | spin_unlock(&hdd_context_lock); |
| 1946 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1947 | if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1948 | &linkLayerStatsGetReq)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1949 | { |
| 1950 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1951 | "sme_LLStatsGetReq Failed", __func__); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1952 | return -EINVAL; |
| 1953 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1954 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 1955 | rc = wait_for_completion_timeout(&context->response_event, |
| 1956 | msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS)); |
| 1957 | if (!rc) |
| 1958 | { |
| 1959 | hddLog(LOGE, |
| 1960 | FL("Target response timed out request id %d request bitmap 0x%x"), |
| 1961 | context->request_id, context->request_bitmap); |
| 1962 | return -ETIMEDOUT; |
| 1963 | } |
| 1964 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1965 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1966 | return 0; |
| 1967 | } |
| 1968 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 1969 | static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy, |
| 1970 | struct wireless_dev *wdev, |
| 1971 | const void *data, |
| 1972 | int data_len) |
| 1973 | { |
| 1974 | int ret = 0; |
| 1975 | |
| 1976 | vos_ssr_protect(__func__); |
| 1977 | ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len); |
| 1978 | vos_ssr_unprotect(__func__); |
| 1979 | |
| 1980 | return ret; |
| 1981 | } |
| 1982 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1983 | const struct |
| 1984 | nla_policy |
| 1985 | qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] = |
| 1986 | { |
| 1987 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 }, |
| 1988 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 }, |
| 1989 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 }, |
| 1990 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 }, |
| 1991 | }; |
| 1992 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 1993 | static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy, |
| 1994 | struct wireless_dev *wdev, |
| 1995 | const void *data, |
| 1996 | int data_len) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1997 | { |
| 1998 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1999 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1]; |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2000 | tSirLLStatsClearReq linkLayerStatsClearReq; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2001 | struct net_device *dev = wdev->netdev; |
| 2002 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2003 | u32 statsClearReqMask; |
| 2004 | u8 stopReq; |
| 2005 | int status; |
| 2006 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2007 | ENTER(); |
| 2008 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2009 | status = wlan_hdd_validate_context(pHddCtx); |
| 2010 | if (0 != status) |
| 2011 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2012 | return -EINVAL; |
| 2013 | } |
| 2014 | |
| 2015 | if (NULL == pAdapter) |
| 2016 | { |
| 2017 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2018 | "%s: HDD adapter is Null", __func__); |
| 2019 | return -ENODEV; |
| 2020 | } |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2021 | /* check the LLStats Capability */ |
| 2022 | if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) || |
| 2023 | (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) |
| 2024 | { |
| 2025 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2026 | FL("Enable LLStats Capability")); |
| 2027 | return -EINVAL; |
| 2028 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2029 | |
| 2030 | if (!pAdapter->isLinkLayerStatsSet) |
| 2031 | { |
| 2032 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2033 | "%s: isLinkLayerStatsSet : %d", |
| 2034 | __func__, pAdapter->isLinkLayerStatsSet); |
| 2035 | return -EINVAL; |
| 2036 | } |
| 2037 | |
| 2038 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX, |
| 2039 | (struct nlattr *)data, |
| 2040 | data_len, qca_wlan_vendor_ll_clr_policy)) |
| 2041 | { |
| 2042 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 2043 | return -EINVAL; |
| 2044 | } |
| 2045 | |
| 2046 | if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] || |
| 2047 | |
| 2048 | !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]) |
| 2049 | { |
| 2050 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") ); |
| 2051 | return -EINVAL; |
| 2052 | |
| 2053 | } |
| 2054 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2055 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2056 | statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2057 | nla_get_u32( |
| 2058 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]); |
| 2059 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2060 | stopReq = linkLayerStatsClearReq.stopReq = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2061 | nla_get_u8( |
| 2062 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]); |
| 2063 | |
| 2064 | // Shall take the request Id if the Upper layers pass. 1 For now. |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2065 | linkLayerStatsClearReq.reqId = 1; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2066 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 2067 | vos_mem_copy(linkLayerStatsClearReq.macAddr, |
| 2068 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2069 | |
| 2070 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 81a730c | 2015-09-14 14:49:52 +0530 | [diff] [blame] | 2071 | "LL_STATS_CLEAR reqId = %d, MAC = %pM," |
| 2072 | "statsClearReqMask = 0x%X, stopReq = %d", |
| 2073 | linkLayerStatsClearReq.reqId, |
| 2074 | linkLayerStatsClearReq.macAddr, |
| 2075 | linkLayerStatsClearReq.statsClearReqMask, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2076 | linkLayerStatsClearReq.stopReq); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2077 | |
| 2078 | if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2079 | &linkLayerStatsClearReq)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2080 | { |
| 2081 | struct sk_buff *temp_skbuff; |
Srinivas Dasari | 9894743 | 2014-11-07 19:41:24 +0530 | [diff] [blame] | 2082 | hdd_station_ctx_t *pHddStaCtx; |
| 2083 | |
| 2084 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2085 | if (VOS_STATUS_SUCCESS != |
| 2086 | WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 2087 | pHddStaCtx->conn_info.staId[0], statsClearReqMask)) |
| 2088 | { |
| 2089 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 2090 | "WLANTL_ClearInterfaceStats Failed", __func__); |
| 2091 | return -EINVAL; |
| 2092 | } |
| 2093 | if ((statsClearReqMask & WIFI_STATS_IFACE_AC) || |
| 2094 | (statsClearReqMask & WIFI_STATS_IFACE)) { |
| 2095 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0; |
| 2096 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0; |
| 2097 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0; |
| 2098 | pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0; |
| 2099 | } |
| 2100 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2101 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 2102 | 2 * sizeof(u32) + |
| 2103 | NLMSG_HDRLEN); |
| 2104 | |
| 2105 | if (temp_skbuff != NULL) |
| 2106 | { |
| 2107 | |
| 2108 | if (nla_put_u32(temp_skbuff, |
| 2109 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK, |
| 2110 | statsClearReqMask) || |
| 2111 | nla_put_u32(temp_skbuff, |
| 2112 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP, |
| 2113 | stopReq)) |
| 2114 | { |
| 2115 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail")); |
| 2116 | kfree_skb(temp_skbuff); |
| 2117 | return -EINVAL; |
| 2118 | } |
| 2119 | /* If the ask is to stop the stats collection as part of clear |
| 2120 | * (stopReq = 1) , ensure that no further requests of get |
| 2121 | * go to the firmware by having isLinkLayerStatsSet set to 0. |
| 2122 | * However it the stopReq as part of the clear request is 0 , |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2123 | * the request to get the statistics are honoured as in this |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2124 | * case the firmware is just asked to clear the statistics. |
| 2125 | */ |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 2126 | if (linkLayerStatsClearReq.stopReq == 1) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2127 | pAdapter->isLinkLayerStatsSet = 0; |
| 2128 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 2129 | } |
| 2130 | return -ENOMEM; |
| 2131 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2132 | |
| 2133 | EXIT(); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2134 | return -EINVAL; |
| 2135 | } |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 2136 | static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy, |
| 2137 | struct wireless_dev *wdev, |
| 2138 | const void *data, |
| 2139 | int data_len) |
| 2140 | { |
| 2141 | int ret = 0; |
| 2142 | |
| 2143 | vos_ssr_protect(__func__); |
| 2144 | ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len); |
| 2145 | vos_ssr_unprotect(__func__); |
| 2146 | |
| 2147 | return ret; |
| 2148 | |
| 2149 | |
| 2150 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2151 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 2152 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2153 | #ifdef WLAN_FEATURE_EXTSCAN |
| 2154 | static const struct nla_policy |
| 2155 | wlan_hdd_extscan_config_policy |
| 2156 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] = |
| 2157 | { |
| 2158 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] = |
| 2159 | { .type = NLA_U32 }, |
| 2160 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] = |
| 2161 | { .type = NLA_U32 }, |
| 2162 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 }, |
| 2163 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] = |
| 2164 | { .type = NLA_U32 }, |
| 2165 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 }, |
| 2166 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 }, |
| 2167 | |
| 2168 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 }, |
| 2169 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 }, |
| 2170 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 }, |
| 2171 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] = |
| 2172 | { .type = NLA_U8 }, |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2173 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] = |
| 2174 | { .type = NLA_U32 }, |
| 2175 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] = |
| 2176 | { .type = NLA_U32 }, |
| 2177 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] = |
| 2178 | { .type = NLA_U32 }, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2179 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] = |
| 2180 | { .type = NLA_U32 }, |
| 2181 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] = |
| 2182 | { .type = NLA_U32 }, |
| 2183 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] = |
| 2184 | { .type = NLA_U32 }, |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2185 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] = |
| 2186 | { .type = NLA_U8 }, |
| 2187 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] = |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2188 | { .type = NLA_U8 }, |
| 2189 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] = |
| 2190 | { .type = NLA_U8 }, |
| 2191 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] = |
| 2192 | { .type = NLA_U8 }, |
| 2193 | |
| 2194 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] = |
| 2195 | { .type = NLA_U32 }, |
| 2196 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] = |
| 2197 | { .type = NLA_UNSPEC }, |
| 2198 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] = |
| 2199 | { .type = NLA_S32 }, |
| 2200 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] = |
| 2201 | { .type = NLA_S32 }, |
| 2202 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] = |
| 2203 | { .type = NLA_U32 }, |
| 2204 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] = |
| 2205 | { .type = NLA_U32 }, |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2206 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] = |
| 2207 | { .type = NLA_U32 }, |
| 2208 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] = |
| 2209 | { .type = NLA_BINARY, |
| 2210 | .len = IEEE80211_MAX_SSID_LEN + 1 }, |
| 2211 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] = |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2212 | { .type = NLA_U32 }, |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2213 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] = |
| 2214 | { .type = NLA_U32 }, |
| 2215 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] = |
| 2216 | { .type = NLA_U8 }, |
| 2217 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] = |
| 2218 | { .type = NLA_S32 }, |
| 2219 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] = |
| 2220 | { .type = NLA_S32 }, |
| 2221 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] = |
| 2222 | { .type = NLA_U32 }, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2223 | }; |
| 2224 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2225 | /** |
| 2226 | * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target |
| 2227 | * @ctx: hdd global context |
| 2228 | * @data: capabilities data |
| 2229 | * |
| 2230 | * Return: none |
| 2231 | */ |
| 2232 | static void |
| 2233 | wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2234 | { |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2235 | struct hdd_ext_scan_context *context; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2236 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2237 | tSirEXTScanCapabilitiesEvent *data = |
| 2238 | (tSirEXTScanCapabilitiesEvent *) pMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2239 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2240 | ENTER(); |
| 2241 | |
| 2242 | if (wlan_hdd_validate_context(pHddCtx)) |
| 2243 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2244 | return; |
| 2245 | } |
| 2246 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2247 | if (!pMsg) |
| 2248 | { |
| 2249 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
| 2250 | return; |
| 2251 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2252 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2253 | vos_spin_lock_acquire(&hdd_context_lock); |
| 2254 | |
| 2255 | context = &pHddCtx->ext_scan_context; |
| 2256 | /* validate response received from target*/ |
| 2257 | if (context->request_id != data->requestId) |
| 2258 | { |
| 2259 | vos_spin_lock_release(&hdd_context_lock); |
| 2260 | hddLog(LOGE, |
| 2261 | FL("Target response id did not match: request_id %d resposne_id %d"), |
| 2262 | context->request_id, data->requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2263 | return; |
| 2264 | } |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2265 | else |
| 2266 | { |
| 2267 | context->capability_response = *data; |
| 2268 | complete(&context->response_event); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2269 | } |
| 2270 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2271 | vos_spin_lock_release(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2272 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2273 | return; |
| 2274 | } |
| 2275 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2276 | /* |
| 2277 | * define short names for the global vendor params |
| 2278 | * used by wlan_hdd_send_ext_scan_capability() |
| 2279 | */ |
| 2280 | #define PARAM_REQUEST_ID \ |
| 2281 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID |
| 2282 | #define PARAM_STATUS \ |
| 2283 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS |
| 2284 | #define MAX_SCAN_CACHE_SIZE \ |
| 2285 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE |
| 2286 | #define MAX_SCAN_BUCKETS \ |
| 2287 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS |
| 2288 | #define MAX_AP_CACHE_PER_SCAN \ |
| 2289 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN |
| 2290 | #define MAX_RSSI_SAMPLE_SIZE \ |
| 2291 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE |
| 2292 | #define MAX_SCAN_RPT_THRHOLD \ |
| 2293 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD |
| 2294 | #define MAX_HOTLIST_BSSIDS \ |
| 2295 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS |
| 2296 | #define MAX_BSSID_HISTORY_ENTRIES \ |
| 2297 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES |
| 2298 | #define MAX_HOTLIST_SSIDS \ |
| 2299 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2300 | #define MAX_SIGNIFICANT_WIFI_CHANGE_APS \ |
| 2301 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2302 | |
| 2303 | static int wlan_hdd_send_ext_scan_capability(void *ctx) |
| 2304 | { |
| 2305 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2306 | struct sk_buff *skb = NULL; |
| 2307 | int ret; |
| 2308 | tSirEXTScanCapabilitiesEvent *data; |
| 2309 | tANI_U32 nl_buf_len; |
| 2310 | |
| 2311 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2312 | if (0 != ret) |
| 2313 | { |
| 2314 | return ret; |
| 2315 | } |
| 2316 | |
| 2317 | data = &(pHddCtx->ext_scan_context.capability_response); |
| 2318 | |
| 2319 | nl_buf_len = NLMSG_HDRLEN; |
| 2320 | nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) + |
| 2321 | (sizeof(data->status) + NLA_HDRLEN) + |
| 2322 | (sizeof(data->scanCacheSize) + NLA_HDRLEN) + |
| 2323 | (sizeof(data->scanBuckets) + NLA_HDRLEN) + |
| 2324 | (sizeof(data->maxApPerScan) + NLA_HDRLEN) + |
| 2325 | (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) + |
| 2326 | (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) + |
| 2327 | (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) + |
| 2328 | (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) + |
| 2329 | (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN); |
| 2330 | |
| 2331 | skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len); |
| 2332 | |
| 2333 | if (!skb) |
| 2334 | { |
| 2335 | hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed")); |
| 2336 | return -ENOMEM; |
| 2337 | } |
| 2338 | |
| 2339 | hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status); |
| 2340 | hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)", |
| 2341 | data->scanCacheSize, data->scanBuckets, data->maxApPerScan); |
| 2342 | hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)", |
| 2343 | data->maxRssiSampleSize, data->maxScanReportingThreshold); |
| 2344 | hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)" |
| 2345 | "max_hotlist_ssids (%u)", data->maxHotlistAPs, |
| 2346 | data->maxBsidHistoryEntries, data->maxHotlistSSIDs); |
| 2347 | |
| 2348 | if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) || |
| 2349 | nla_put_u32(skb, PARAM_STATUS, data->status) || |
| 2350 | nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) || |
| 2351 | nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) || |
| 2352 | nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN, |
| 2353 | data->maxApPerScan) || |
| 2354 | nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE, |
| 2355 | data->maxRssiSampleSize) || |
| 2356 | nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD, |
| 2357 | data->maxScanReportingThreshold) || |
| 2358 | nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) || |
| 2359 | nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES, |
| 2360 | data->maxBsidHistoryEntries) || |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2361 | nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) || |
| 2362 | nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0)) |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2363 | { |
| 2364 | hddLog(LOGE, FL("nla put fail")); |
| 2365 | goto nla_put_failure; |
| 2366 | } |
| 2367 | |
| 2368 | cfg80211_vendor_cmd_reply(skb); |
| 2369 | return 0; |
| 2370 | |
| 2371 | nla_put_failure: |
| 2372 | kfree_skb(skb); |
| 2373 | return -EINVAL;; |
| 2374 | } |
| 2375 | |
| 2376 | /* |
| 2377 | * done with short names for the global vendor params |
| 2378 | * used by wlan_hdd_send_ext_scan_capability() |
| 2379 | */ |
| 2380 | #undef PARAM_REQUEST_ID |
| 2381 | #undef PARAM_STATUS |
| 2382 | #undef MAX_SCAN_CACHE_SIZE |
| 2383 | #undef MAX_SCAN_BUCKETS |
| 2384 | #undef MAX_AP_CACHE_PER_SCAN |
| 2385 | #undef MAX_RSSI_SAMPLE_SIZE |
| 2386 | #undef MAX_SCAN_RPT_THRHOLD |
| 2387 | #undef MAX_HOTLIST_BSSIDS |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 2388 | #undef MAX_BSSID_HISTORY_ENTRIES |
| 2389 | #undef MAX_HOTLIST_SSIDS |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2390 | |
| 2391 | static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg) |
| 2392 | { |
| 2393 | tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg; |
| 2394 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2395 | tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal ); |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2396 | struct hdd_ext_scan_context *context; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2397 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2398 | ENTER(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2399 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2400 | if (wlan_hdd_validate_context(pHddCtx)) |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2401 | return; |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2402 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2403 | if (!pMsg) |
| 2404 | { |
| 2405 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2406 | return; |
| 2407 | } |
| 2408 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2409 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2410 | hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status); |
| 2411 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2412 | context = &pHddCtx->ext_scan_context; |
| 2413 | spin_lock(&hdd_context_lock); |
| 2414 | if (context->request_id == pData->requestId) { |
| 2415 | context->response_status = pData->status ? -EINVAL : 0; |
| 2416 | complete(&context->response_event); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2417 | } |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 2418 | spin_unlock(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2419 | |
| 2420 | /* |
| 2421 | * Store the Request ID for comparing with the requestID obtained |
| 2422 | * in other requests.HDD shall return a failure is the extscan_stop |
| 2423 | * request is issued with a different requestId as that of the |
| 2424 | * extscan_start request. Also, This requestId shall be used while |
| 2425 | * indicating the full scan results to the upper layers. |
| 2426 | * The requestId is stored with the assumption that the firmware |
| 2427 | * shall return the ext scan start request's requestId in ext scan |
| 2428 | * start response. |
| 2429 | */ |
| 2430 | if (pData->status == 0) |
| 2431 | pMac->sme.extScanStartReqId = pData->requestId; |
| 2432 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2433 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2434 | return; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2435 | } |
| 2436 | |
| 2437 | |
| 2438 | static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg) |
| 2439 | { |
| 2440 | tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg; |
| 2441 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 2442 | struct hdd_ext_scan_context *context; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2443 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2444 | ENTER(); |
| 2445 | |
| 2446 | if (wlan_hdd_validate_context(pHddCtx)){ |
| 2447 | return; |
| 2448 | } |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 2449 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2450 | if (!pMsg) |
| 2451 | { |
| 2452 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2453 | return; |
| 2454 | } |
| 2455 | |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 2456 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId, |
| 2457 | pData->status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2458 | |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 2459 | context = &pHddCtx->ext_scan_context; |
| 2460 | spin_lock(&hdd_context_lock); |
| 2461 | if (context->request_id == pData->requestId) { |
| 2462 | context->response_status = pData->status ? -EINVAL : 0; |
| 2463 | complete(&context->response_event); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2464 | } |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 2465 | spin_unlock(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2466 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2467 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2468 | return; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2469 | } |
| 2470 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2471 | static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx, |
| 2472 | void *pMsg) |
| 2473 | { |
| 2474 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2475 | tpSirEXTScanSetBssidHotListRspParams pData = |
| 2476 | (tpSirEXTScanSetBssidHotListRspParams) pMsg; |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2477 | struct hdd_ext_scan_context *context; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2478 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2479 | ENTER(); |
| 2480 | |
| 2481 | if (wlan_hdd_validate_context(pHddCtx)){ |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2482 | return; |
| 2483 | } |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2484 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2485 | if (!pMsg) |
| 2486 | { |
| 2487 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
| 2488 | return; |
| 2489 | } |
| 2490 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2491 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId, |
| 2492 | pData->status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2493 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2494 | context = &pHddCtx->ext_scan_context; |
| 2495 | spin_lock(&hdd_context_lock); |
| 2496 | if (context->request_id == pData->requestId) { |
| 2497 | context->response_status = pData->status ? -EINVAL : 0; |
| 2498 | complete(&context->response_event); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2499 | } |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2500 | spin_unlock(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2501 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2502 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2503 | return; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2504 | } |
| 2505 | |
| 2506 | static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx, |
| 2507 | void *pMsg) |
| 2508 | { |
| 2509 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2510 | tpSirEXTScanResetBssidHotlistRspParams pData = |
| 2511 | (tpSirEXTScanResetBssidHotlistRspParams) pMsg; |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 2512 | struct hdd_ext_scan_context *context; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2513 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2514 | ENTER(); |
| 2515 | |
| 2516 | if (wlan_hdd_validate_context(pHddCtx)) { |
| 2517 | return; |
| 2518 | } |
| 2519 | if (!pMsg) |
| 2520 | { |
| 2521 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2522 | return; |
| 2523 | } |
| 2524 | |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 2525 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId, |
| 2526 | pData->status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2527 | |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 2528 | context = &pHddCtx->ext_scan_context; |
| 2529 | spin_lock(&hdd_context_lock); |
| 2530 | if (context->request_id == pData->requestId) { |
| 2531 | context->response_status = pData->status ? -EINVAL : 0; |
| 2532 | complete(&context->response_event); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2533 | } |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 2534 | spin_unlock(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2535 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2536 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2537 | return; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2538 | } |
| 2539 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2540 | static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx, |
| 2541 | void *pMsg) |
| 2542 | { |
| 2543 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2544 | struct sk_buff *skb = NULL; |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2545 | tANI_U32 i = 0, j, resultsPerEvent, scan_id_index; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2546 | tANI_S32 totalResults; |
| 2547 | tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg; |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2548 | tpSirWifiScanResult pSirWifiScanResult, head_ptr; |
| 2549 | struct hdd_ext_scan_context *context; |
| 2550 | bool ignore_cached_results = false; |
| 2551 | tExtscanCachedScanResult *result; |
| 2552 | struct nlattr *nla_results; |
| 2553 | tANI_U16 ieLength= 0; |
| 2554 | tANI_U8 *ie = NULL; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2555 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2556 | ENTER(); |
| 2557 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2558 | if (wlan_hdd_validate_context(pHddCtx)) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2559 | return; |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2560 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2561 | if (!pMsg) |
| 2562 | { |
| 2563 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
| 2564 | return; |
| 2565 | } |
| 2566 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2567 | spin_lock(&hdd_context_lock); |
| 2568 | context = &pHddCtx->ext_scan_context; |
| 2569 | ignore_cached_results = context->ignore_cached_results; |
| 2570 | spin_unlock(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2571 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2572 | if (ignore_cached_results) { |
| 2573 | hddLog(LOGE, |
| 2574 | FL("Ignore the cached results received after timeout")); |
| 2575 | return; |
| 2576 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2577 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2578 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u More Data %u No of scan ids %u", |
| 2579 | pData->requestId, pData->moreData, pData->scanResultSize); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2580 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2581 | result = (tExtscanCachedScanResult *)&(pData->result); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2582 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2583 | for (scan_id_index = 0; scan_id_index < pData->scanResultSize; |
| 2584 | scan_id_index++) { |
| 2585 | result+= scan_id_index; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2586 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2587 | totalResults = result->num_results; |
| 2588 | hddLog(VOS_TRACE_LEVEL_INFO, "scan_id %u flags %u Num results %u", |
| 2589 | result->scan_id, result->flags, totalResults); |
| 2590 | i = 0; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2591 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2592 | do{ |
| 2593 | resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ? |
| 2594 | EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults); |
| 2595 | totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2596 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2597 | skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, |
| 2598 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN); |
| 2599 | |
| 2600 | if (!skb) { |
| 2601 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2602 | FL("cfg80211_vendor_event_alloc failed")); |
| 2603 | return; |
| 2604 | } |
| 2605 | |
| 2606 | hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent); |
| 2607 | |
| 2608 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2609 | pData->requestId) || |
| 2610 | nla_put_u32(skb, |
| 2611 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 2612 | resultsPerEvent)) { |
| 2613 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2614 | goto fail; |
| 2615 | } |
| 2616 | if (nla_put_u8(skb, |
| 2617 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA, |
| 2618 | pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 ))) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2619 | { |
| 2620 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2621 | goto fail; |
| 2622 | } |
| 2623 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2624 | if (nla_put_u32(skb, |
| 2625 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID, |
| 2626 | result->scan_id)) { |
| 2627 | hddLog(LOGE, FL("put fail")); |
| 2628 | goto fail; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2629 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2630 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2631 | nla_results = nla_nest_start(skb, |
| 2632 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_LIST); |
| 2633 | if (!nla_results) |
| 2634 | goto fail; |
| 2635 | |
| 2636 | if (resultsPerEvent) { |
| 2637 | struct nlattr *aps; |
| 2638 | struct nlattr *nla_result; |
| 2639 | |
| 2640 | nla_result = nla_nest_start(skb, scan_id_index); |
| 2641 | if(!nla_result) |
| 2642 | goto fail; |
| 2643 | |
| 2644 | if (nla_put_u32(skb, |
| 2645 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_SCAN_ID, |
| 2646 | result->scan_id) || |
| 2647 | nla_put_u32(skb, |
| 2648 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CACHED_RESULTS_FLAGS, |
| 2649 | result->flags) || |
| 2650 | nla_put_u32(skb, |
| 2651 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 2652 | totalResults)) { |
| 2653 | hddLog(LOGE, FL("put fail")); |
| 2654 | goto fail; |
| 2655 | } |
| 2656 | |
| 2657 | aps = nla_nest_start(skb, |
| 2658 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST); |
| 2659 | if (!aps) |
| 2660 | { |
| 2661 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2662 | goto fail; |
| 2663 | } |
| 2664 | |
| 2665 | head_ptr = (tpSirWifiScanResult) &(result->ap); |
| 2666 | |
| 2667 | for (j = 0; j < resultsPerEvent; j++, i++) { |
| 2668 | struct nlattr *ap; |
| 2669 | pSirWifiScanResult = head_ptr + i; |
| 2670 | |
| 2671 | /* |
Srinivas Dasari | 91727c1 | 2016-03-23 17:59:06 +0530 | [diff] [blame] | 2672 | * Firmware returns timestamp from extscan_start till |
| 2673 | * BSSID was cached (in micro seconds). Add this with |
| 2674 | * time gap between system boot up to extscan_start |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2675 | * to derive the time since boot when the |
| 2676 | * BSSID was cached. |
| 2677 | */ |
Srinivas Dasari | 91727c1 | 2016-03-23 17:59:06 +0530 | [diff] [blame] | 2678 | pSirWifiScanResult->ts += |
| 2679 | pHddCtx->extscan_start_time_since_boot; |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2680 | hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) " |
| 2681 | "Ssid (%s)" |
| 2682 | "Bssid: %pM " |
| 2683 | "Channel (%u)" |
| 2684 | "Rssi (%d)" |
| 2685 | "RTT (%u)" |
| 2686 | "RTT_SD (%u)" |
| 2687 | "Beacon Period %u" |
| 2688 | "Capability 0x%x " |
| 2689 | "Ie length %d", |
| 2690 | i, |
| 2691 | pSirWifiScanResult->ts, |
| 2692 | pSirWifiScanResult->ssid, |
| 2693 | pSirWifiScanResult->bssid, |
| 2694 | pSirWifiScanResult->channel, |
| 2695 | pSirWifiScanResult->rssi, |
| 2696 | pSirWifiScanResult->rtt, |
| 2697 | pSirWifiScanResult->rtt_sd, |
| 2698 | pSirWifiScanResult->beaconPeriod, |
| 2699 | pSirWifiScanResult->capability, |
| 2700 | ieLength); |
| 2701 | |
| 2702 | ap = nla_nest_start(skb, j + 1); |
| 2703 | if (!ap) |
| 2704 | { |
| 2705 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2706 | goto fail; |
| 2707 | } |
| 2708 | |
| 2709 | if (nla_put_u64(skb, |
| 2710 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP, |
| 2711 | pSirWifiScanResult->ts) ) |
| 2712 | { |
| 2713 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2714 | goto fail; |
| 2715 | } |
| 2716 | if (nla_put(skb, |
| 2717 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID, |
| 2718 | sizeof(pSirWifiScanResult->ssid), |
| 2719 | pSirWifiScanResult->ssid) ) |
| 2720 | { |
| 2721 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2722 | goto fail; |
| 2723 | } |
| 2724 | if (nla_put(skb, |
| 2725 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID, |
| 2726 | sizeof(pSirWifiScanResult->bssid), |
| 2727 | pSirWifiScanResult->bssid) ) |
| 2728 | { |
| 2729 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2730 | goto fail; |
| 2731 | } |
| 2732 | if (nla_put_u32(skb, |
| 2733 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL, |
| 2734 | pSirWifiScanResult->channel) ) |
| 2735 | { |
| 2736 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2737 | goto fail; |
| 2738 | } |
| 2739 | if (nla_put_s32(skb, |
| 2740 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI, |
| 2741 | pSirWifiScanResult->rssi) ) |
| 2742 | { |
| 2743 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2744 | goto fail; |
| 2745 | } |
| 2746 | if (nla_put_u32(skb, |
| 2747 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT, |
| 2748 | pSirWifiScanResult->rtt) ) |
| 2749 | { |
| 2750 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2751 | goto fail; |
| 2752 | } |
| 2753 | if (nla_put_u32(skb, |
| 2754 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD, |
| 2755 | pSirWifiScanResult->rtt_sd)) |
| 2756 | { |
| 2757 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2758 | goto fail; |
| 2759 | } |
| 2760 | if (nla_put_u32(skb, |
| 2761 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD, |
| 2762 | pSirWifiScanResult->beaconPeriod)) |
| 2763 | { |
| 2764 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2765 | goto fail; |
| 2766 | } |
| 2767 | if (nla_put_u32(skb, |
| 2768 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY, |
| 2769 | pSirWifiScanResult->capability)) |
| 2770 | { |
| 2771 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2772 | goto fail; |
| 2773 | } |
| 2774 | if (nla_put_u32(skb, |
| 2775 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH, |
| 2776 | ieLength)) |
| 2777 | { |
| 2778 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2779 | goto fail; |
| 2780 | } |
| 2781 | |
| 2782 | if (ieLength) |
| 2783 | if (nla_put(skb, |
| 2784 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA, |
| 2785 | ieLength, ie)) { |
| 2786 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2787 | goto fail; |
| 2788 | } |
| 2789 | |
| 2790 | nla_nest_end(skb, ap); |
| 2791 | } |
| 2792 | nla_nest_end(skb, aps); |
| 2793 | nla_nest_end(skb, nla_result); |
| 2794 | } |
| 2795 | |
| 2796 | nla_nest_end(skb, nla_results); |
| 2797 | |
| 2798 | cfg80211_vendor_cmd_reply(skb); |
| 2799 | |
| 2800 | } while (totalResults > 0); |
| 2801 | } |
| 2802 | |
| 2803 | if (!pData->moreData) { |
| 2804 | spin_lock(&hdd_context_lock); |
| 2805 | context->response_status = 0; |
| 2806 | complete(&context->response_event); |
| 2807 | spin_unlock(&hdd_context_lock); |
| 2808 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2809 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2810 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2811 | return; |
| 2812 | fail: |
| 2813 | kfree_skb(skb); |
| 2814 | return; |
| 2815 | } |
| 2816 | |
| 2817 | static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx, |
| 2818 | void *pMsg) |
| 2819 | { |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2820 | tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2821 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2822 | struct sk_buff *skb = NULL; |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2823 | tANI_U32 i, index; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2824 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2825 | ENTER(); |
| 2826 | |
| 2827 | if (wlan_hdd_validate_context(pHddCtx)) { |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2828 | hddLog(LOGE, |
| 2829 | FL("HDD context is not valid or response")); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2830 | return; |
| 2831 | } |
| 2832 | if (!pMsg) |
| 2833 | { |
| 2834 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2835 | return; |
| 2836 | } |
| 2837 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2838 | if (pData->bss_found) |
| 2839 | index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX; |
| 2840 | else |
| 2841 | index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX; |
| 2842 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2843 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 2844 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 2845 | NULL, |
| 2846 | #endif |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2847 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2848 | index, GFP_KERNEL); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2849 | |
| 2850 | if (!skb) { |
| 2851 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2852 | FL("cfg80211_vendor_event_alloc failed")); |
| 2853 | return; |
| 2854 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2855 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2856 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2857 | hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss); |
| 2858 | hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData); |
| 2859 | hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found); |
| 2860 | |
| 2861 | for (i = 0; i < pData->numHotlistBss; i++) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2862 | hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) " |
| 2863 | "Ssid (%s) " |
| 2864 | "Bssid (" MAC_ADDRESS_STR ") " |
| 2865 | "Channel (%u) " |
| 2866 | "Rssi (%d) " |
| 2867 | "RTT (%u) " |
| 2868 | "RTT_SD (%u) ", |
| 2869 | i, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2870 | pData->bssHotlist[i].ts, |
| 2871 | pData->bssHotlist[i].ssid, |
| 2872 | MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid), |
| 2873 | pData->bssHotlist[i].channel, |
| 2874 | pData->bssHotlist[i].rssi, |
| 2875 | pData->bssHotlist[i].rtt, |
| 2876 | pData->bssHotlist[i].rtt_sd); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2877 | } |
| 2878 | |
| 2879 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2880 | pData->requestId) || |
| 2881 | nla_put_u32(skb, |
| 2882 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2883 | pData->numHotlistBss)) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2884 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2885 | goto fail; |
| 2886 | } |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2887 | if (pData->numHotlistBss) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2888 | struct nlattr *aps; |
| 2889 | |
| 2890 | aps = nla_nest_start(skb, |
| 2891 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST); |
| 2892 | if (!aps) |
| 2893 | goto fail; |
| 2894 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2895 | for (i = 0; i < pData->numHotlistBss; i++) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2896 | struct nlattr *ap; |
| 2897 | |
| 2898 | ap = nla_nest_start(skb, i + 1); |
| 2899 | if (!ap) |
| 2900 | goto fail; |
| 2901 | |
| 2902 | if (nla_put_u64(skb, |
| 2903 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2904 | pData->bssHotlist[i].ts) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2905 | nla_put(skb, |
| 2906 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2907 | sizeof(pData->bssHotlist[i].ssid), |
| 2908 | pData->bssHotlist[i].ssid) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2909 | nla_put(skb, |
| 2910 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2911 | sizeof(pData->bssHotlist[i].bssid), |
| 2912 | pData->bssHotlist[i].bssid) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2913 | nla_put_u32(skb, |
| 2914 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2915 | pData->bssHotlist[i].channel) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2916 | nla_put_s32(skb, |
| 2917 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2918 | pData->bssHotlist[i].rssi) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2919 | nla_put_u32(skb, |
| 2920 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2921 | pData->bssHotlist[i].rtt) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2922 | nla_put_u32(skb, |
| 2923 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD, |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 2924 | pData->bssHotlist[i].rtt_sd)) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2925 | goto fail; |
| 2926 | |
| 2927 | nla_nest_end(skb, ap); |
| 2928 | } |
| 2929 | nla_nest_end(skb, aps); |
| 2930 | |
| 2931 | if (nla_put_u8(skb, |
| 2932 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA, |
| 2933 | pData->moreData)) |
| 2934 | goto fail; |
| 2935 | } |
| 2936 | |
| 2937 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2938 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2939 | return; |
| 2940 | |
| 2941 | fail: |
| 2942 | kfree_skb(skb); |
| 2943 | return; |
| 2944 | |
| 2945 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2946 | |
| 2947 | static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx, |
| 2948 | void *pMsg) |
| 2949 | { |
| 2950 | struct sk_buff *skb; |
| 2951 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2952 | tpSirWifiFullScanResultEvent pData = |
| 2953 | (tpSirWifiFullScanResultEvent) (pMsg); |
| 2954 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2955 | ENTER(); |
| 2956 | |
| 2957 | if (wlan_hdd_validate_context(pHddCtx)) { |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2958 | hddLog(LOGE, |
| 2959 | FL("HDD context is not valid or response")); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2960 | return; |
| 2961 | } |
| 2962 | if (!pMsg) |
| 2963 | { |
| 2964 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2965 | return; |
| 2966 | } |
| 2967 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2968 | /* |
| 2969 | * If the full scan result including IE data exceeds NL 4K size |
| 2970 | * limitation, drop that beacon/probe rsp frame. |
| 2971 | */ |
| 2972 | if ((sizeof(*pData) + pData->ieLength) >= EXTSCAN_EVENT_BUF_SIZE) { |
| 2973 | hddLog(LOGE, FL("Frame exceeded NL size limilation, drop it!")); |
| 2974 | return; |
| 2975 | } |
| 2976 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2977 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 2978 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 2979 | NULL, |
| 2980 | #endif |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2981 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2982 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX, |
| 2983 | GFP_KERNEL); |
| 2984 | |
| 2985 | if (!skb) { |
| 2986 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2987 | FL("cfg80211_vendor_event_alloc failed")); |
| 2988 | return; |
| 2989 | } |
| 2990 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2991 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId); |
| 2992 | hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData); |
| 2993 | hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) " |
| 2994 | "Ssid (%s)" |
| 2995 | "Bssid (" MAC_ADDRESS_STR ")" |
| 2996 | "Channel (%u)" |
| 2997 | "Rssi (%d)" |
| 2998 | "RTT (%u)" |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 2999 | "RTT_SD (%u)" |
| 3000 | "Bcn Period %d" |
| 3001 | "Capability 0x%X "), |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3002 | pData->ap.ts, |
| 3003 | pData->ap.ssid, |
| 3004 | MAC_ADDR_ARRAY(pData->ap.bssid), |
| 3005 | pData->ap.channel, |
| 3006 | pData->ap.rssi, |
| 3007 | pData->ap.rtt, |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3008 | pData->ap.rtt_sd, |
| 3009 | pData->ap.beaconPeriod, |
| 3010 | pData->ap.capability); |
| 3011 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3012 | hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength); |
| 3013 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 3014 | pData->requestId) || |
| 3015 | nla_put_u64(skb, |
| 3016 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP, |
| 3017 | pData->ap.ts) || |
| 3018 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID, |
| 3019 | sizeof(pData->ap.ssid), |
| 3020 | pData->ap.ssid) || |
| 3021 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID, |
| 3022 | WNI_CFG_BSSID_LEN, |
| 3023 | pData->ap.bssid) || |
| 3024 | nla_put_u32(skb, |
| 3025 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL, |
| 3026 | pData->ap.channel) || |
Dasari Srinivas | 90747d7 | 2014-10-08 12:16:15 +0530 | [diff] [blame] | 3027 | nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3028 | pData->ap.rssi) || |
| 3029 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT, |
| 3030 | pData->ap.rtt) || |
| 3031 | nla_put_u32(skb, |
| 3032 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD, |
| 3033 | pData->ap.rtt_sd) || |
| 3034 | nla_put_u16(skb, |
| 3035 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD, |
| 3036 | pData->ap.beaconPeriod) || |
| 3037 | nla_put_u16(skb, |
| 3038 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY, |
| 3039 | pData->ap.capability) || |
| 3040 | nla_put_u32(skb, |
| 3041 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH, |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3042 | pData->ieLength) || |
| 3043 | nla_put_u8(skb, |
| 3044 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA, |
| 3045 | pData->moreData)) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3046 | { |
| 3047 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3048 | goto nla_put_failure; |
| 3049 | } |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3050 | |
| 3051 | if (pData->ieLength) { |
| 3052 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA, |
| 3053 | pData->ieLength, |
| 3054 | pData->ie)) |
| 3055 | { |
| 3056 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3057 | goto nla_put_failure; |
| 3058 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3059 | } |
| 3060 | |
| 3061 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3062 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3063 | return; |
| 3064 | |
| 3065 | nla_put_failure: |
| 3066 | kfree_skb(skb); |
| 3067 | return; |
| 3068 | } |
| 3069 | |
| 3070 | static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx, |
| 3071 | void *pMsg) |
| 3072 | { |
| 3073 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 3074 | struct sk_buff *skb = NULL; |
| 3075 | tpSirEXTScanResultsAvailableIndParams pData = |
| 3076 | (tpSirEXTScanResultsAvailableIndParams) pMsg; |
| 3077 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3078 | ENTER(); |
| 3079 | |
| 3080 | if (wlan_hdd_validate_context(pHddCtx)){ |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3081 | hddLog(LOGE, |
| 3082 | FL("HDD context is not valid or response")); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3083 | return; |
| 3084 | } |
| 3085 | if (!pMsg) |
| 3086 | { |
| 3087 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3088 | return; |
| 3089 | } |
| 3090 | |
| 3091 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 3092 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 3093 | NULL, |
| 3094 | #endif |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3095 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 3096 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX, |
| 3097 | GFP_KERNEL); |
| 3098 | |
| 3099 | if (!skb) { |
| 3100 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3101 | FL("cfg80211_vendor_event_alloc failed")); |
| 3102 | return; |
| 3103 | } |
| 3104 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3105 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 3106 | hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", |
| 3107 | pData->numResultsAvailable); |
| 3108 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 3109 | pData->requestId) || |
| 3110 | nla_put_u32(skb, |
| 3111 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 3112 | pData->numResultsAvailable)) { |
| 3113 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3114 | goto nla_put_failure; |
| 3115 | } |
| 3116 | |
| 3117 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3118 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3119 | return; |
| 3120 | |
| 3121 | nla_put_failure: |
| 3122 | kfree_skb(skb); |
| 3123 | return; |
| 3124 | } |
| 3125 | |
| 3126 | static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg) |
| 3127 | { |
| 3128 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 3129 | struct sk_buff *skb = NULL; |
| 3130 | tpSirEXTScanProgressIndParams pData = |
| 3131 | (tpSirEXTScanProgressIndParams) pMsg; |
| 3132 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3133 | ENTER(); |
| 3134 | |
| 3135 | if (wlan_hdd_validate_context(pHddCtx)){ |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3136 | hddLog(LOGE, |
| 3137 | FL("HDD context is not valid or response")); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3138 | return; |
| 3139 | } |
| 3140 | if (!pMsg) |
| 3141 | { |
| 3142 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3143 | return; |
| 3144 | } |
| 3145 | |
| 3146 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 3147 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 3148 | NULL, |
| 3149 | #endif |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3150 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 3151 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX, |
| 3152 | GFP_KERNEL); |
| 3153 | |
| 3154 | if (!skb) { |
| 3155 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3156 | FL("cfg80211_vendor_event_alloc failed")); |
| 3157 | return; |
| 3158 | } |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3159 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Request Id (%u) "), pData->requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3160 | hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)", |
| 3161 | pData->extScanEventType); |
| 3162 | hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)", |
| 3163 | pData->status); |
| 3164 | |
| 3165 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE, |
| 3166 | pData->extScanEventType) || |
| 3167 | nla_put_u32(skb, |
Dasari Srinivas | 5a28865 | 2014-06-30 17:13:22 +0530 | [diff] [blame] | 3168 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 3169 | pData->requestId) || |
| 3170 | nla_put_u32(skb, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3171 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS, |
| 3172 | pData->status)) { |
| 3173 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3174 | goto nla_put_failure; |
| 3175 | } |
| 3176 | |
| 3177 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3178 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3179 | return; |
| 3180 | |
| 3181 | nla_put_failure: |
| 3182 | kfree_skb(skb); |
| 3183 | return; |
| 3184 | } |
| 3185 | |
| 3186 | void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType, |
| 3187 | void *pMsg) |
| 3188 | { |
| 3189 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 3190 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3191 | ENTER(); |
| 3192 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3193 | if (wlan_hdd_validate_context(pHddCtx)) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3194 | return; |
| 3195 | } |
| 3196 | |
| 3197 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType); |
| 3198 | |
| 3199 | |
| 3200 | switch(evType) { |
| 3201 | case SIR_HAL_EXTSCAN_START_RSP: |
| 3202 | wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg); |
| 3203 | break; |
| 3204 | |
| 3205 | case SIR_HAL_EXTSCAN_STOP_RSP: |
| 3206 | wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg); |
| 3207 | break; |
| 3208 | case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP: |
| 3209 | /* There is no need to send this response to upper layer |
| 3210 | Just log the message */ |
| 3211 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3212 | FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP")); |
| 3213 | break; |
| 3214 | case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP: |
| 3215 | wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg); |
| 3216 | break; |
| 3217 | |
| 3218 | case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP: |
| 3219 | wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg); |
| 3220 | break; |
| 3221 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3222 | case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP: |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 3223 | wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3224 | break; |
| 3225 | case SIR_HAL_EXTSCAN_PROGRESS_IND: |
| 3226 | wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg); |
| 3227 | break; |
| 3228 | case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND: |
| 3229 | wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg); |
| 3230 | break; |
| 3231 | case SIR_HAL_EXTSCAN_SCAN_RESULT_IND: |
| 3232 | wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg); |
| 3233 | break; |
| 3234 | case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND: |
| 3235 | wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg); |
| 3236 | break; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3237 | case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND: |
| 3238 | wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg); |
| 3239 | break; |
| 3240 | default: |
| 3241 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType); |
| 3242 | break; |
| 3243 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3244 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3245 | } |
| 3246 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3247 | static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy, |
| 3248 | struct wireless_dev *wdev, |
| 3249 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3250 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3251 | tSirGetEXTScanCapabilitiesReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3252 | struct net_device *dev = wdev->netdev; |
| 3253 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3254 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3255 | struct nlattr |
| 3256 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3257 | eHalStatus status; |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 3258 | struct hdd_ext_scan_context *context; |
| 3259 | unsigned long rc; |
| 3260 | int ret; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3261 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3262 | ENTER(); |
| 3263 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3264 | status = wlan_hdd_validate_context(pHddCtx); |
| 3265 | if (0 != status) |
| 3266 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3267 | return -EINVAL; |
| 3268 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3269 | /* check the EXTScan Capability */ |
| 3270 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 3271 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) || |
| 3272 | (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3273 | { |
| 3274 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3275 | FL("EXTScan not enabled/supported by Firmware")); |
| 3276 | return -EINVAL; |
| 3277 | } |
| 3278 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3279 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3280 | data, dataLen, |
| 3281 | wlan_hdd_extscan_config_policy)) { |
| 3282 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3283 | return -EINVAL; |
| 3284 | } |
| 3285 | |
| 3286 | /* Parse and fetch request Id */ |
| 3287 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3288 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3289 | return -EINVAL; |
| 3290 | } |
| 3291 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3292 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3293 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3294 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3295 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3296 | reqMsg.sessionId = pAdapter->sessionId; |
| 3297 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3298 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 3299 | vos_spin_lock_acquire(&hdd_context_lock); |
| 3300 | context = &pHddCtx->ext_scan_context; |
| 3301 | context->request_id = reqMsg.requestId; |
| 3302 | INIT_COMPLETION(context->response_event); |
| 3303 | vos_spin_lock_release(&hdd_context_lock); |
| 3304 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3305 | status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3306 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3307 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3308 | FL("sme_EXTScanGetCapabilities failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3309 | return -EINVAL; |
| 3310 | } |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 3311 | |
| 3312 | rc = wait_for_completion_timeout(&context->response_event, |
| 3313 | msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN)); |
| 3314 | if (!rc) { |
| 3315 | hddLog(LOGE, FL("Target response timed out")); |
| 3316 | return -ETIMEDOUT; |
| 3317 | } |
| 3318 | |
| 3319 | ret = wlan_hdd_send_ext_scan_capability(pHddCtx); |
| 3320 | if (ret) |
| 3321 | hddLog(LOGE, FL("Failed to send ext scan capability to user space")); |
| 3322 | |
| 3323 | return ret; |
| 3324 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3325 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3326 | return 0; |
| 3327 | } |
| 3328 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3329 | static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy, |
| 3330 | struct wireless_dev *wdev, |
| 3331 | const void *data, int dataLen) |
| 3332 | { |
| 3333 | int ret = 0; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3334 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3335 | vos_ssr_protect(__func__); |
| 3336 | ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen); |
| 3337 | vos_ssr_unprotect(__func__); |
| 3338 | |
| 3339 | return ret; |
| 3340 | } |
| 3341 | |
| 3342 | static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy, |
| 3343 | struct wireless_dev *wdev, |
| 3344 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3345 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3346 | tSirEXTScanGetCachedResultsReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3347 | struct net_device *dev = wdev->netdev; |
| 3348 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3349 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3350 | struct nlattr |
| 3351 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3352 | eHalStatus status; |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3353 | struct hdd_ext_scan_context *context; |
| 3354 | unsigned long rc; |
| 3355 | int retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3356 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3357 | ENTER(); |
| 3358 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3359 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 3360 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 3361 | return -EINVAL; |
| 3362 | } |
| 3363 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3364 | status = wlan_hdd_validate_context(pHddCtx); |
| 3365 | if (0 != status) |
| 3366 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3367 | return -EINVAL; |
| 3368 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3369 | /* check the EXTScan Capability */ |
| 3370 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 3371 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) || |
| 3372 | (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3373 | { |
| 3374 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3375 | FL("EXTScan not enabled/supported by Firmware")); |
| 3376 | return -EINVAL; |
| 3377 | } |
| 3378 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3379 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3380 | data, dataLen, |
| 3381 | wlan_hdd_extscan_config_policy)) { |
| 3382 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3383 | return -EINVAL; |
| 3384 | } |
| 3385 | /* Parse and fetch request Id */ |
| 3386 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3387 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3388 | return -EINVAL; |
| 3389 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3390 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3391 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3392 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3393 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3394 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3395 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3396 | reqMsg.sessionId = pAdapter->sessionId; |
| 3397 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3398 | |
| 3399 | /* Parse and fetch flush parameter */ |
| 3400 | if (!tb |
| 3401 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]) |
| 3402 | { |
| 3403 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed")); |
| 3404 | goto failed; |
| 3405 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3406 | reqMsg.flush = nla_get_u8( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3407 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]); |
| 3408 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3409 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3410 | |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3411 | spin_lock(&hdd_context_lock); |
| 3412 | context = &pHddCtx->ext_scan_context; |
| 3413 | context->request_id = reqMsg.requestId; |
| 3414 | context->ignore_cached_results = false; |
| 3415 | INIT_COMPLETION(context->response_event); |
| 3416 | spin_unlock(&hdd_context_lock); |
| 3417 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3418 | status = sme_getCachedResults(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3419 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3420 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3421 | FL("sme_getCachedResults failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3422 | return -EINVAL; |
| 3423 | } |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3424 | |
| 3425 | rc = wait_for_completion_timeout(&context->response_event, |
| 3426 | msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN)); |
| 3427 | if (!rc) { |
| 3428 | hddLog(LOGE, FL("Target response timed out")); |
| 3429 | retval = -ETIMEDOUT; |
| 3430 | spin_lock(&hdd_context_lock); |
| 3431 | context->ignore_cached_results = true; |
| 3432 | spin_unlock(&hdd_context_lock); |
| 3433 | } else { |
| 3434 | spin_lock(&hdd_context_lock); |
| 3435 | retval = context->response_status; |
| 3436 | spin_unlock(&hdd_context_lock); |
| 3437 | } |
| 3438 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3439 | EXIT(); |
Padma, Santhosh Kumar | e1b8a94 | 2015-08-25 12:44:24 +0530 | [diff] [blame] | 3440 | return retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3441 | |
| 3442 | failed: |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3443 | return -EINVAL; |
| 3444 | } |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3445 | static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy, |
| 3446 | struct wireless_dev *wdev, |
| 3447 | const void *data, int dataLen) |
| 3448 | { |
| 3449 | int ret = 0; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3450 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3451 | vos_ssr_protect(__func__); |
| 3452 | ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen); |
| 3453 | vos_ssr_unprotect(__func__); |
| 3454 | |
| 3455 | return ret; |
| 3456 | } |
| 3457 | |
| 3458 | static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3459 | struct wireless_dev *wdev, |
Edhar, Mahesh Kumar | ed8631f | 2015-01-20 14:31:47 +0530 | [diff] [blame] | 3460 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3461 | { |
| 3462 | tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL; |
| 3463 | struct net_device *dev = wdev->netdev; |
| 3464 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3465 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3466 | struct nlattr |
| 3467 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3468 | struct nlattr |
| 3469 | *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3470 | struct nlattr *apTh; |
| 3471 | eHalStatus status; |
| 3472 | tANI_U8 i = 0; |
| 3473 | int rem; |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3474 | struct hdd_ext_scan_context *context; |
| 3475 | tANI_U32 request_id; |
| 3476 | unsigned long rc; |
| 3477 | int retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3478 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3479 | ENTER(); |
| 3480 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3481 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 3482 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 3483 | return -EINVAL; |
| 3484 | } |
| 3485 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3486 | status = wlan_hdd_validate_context(pHddCtx); |
| 3487 | if (0 != status) |
| 3488 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3489 | return -EINVAL; |
| 3490 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3491 | /* check the EXTScan Capability */ |
| 3492 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 3493 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) || |
| 3494 | (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3495 | { |
| 3496 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3497 | FL("EXTScan not enabled/supported by Firmware")); |
| 3498 | return -EINVAL; |
| 3499 | } |
| 3500 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3501 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3502 | data, dataLen, |
| 3503 | wlan_hdd_extscan_config_policy)) { |
| 3504 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3505 | return -EINVAL; |
| 3506 | } |
| 3507 | |
| 3508 | /* Parse and fetch request Id */ |
| 3509 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3510 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3511 | return -EINVAL; |
| 3512 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3513 | pReqMsg = (tpSirEXTScanSetBssidHotListReqParams) |
| 3514 | vos_mem_malloc(sizeof(*pReqMsg)); |
| 3515 | if (!pReqMsg) { |
| 3516 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed")); |
| 3517 | return -ENOMEM; |
| 3518 | } |
| 3519 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3520 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3521 | pReqMsg->requestId = nla_get_u32( |
| 3522 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3523 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId); |
| 3524 | |
| 3525 | /* Parse and fetch number of APs */ |
| 3526 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) { |
| 3527 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed")); |
| 3528 | goto fail; |
| 3529 | } |
| 3530 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3531 | /* Parse and fetch lost ap sample size */ |
| 3532 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) { |
| 3533 | hddLog(LOGE, FL("attr lost ap sample size failed")); |
| 3534 | goto fail; |
| 3535 | } |
| 3536 | |
| 3537 | pReqMsg->lostBssidSampleSize = nla_get_u32( |
| 3538 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]); |
| 3539 | hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize); |
| 3540 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3541 | pReqMsg->sessionId = pAdapter->sessionId; |
| 3542 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId); |
| 3543 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3544 | pReqMsg->numBssid = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3545 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]); |
Hanumanth Reddy Pothula | 8e18840 | 2017-01-27 16:43:45 +0530 | [diff] [blame] | 3546 | if (pReqMsg->numBssid > WLAN_EXTSCAN_MAX_HOTLIST_APS) { |
| 3547 | hddLog(LOGE, FL("Number of AP: %u exceeds max: %u"), |
| 3548 | pReqMsg->numBssid, WLAN_EXTSCAN_MAX_HOTLIST_APS); |
| 3549 | goto fail; |
| 3550 | } |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3551 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3552 | |
| 3553 | nla_for_each_nested(apTh, |
| 3554 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) { |
Hanumanth Reddy Pothula | 8e18840 | 2017-01-27 16:43:45 +0530 | [diff] [blame] | 3555 | if (i == pReqMsg->numBssid) { |
| 3556 | hddLog(LOGW, FL("Ignoring excess AP")); |
| 3557 | break; |
| 3558 | } |
| 3559 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3560 | if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3561 | nla_data(apTh), nla_len(apTh), |
| 3562 | NULL)) { |
| 3563 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed")); |
| 3564 | goto fail; |
| 3565 | } |
| 3566 | |
| 3567 | /* Parse and fetch MAC address */ |
| 3568 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) { |
| 3569 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed")); |
| 3570 | goto fail; |
| 3571 | } |
| 3572 | memcpy(pReqMsg->ap[i].bssid, nla_data( |
| 3573 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]), |
| 3574 | sizeof(tSirMacAddr)); |
| 3575 | hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid); |
| 3576 | |
| 3577 | /* Parse and fetch low RSSI */ |
| 3578 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) { |
| 3579 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed")); |
| 3580 | goto fail; |
| 3581 | } |
| 3582 | pReqMsg->ap[i].low = nla_get_s32( |
| 3583 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]); |
| 3584 | hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low); |
| 3585 | |
| 3586 | /* Parse and fetch high RSSI */ |
| 3587 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) { |
| 3588 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed")); |
| 3589 | goto fail; |
| 3590 | } |
| 3591 | pReqMsg->ap[i].high = nla_get_s32( |
| 3592 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]); |
| 3593 | hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"), |
| 3594 | pReqMsg->ap[i].high); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3595 | i++; |
| 3596 | } |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3597 | |
Hanumanth Reddy Pothula | 8e18840 | 2017-01-27 16:43:45 +0530 | [diff] [blame] | 3598 | if (i < pReqMsg->numBssid) { |
| 3599 | hddLog(LOGW, FL("Number of AP %u less than expected %u"), |
| 3600 | i, pReqMsg->numBssid); |
| 3601 | pReqMsg->numBssid = i; |
| 3602 | } |
| 3603 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3604 | context = &pHddCtx->ext_scan_context; |
| 3605 | spin_lock(&hdd_context_lock); |
| 3606 | INIT_COMPLETION(context->response_event); |
| 3607 | context->request_id = request_id = pReqMsg->requestId; |
| 3608 | spin_unlock(&hdd_context_lock); |
| 3609 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3610 | status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg); |
| 3611 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3612 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3613 | FL("sme_SetBssHotlist failed(err=%d)"), status); |
| 3614 | vos_mem_free(pReqMsg); |
| 3615 | return -EINVAL; |
| 3616 | } |
| 3617 | |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3618 | /* request was sent -- wait for the response */ |
| 3619 | rc = wait_for_completion_timeout(&context->response_event, |
| 3620 | msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN)); |
| 3621 | |
| 3622 | if (!rc) { |
| 3623 | hddLog(LOGE, FL("sme_SetBssHotlist timed out")); |
| 3624 | retval = -ETIMEDOUT; |
| 3625 | } else { |
| 3626 | spin_lock(&hdd_context_lock); |
| 3627 | if (context->request_id == request_id) |
| 3628 | retval = context->response_status; |
| 3629 | else |
| 3630 | retval = -EINVAL; |
| 3631 | spin_unlock(&hdd_context_lock); |
| 3632 | } |
| 3633 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3634 | vos_mem_free(pReqMsg); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3635 | EXIT(); |
Padma, Santhosh Kumar | 37f4fd1 | 2015-08-19 14:37:37 +0530 | [diff] [blame] | 3636 | return retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3637 | |
| 3638 | fail: |
| 3639 | vos_mem_free(pReqMsg); |
| 3640 | return -EINVAL; |
| 3641 | } |
| 3642 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3643 | static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy, |
| 3644 | struct wireless_dev *wdev, |
| 3645 | const void *data, int dataLen) |
| 3646 | { |
| 3647 | int ret = 0; |
| 3648 | |
| 3649 | vos_ssr_protect(__func__); |
| 3650 | ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data, |
| 3651 | dataLen); |
| 3652 | vos_ssr_unprotect(__func__); |
| 3653 | |
| 3654 | return ret; |
| 3655 | } |
| 3656 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3657 | static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3658 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 3659 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3660 | { |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3661 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3662 | struct net_device *dev = wdev->netdev; |
| 3663 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3664 | uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3665 | uint8_t num_channels = 0; |
| 3666 | uint8_t num_chan_new = 0; |
| 3667 | uint8_t buf[256] = {0}; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3668 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
Padma, Santhosh Kumar | 387aa9c | 2015-06-19 15:39:37 +0530 | [diff] [blame] | 3669 | tANI_U32 requestId, maxChannels; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3670 | tWifiBand wifiBand; |
| 3671 | eHalStatus status; |
| 3672 | struct sk_buff *replySkb; |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3673 | tANI_U8 i,j,k; |
| 3674 | int ret,len = 0;; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3675 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3676 | ENTER(); |
| 3677 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3678 | status = wlan_hdd_validate_context(pHddCtx); |
| 3679 | if (0 != status) |
| 3680 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3681 | return -EINVAL; |
| 3682 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3683 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3684 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3685 | data, dataLen, |
| 3686 | wlan_hdd_extscan_config_policy)) { |
| 3687 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3688 | return -EINVAL; |
| 3689 | } |
| 3690 | |
| 3691 | /* Parse and fetch request Id */ |
| 3692 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3693 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3694 | return -EINVAL; |
| 3695 | } |
| 3696 | requestId = nla_get_u32( |
| 3697 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3698 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId); |
| 3699 | |
| 3700 | /* Parse and fetch wifi band */ |
| 3701 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]) |
| 3702 | { |
| 3703 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed")); |
| 3704 | return -EINVAL; |
| 3705 | } |
| 3706 | wifiBand = nla_get_u32( |
| 3707 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]); |
| 3708 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand); |
| 3709 | |
Padma, Santhosh Kumar | 387aa9c | 2015-06-19 15:39:37 +0530 | [diff] [blame] | 3710 | /* Parse and fetch max channels */ |
| 3711 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]) |
| 3712 | { |
| 3713 | hddLog(LOGE, FL("attr max channels failed")); |
| 3714 | return -EINVAL; |
| 3715 | } |
| 3716 | maxChannels = nla_get_u32( |
| 3717 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]); |
| 3718 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels); |
| 3719 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3720 | status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal), |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3721 | wifiBand, chan_list, |
| 3722 | &num_channels); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3723 | if (eHAL_STATUS_SUCCESS != status) { |
| 3724 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3725 | FL("sme_GetValidChannelsByBand failed (err=%d)"), status); |
| 3726 | return -EINVAL; |
| 3727 | } |
Padma, Santhosh Kumar | 387aa9c | 2015-06-19 15:39:37 +0530 | [diff] [blame] | 3728 | |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3729 | num_channels = VOS_MIN(num_channels, maxChannels); |
| 3730 | num_chan_new = num_channels; |
| 3731 | /* remove the indoor only channels if iface is SAP */ |
| 3732 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 3733 | { |
| 3734 | num_chan_new = 0; |
| 3735 | for (i = 0; i < num_channels; i++) |
| 3736 | for (j = 0; j < IEEE80211_NUM_BANDS; j++) { |
| 3737 | if (wiphy->bands[j] == NULL) |
| 3738 | continue; |
| 3739 | for (k = 0; k < wiphy->bands[j]->n_channels; k++) { |
| 3740 | if ((chan_list[i] == |
| 3741 | wiphy->bands[j]->channels[k].center_freq) && |
| 3742 | (!(wiphy->bands[j]->channels[k].flags & |
| 3743 | IEEE80211_CHAN_INDOOR_ONLY))) { |
| 3744 | chan_list[num_chan_new] = chan_list[i]; |
| 3745 | num_chan_new++; |
| 3746 | } |
| 3747 | } |
| 3748 | } |
| 3749 | } |
Padma, Santhosh Kumar | 387aa9c | 2015-06-19 15:39:37 +0530 | [diff] [blame] | 3750 | |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3751 | hddLog(LOG1, FL("Number of channels: %d"), num_chan_new); |
| 3752 | for (i = 0; i < num_chan_new; i++) |
| 3753 | len += scnprintf(buf + len, sizeof(buf) - len, "%u ", chan_list[i]); |
| 3754 | hddLog(LOG1, "Channels: %s", buf); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3755 | |
| 3756 | replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3757 | sizeof(u32) * num_chan_new + |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3758 | NLMSG_HDRLEN); |
| 3759 | |
| 3760 | if (!replySkb) { |
| 3761 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3762 | FL("valid channels: buffer alloc fail")); |
| 3763 | return -EINVAL; |
| 3764 | } |
| 3765 | if (nla_put_u32(replySkb, |
| 3766 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS, |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3767 | num_chan_new) || |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3768 | nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS, |
Agrawal Ashish | 16abf78 | 2016-08-18 22:42:59 +0530 | [diff] [blame] | 3769 | sizeof(u32) * num_chan_new, chan_list)) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3770 | |
| 3771 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3772 | kfree_skb(replySkb); |
| 3773 | return -EINVAL; |
| 3774 | } |
| 3775 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3776 | ret = cfg80211_vendor_cmd_reply(replySkb); |
| 3777 | |
| 3778 | EXIT(); |
| 3779 | return ret; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3780 | } |
| 3781 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3782 | static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy, |
| 3783 | struct wireless_dev *wdev, |
| 3784 | const void *data, int dataLen) |
| 3785 | { |
| 3786 | int ret = 0; |
| 3787 | |
| 3788 | vos_ssr_protect(__func__); |
| 3789 | ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data, |
| 3790 | dataLen); |
| 3791 | vos_ssr_unprotect(__func__); |
| 3792 | |
| 3793 | return ret; |
| 3794 | } |
| 3795 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 3796 | static int hdd_extscan_start_fill_bucket_channel_spec( |
| 3797 | hdd_context_t *pHddCtx, |
| 3798 | tpSirEXTScanStartReqParams pReqMsg, |
| 3799 | struct nlattr **tb) |
| 3800 | { |
| 3801 | struct nlattr *bucket[ |
| 3802 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3803 | struct nlattr *channel[ |
| 3804 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3805 | struct nlattr *buckets; |
| 3806 | struct nlattr *channels; |
| 3807 | int rem1, rem2; |
| 3808 | eHalStatus status; |
| 3809 | tANI_U8 bktIndex, j, numChannels; |
| 3810 | tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3811 | tANI_U32 passive_max_chn_time, active_max_chn_time; |
| 3812 | |
| 3813 | bktIndex = 0; |
| 3814 | |
| 3815 | nla_for_each_nested(buckets, |
| 3816 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) { |
| 3817 | if (nla_parse(bucket, |
Ashish Kumar Dhanotiya | 9c93f56 | 2017-06-20 12:13:33 +0530 | [diff] [blame] | 3818 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3819 | nla_data(buckets), nla_len(buckets), |
| 3820 | wlan_hdd_extscan_config_policy)) { |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 3821 | hddLog(LOGE, FL("nla_parse failed")); |
| 3822 | return -EINVAL; |
| 3823 | } |
| 3824 | |
| 3825 | /* Parse and fetch bucket spec */ |
| 3826 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) { |
| 3827 | hddLog(LOGE, FL("attr bucket index failed")); |
| 3828 | return -EINVAL; |
| 3829 | } |
| 3830 | pReqMsg->buckets[bktIndex].bucket = nla_get_u8( |
| 3831 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]); |
| 3832 | hddLog(LOG1, FL("Bucket spec Index %d"), |
| 3833 | pReqMsg->buckets[bktIndex].bucket); |
| 3834 | |
| 3835 | /* Parse and fetch wifi band */ |
| 3836 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) { |
| 3837 | hddLog(LOGE, FL("attr wifi band failed")); |
| 3838 | return -EINVAL; |
| 3839 | } |
| 3840 | pReqMsg->buckets[bktIndex].band = nla_get_u8( |
| 3841 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]); |
| 3842 | hddLog(LOG1, FL("Wifi band %d"), |
| 3843 | pReqMsg->buckets[bktIndex].band); |
| 3844 | |
| 3845 | /* Parse and fetch period */ |
| 3846 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) { |
| 3847 | hddLog(LOGE, FL("attr period failed")); |
| 3848 | return -EINVAL; |
| 3849 | } |
| 3850 | pReqMsg->buckets[bktIndex].period = nla_get_u32( |
| 3851 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]); |
| 3852 | hddLog(LOG1, FL("period %d"), |
| 3853 | pReqMsg->buckets[bktIndex].period); |
| 3854 | |
| 3855 | /* Parse and fetch report events */ |
| 3856 | if (!bucket[ |
| 3857 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) { |
| 3858 | hddLog(LOGE, FL("attr report events failed")); |
| 3859 | return -EINVAL; |
| 3860 | } |
| 3861 | pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8( |
| 3862 | bucket[ |
| 3863 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]); |
| 3864 | hddLog(LOG1, FL("report events %d"), |
| 3865 | pReqMsg->buckets[bktIndex].reportEvents); |
| 3866 | |
| 3867 | /* Parse and fetch max period */ |
| 3868 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) { |
| 3869 | hddLog(LOGE, FL("attr max period failed")); |
| 3870 | return -EINVAL; |
| 3871 | } |
| 3872 | pReqMsg->buckets[bktIndex].max_period = nla_get_u32( |
| 3873 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]); |
| 3874 | hddLog(LOG1, FL("max period %u"), |
| 3875 | pReqMsg->buckets[bktIndex].max_period); |
| 3876 | |
| 3877 | /* Parse and fetch exponent */ |
| 3878 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) { |
| 3879 | hddLog(LOGE, FL("attr exponent failed")); |
| 3880 | return -EINVAL; |
| 3881 | } |
| 3882 | pReqMsg->buckets[bktIndex].exponent = nla_get_u32( |
| 3883 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]); |
| 3884 | hddLog(LOG1, FL("exponent %u"), |
| 3885 | pReqMsg->buckets[bktIndex].exponent); |
| 3886 | |
| 3887 | /* Parse and fetch step count */ |
| 3888 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) { |
| 3889 | hddLog(LOGE, FL("attr step count failed")); |
| 3890 | return -EINVAL; |
| 3891 | } |
| 3892 | pReqMsg->buckets[bktIndex].step_count = nla_get_u32( |
| 3893 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]); |
| 3894 | hddLog(LOG1, FL("Step count %u"), |
| 3895 | pReqMsg->buckets[bktIndex].step_count); |
| 3896 | |
| 3897 | ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time); |
| 3898 | ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time); |
| 3899 | |
| 3900 | /* Framework shall pass the channel list if the input WiFi band is |
| 3901 | * WIFI_BAND_UNSPECIFIED. |
| 3902 | * If the input WiFi band is specified (any value other than |
| 3903 | * WIFI_BAND_UNSPECIFIED) then driver populates the channel list |
| 3904 | */ |
| 3905 | if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) { |
| 3906 | numChannels = 0; |
| 3907 | hddLog(LOG1, "WiFi band is specified, driver to fill channel list"); |
| 3908 | status = sme_GetValidChannelsByBand(pHddCtx->hHal, |
| 3909 | pReqMsg->buckets[bktIndex].band, |
| 3910 | chanList, &numChannels); |
| 3911 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3912 | hddLog(LOGE, |
| 3913 | FL("sme_GetValidChannelsByBand failed (err=%d)"), |
| 3914 | status); |
| 3915 | return -EINVAL; |
| 3916 | } |
| 3917 | |
| 3918 | pReqMsg->buckets[bktIndex].numChannels = |
| 3919 | VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS); |
| 3920 | hddLog(LOG1, FL("Num channels %d"), |
| 3921 | pReqMsg->buckets[bktIndex].numChannels); |
| 3922 | |
| 3923 | for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels; |
| 3924 | j++) { |
| 3925 | pReqMsg->buckets[bktIndex].channels[j].channel = |
| 3926 | chanList[j]; |
| 3927 | pReqMsg->buckets[bktIndex].channels[j]. |
| 3928 | chnlClass = 0; |
| 3929 | if (CSR_IS_CHANNEL_DFS( |
| 3930 | vos_freq_to_chan(chanList[j]))) { |
| 3931 | pReqMsg->buckets[bktIndex].channels[j]. |
| 3932 | passive = 1; |
| 3933 | pReqMsg->buckets[bktIndex].channels[j]. |
| 3934 | dwellTimeMs = passive_max_chn_time; |
| 3935 | } else { |
| 3936 | pReqMsg->buckets[bktIndex].channels[j]. |
| 3937 | passive = 0; |
| 3938 | pReqMsg->buckets[bktIndex].channels[j]. |
| 3939 | dwellTimeMs = active_max_chn_time; |
| 3940 | } |
| 3941 | |
| 3942 | hddLog(LOG1, |
| 3943 | "Channel %u Passive %u Dwell time %u ms", |
| 3944 | pReqMsg->buckets[bktIndex].channels[j].channel, |
| 3945 | pReqMsg->buckets[bktIndex].channels[j].passive, |
| 3946 | pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs); |
| 3947 | } |
| 3948 | |
| 3949 | bktIndex++; |
| 3950 | continue; |
| 3951 | } |
| 3952 | |
| 3953 | /* Parse and fetch number of channels */ |
| 3954 | if (!bucket[ |
| 3955 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) { |
| 3956 | hddLog(LOGE, FL("attr num channels failed")); |
| 3957 | return -EINVAL; |
| 3958 | } |
| 3959 | |
| 3960 | pReqMsg->buckets[bktIndex].numChannels = |
| 3961 | nla_get_u32(bucket[ |
| 3962 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]); |
| 3963 | hddLog(LOG1, FL("num channels %d"), |
| 3964 | pReqMsg->buckets[bktIndex].numChannels); |
| 3965 | |
| 3966 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) { |
| 3967 | hddLog(LOGE, FL("attr channel spec failed")); |
| 3968 | return -EINVAL; |
| 3969 | } |
| 3970 | |
| 3971 | j = 0; |
| 3972 | nla_for_each_nested(channels, |
| 3973 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) { |
| 3974 | if (nla_parse(channel, |
| 3975 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3976 | nla_data(channels), nla_len(channels), |
| 3977 | wlan_hdd_extscan_config_policy)) { |
| 3978 | hddLog(LOGE, FL("nla_parse failed")); |
| 3979 | return -EINVAL; |
| 3980 | } |
| 3981 | |
| 3982 | /* Parse and fetch channel */ |
| 3983 | if (!channel[ |
| 3984 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) { |
| 3985 | hddLog(LOGE, FL("attr channel failed")); |
| 3986 | return -EINVAL; |
| 3987 | } |
| 3988 | pReqMsg->buckets[bktIndex].channels[j].channel = |
| 3989 | nla_get_u32(channel[ |
| 3990 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]); |
| 3991 | hddLog(LOG1, FL("channel %u"), |
| 3992 | pReqMsg->buckets[bktIndex].channels[j].channel); |
| 3993 | |
| 3994 | /* Parse and fetch dwell time */ |
| 3995 | if (!channel[ |
| 3996 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) { |
| 3997 | hddLog(LOGE, FL("attr dwelltime failed")); |
| 3998 | return -EINVAL; |
| 3999 | } |
| 4000 | pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs = |
| 4001 | nla_get_u32(channel[ |
| 4002 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]); |
| 4003 | |
| 4004 | hddLog(LOG1, FL("Dwell time (%u ms)"), |
| 4005 | pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs); |
| 4006 | |
| 4007 | |
| 4008 | /* Parse and fetch channel spec passive */ |
| 4009 | if (!channel[ |
| 4010 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) { |
| 4011 | hddLog(LOGE, |
| 4012 | FL("attr channel spec passive failed")); |
| 4013 | return -EINVAL; |
| 4014 | } |
| 4015 | pReqMsg->buckets[bktIndex].channels[j].passive = |
| 4016 | nla_get_u8(channel[ |
| 4017 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]); |
| 4018 | hddLog(LOG1, FL("Chnl spec passive %u"), |
| 4019 | pReqMsg->buckets[bktIndex].channels[j].passive); |
| 4020 | |
| 4021 | j++; |
| 4022 | } |
| 4023 | |
| 4024 | bktIndex++; |
| 4025 | } |
| 4026 | |
| 4027 | return 0; |
| 4028 | } |
| 4029 | |
| 4030 | |
| 4031 | /* |
| 4032 | * define short names for the global vendor params |
| 4033 | * used by wlan_hdd_cfg80211_extscan_start() |
| 4034 | */ |
| 4035 | #define PARAM_MAX \ |
| 4036 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX |
| 4037 | #define PARAM_REQUEST_ID \ |
| 4038 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID |
| 4039 | #define PARAM_BASE_PERIOD \ |
| 4040 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD |
| 4041 | #define PARAM_MAX_AP_PER_SCAN \ |
| 4042 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN |
| 4043 | #define PARAM_RPT_THRHLD_PERCENT \ |
| 4044 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT |
| 4045 | #define PARAM_RPT_THRHLD_NUM_SCANS \ |
| 4046 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS |
| 4047 | #define PARAM_NUM_BUCKETS \ |
| 4048 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS |
| 4049 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4050 | static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4051 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4052 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4053 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4054 | tpSirEXTScanStartReqParams pReqMsg = NULL; |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4055 | struct net_device *dev = wdev->netdev; |
| 4056 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4057 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4058 | struct nlattr *tb[PARAM_MAX + 1]; |
| 4059 | int retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4060 | eHalStatus status; |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4061 | tANI_U32 request_id; |
| 4062 | struct hdd_ext_scan_context *context; |
| 4063 | unsigned long rc; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4064 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4065 | ENTER(); |
| 4066 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4067 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 4068 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 4069 | return -EINVAL; |
| 4070 | } |
| 4071 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4072 | status = wlan_hdd_validate_context(pHddCtx); |
| 4073 | if (0 != status) |
| 4074 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4075 | return -EINVAL; |
| 4076 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4077 | /* check the EXTScan Capability */ |
| 4078 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 4079 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) || |
| 4080 | (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4081 | { |
| 4082 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4083 | FL("EXTScan not enabled/supported by Firmware")); |
| 4084 | return -EINVAL; |
| 4085 | } |
| 4086 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4087 | if (nla_parse(tb, PARAM_MAX, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4088 | data, dataLen, |
| 4089 | wlan_hdd_extscan_config_policy)) { |
| 4090 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4091 | return -EINVAL; |
| 4092 | } |
| 4093 | |
| 4094 | /* Parse and fetch request Id */ |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4095 | if (!tb[PARAM_REQUEST_ID]) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4096 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 4097 | return -EINVAL; |
| 4098 | } |
| 4099 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4100 | pReqMsg = (tpSirEXTScanStartReqParams) |
| 4101 | vos_mem_malloc(sizeof(*pReqMsg)); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4102 | if (!pReqMsg) { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4103 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed")); |
| 4104 | return -ENOMEM; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4105 | } |
| 4106 | |
| 4107 | pReqMsg->requestId = nla_get_u32( |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4108 | tb[PARAM_REQUEST_ID]); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4109 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId); |
| 4110 | |
| 4111 | pReqMsg->sessionId = pAdapter->sessionId; |
| 4112 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId); |
| 4113 | |
| 4114 | /* Parse and fetch base period */ |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4115 | if (!tb[PARAM_BASE_PERIOD]) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4116 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed")); |
| 4117 | goto fail; |
| 4118 | } |
| 4119 | pReqMsg->basePeriod = nla_get_u32( |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4120 | tb[PARAM_BASE_PERIOD]); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4121 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"), |
| 4122 | pReqMsg->basePeriod); |
| 4123 | |
| 4124 | /* Parse and fetch max AP per scan */ |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4125 | if (!tb[PARAM_MAX_AP_PER_SCAN]) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4126 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed")); |
| 4127 | goto fail; |
| 4128 | } |
| 4129 | pReqMsg->maxAPperScan = nla_get_u32( |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4130 | tb[PARAM_MAX_AP_PER_SCAN]); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4131 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"), |
| 4132 | pReqMsg->maxAPperScan); |
| 4133 | |
| 4134 | /* Parse and fetch report threshold */ |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4135 | if (!tb[PARAM_RPT_THRHLD_PERCENT]) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4136 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed")); |
| 4137 | goto fail; |
| 4138 | } |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4139 | pReqMsg->reportThresholdPercent = nla_get_u8( |
| 4140 | tb[PARAM_RPT_THRHLD_PERCENT]); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4141 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"), |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4142 | pReqMsg->reportThresholdPercent); |
| 4143 | |
| 4144 | /* Parse and fetch report threshold num scans */ |
| 4145 | if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) { |
| 4146 | hddLog(LOGE, FL("attr report_threshold num scans failed")); |
| 4147 | goto fail; |
| 4148 | } |
| 4149 | pReqMsg->reportThresholdNumScans = nla_get_u8( |
| 4150 | tb[PARAM_RPT_THRHLD_NUM_SCANS]); |
| 4151 | hddLog(LOG1, FL("Report Threshold num scans %d"), |
| 4152 | pReqMsg->reportThresholdNumScans); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4153 | |
| 4154 | /* Parse and fetch number of buckets */ |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4155 | if (!tb[PARAM_NUM_BUCKETS]) { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4156 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed")); |
| 4157 | goto fail; |
| 4158 | } |
| 4159 | pReqMsg->numBuckets = nla_get_u8( |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4160 | tb[PARAM_NUM_BUCKETS]); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4161 | if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) { |
| 4162 | hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets " |
| 4163 | "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS); |
| 4164 | pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS; |
| 4165 | } |
| 4166 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"), |
| 4167 | pReqMsg->numBuckets); |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4168 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4169 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) { |
| 4170 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed")); |
| 4171 | goto fail; |
| 4172 | } |
| 4173 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4174 | pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4175 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4176 | if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb)) |
| 4177 | goto fail; |
Dasari Srinivas | 8b2ce27 | 2014-09-16 16:57:30 +0530 | [diff] [blame] | 4178 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4179 | context = &pHddCtx->ext_scan_context; |
| 4180 | spin_lock(&hdd_context_lock); |
| 4181 | INIT_COMPLETION(context->response_event); |
| 4182 | context->request_id = request_id = pReqMsg->requestId; |
| 4183 | spin_unlock(&hdd_context_lock); |
Dasari Srinivas | 8b2ce27 | 2014-09-16 16:57:30 +0530 | [diff] [blame] | 4184 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4185 | status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg); |
| 4186 | if (!HAL_STATUS_SUCCESS(status)) { |
| 4187 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4188 | FL("sme_EXTScanStart failed(err=%d)"), status); |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4189 | goto fail; |
| 4190 | } |
| 4191 | |
Srinivas Dasari | 91727c1 | 2016-03-23 17:59:06 +0530 | [diff] [blame] | 4192 | pHddCtx->extscan_start_time_since_boot = vos_get_monotonic_boottime(); |
| 4193 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4194 | /* request was sent -- wait for the response */ |
| 4195 | rc = wait_for_completion_timeout(&context->response_event, |
| 4196 | msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN)); |
| 4197 | |
| 4198 | if (!rc) { |
| 4199 | hddLog(LOGE, FL("sme_ExtScanStart timed out")); |
| 4200 | retval = -ETIMEDOUT; |
| 4201 | } else { |
| 4202 | spin_lock(&hdd_context_lock); |
| 4203 | if (context->request_id == request_id) |
| 4204 | retval = context->response_status; |
| 4205 | else |
| 4206 | retval = -EINVAL; |
| 4207 | spin_unlock(&hdd_context_lock); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4208 | } |
| 4209 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4210 | vos_mem_free(pReqMsg); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4211 | EXIT(); |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4212 | return retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4213 | |
| 4214 | fail: |
| 4215 | vos_mem_free(pReqMsg); |
| 4216 | return -EINVAL; |
| 4217 | } |
| 4218 | |
Padma, Santhosh Kumar | 7b9190d | 2015-08-17 17:45:29 +0530 | [diff] [blame] | 4219 | /* |
| 4220 | * done with short names for the global vendor params |
| 4221 | * used by wlan_hdd_cfg80211_extscan_start() |
| 4222 | */ |
| 4223 | #undef PARAM_MAX |
| 4224 | #undef PARAM_REQUEST_ID |
| 4225 | #undef PARAM_BASE_PERIOD |
| 4226 | #undef PARAMS_MAX_AP_PER_SCAN |
| 4227 | #undef PARAMS_RPT_THRHLD_PERCENT |
| 4228 | #undef PARAMS_RPT_THRHLD_NUM_SCANS |
| 4229 | #undef PARAMS_NUM_BUCKETS |
| 4230 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4231 | static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy, |
| 4232 | struct wireless_dev *wdev, |
| 4233 | const void *data, int dataLen) |
| 4234 | { |
| 4235 | int ret = 0; |
| 4236 | |
| 4237 | vos_ssr_protect(__func__); |
| 4238 | ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen); |
| 4239 | vos_ssr_unprotect(__func__); |
| 4240 | |
| 4241 | return ret; |
| 4242 | } |
| 4243 | |
| 4244 | static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4245 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4246 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4247 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4248 | tSirEXTScanStopReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4249 | struct net_device *dev = wdev->netdev; |
| 4250 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4251 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4252 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 4253 | eHalStatus status; |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 4254 | int retval; |
| 4255 | unsigned long rc; |
| 4256 | struct hdd_ext_scan_context *context; |
| 4257 | tANI_U32 request_id; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4258 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4259 | ENTER(); |
| 4260 | |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 4261 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 4262 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 4263 | return -EINVAL; |
| 4264 | } |
| 4265 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4266 | status = wlan_hdd_validate_context(pHddCtx); |
| 4267 | if (0 != status) |
| 4268 | { |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4269 | return -EINVAL; |
| 4270 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4271 | /* check the EXTScan Capability */ |
| 4272 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 4273 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) || |
| 4274 | (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4275 | { |
| 4276 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4277 | FL("EXTScan not enabled/supported by Firmware")); |
| 4278 | return -EINVAL; |
| 4279 | } |
| 4280 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4281 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 4282 | data, dataLen, |
| 4283 | wlan_hdd_extscan_config_policy)) { |
| 4284 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4285 | return -EINVAL; |
| 4286 | } |
| 4287 | |
| 4288 | /* Parse and fetch request Id */ |
| 4289 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 4290 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 4291 | return -EINVAL; |
| 4292 | } |
| 4293 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4294 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4295 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4296 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4297 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4298 | reqMsg.sessionId = pAdapter->sessionId; |
| 4299 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4300 | |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 4301 | context = &pHddCtx->ext_scan_context; |
| 4302 | spin_lock(&hdd_context_lock); |
| 4303 | INIT_COMPLETION(context->response_event); |
Sravanti Palakonda | 7539fb9 | 2016-02-26 17:49:21 +0530 | [diff] [blame] | 4304 | context->request_id = request_id = reqMsg.requestId; |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 4305 | spin_unlock(&hdd_context_lock); |
| 4306 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4307 | status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4308 | if (!HAL_STATUS_SUCCESS(status)) { |
| 4309 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4310 | FL("sme_EXTScanStop failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4311 | return -EINVAL; |
| 4312 | } |
| 4313 | |
Padma, Santhosh Kumar | 57cff7f | 2015-08-17 18:33:14 +0530 | [diff] [blame] | 4314 | /* request was sent -- wait for the response */ |
| 4315 | rc = wait_for_completion_timeout(&context->response_event, |
| 4316 | msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN)); |
| 4317 | |
| 4318 | if (!rc) { |
| 4319 | hddLog(LOGE, FL("sme_ExtScanStop timed out")); |
| 4320 | retval = -ETIMEDOUT; |
| 4321 | } else { |
| 4322 | spin_lock(&hdd_context_lock); |
| 4323 | if (context->request_id == request_id) |
| 4324 | retval = context->response_status; |
| 4325 | else |
| 4326 | retval = -EINVAL; |
| 4327 | spin_unlock(&hdd_context_lock); |
| 4328 | } |
| 4329 | |
| 4330 | return retval; |
| 4331 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4332 | EXIT(); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4333 | return 0; |
| 4334 | } |
| 4335 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4336 | static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy, |
| 4337 | struct wireless_dev *wdev, |
| 4338 | const void *data, int dataLen) |
| 4339 | { |
| 4340 | int ret = 0; |
| 4341 | |
| 4342 | vos_ssr_protect(__func__); |
| 4343 | ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen); |
| 4344 | vos_ssr_unprotect(__func__); |
| 4345 | |
| 4346 | return ret; |
| 4347 | } |
| 4348 | |
| 4349 | static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4350 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4351 | const void *data, int dataLen) |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4352 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4353 | tSirEXTScanResetBssidHotlistReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4354 | struct net_device *dev = wdev->netdev; |
| 4355 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4356 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4357 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 4358 | eHalStatus status; |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 4359 | struct hdd_ext_scan_context *context; |
| 4360 | tANI_U32 request_id; |
| 4361 | unsigned long rc; |
| 4362 | int retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4363 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4364 | ENTER(); |
| 4365 | |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 4366 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 4367 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 4368 | return -EINVAL; |
| 4369 | } |
| 4370 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4371 | status = wlan_hdd_validate_context(pHddCtx); |
| 4372 | if (0 != status) |
| 4373 | { |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 4374 | hddLog(LOGE, FL("HDD context is not valid")); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4375 | return -EINVAL; |
| 4376 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4377 | /* check the EXTScan Capability */ |
| 4378 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 4379 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) || |
| 4380 | (TRUE != sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED))) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4381 | { |
| 4382 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4383 | FL("EXTScan not enabled/supported by Firmware")); |
| 4384 | return -EINVAL; |
| 4385 | } |
| 4386 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4387 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 4388 | data, dataLen, |
| 4389 | wlan_hdd_extscan_config_policy)) { |
| 4390 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4391 | return -EINVAL; |
| 4392 | } |
| 4393 | |
| 4394 | /* Parse and fetch request Id */ |
| 4395 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 4396 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 4397 | return -EINVAL; |
| 4398 | } |
| 4399 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4400 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4401 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4402 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4403 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4404 | reqMsg.sessionId = pAdapter->sessionId; |
| 4405 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4406 | |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 4407 | context = &pHddCtx->ext_scan_context; |
| 4408 | spin_lock(&hdd_context_lock); |
| 4409 | INIT_COMPLETION(context->response_event); |
| 4410 | context->request_id = request_id = reqMsg.requestId; |
| 4411 | spin_unlock(&hdd_context_lock); |
| 4412 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 4413 | status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4414 | if (!HAL_STATUS_SUCCESS(status)) { |
| 4415 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4416 | FL("sme_ResetBssHotlist failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4417 | return -EINVAL; |
| 4418 | } |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 4419 | |
| 4420 | /* request was sent -- wait for the response */ |
| 4421 | rc = wait_for_completion_timeout(&context->response_event, |
| 4422 | msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN)); |
| 4423 | if (!rc) { |
| 4424 | hddLog(LOGE, FL("sme_ResetBssHotlist timed out")); |
| 4425 | retval = -ETIMEDOUT; |
| 4426 | } else { |
| 4427 | spin_lock(&hdd_context_lock); |
| 4428 | if (context->request_id == request_id) |
| 4429 | retval = context->response_status; |
| 4430 | else |
| 4431 | retval = -EINVAL; |
| 4432 | spin_unlock(&hdd_context_lock); |
| 4433 | } |
| 4434 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4435 | EXIT(); |
Padma, Santhosh Kumar | 04a3bab | 2015-08-20 13:09:35 +0530 | [diff] [blame] | 4436 | return retval; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4437 | } |
| 4438 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4439 | static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy, |
| 4440 | struct wireless_dev *wdev, |
| 4441 | const void *data, int dataLen) |
| 4442 | { |
| 4443 | int ret = 0; |
| 4444 | |
| 4445 | vos_ssr_protect(__func__); |
| 4446 | ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen); |
| 4447 | vos_ssr_unprotect(__func__); |
| 4448 | |
| 4449 | return ret; |
| 4450 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4451 | #endif /* WLAN_FEATURE_EXTSCAN */ |
| 4452 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4453 | /*EXT TDLS*/ |
| 4454 | static const struct nla_policy |
| 4455 | wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] = |
| 4456 | { |
| 4457 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 4458 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 }, |
| 4459 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] = |
| 4460 | {.type = NLA_S32 }, |
| 4461 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 }, |
| 4462 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 }, |
| 4463 | |
| 4464 | }; |
| 4465 | |
| 4466 | static const struct nla_policy |
| 4467 | wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] = |
| 4468 | { |
| 4469 | [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 4470 | |
| 4471 | }; |
| 4472 | |
| 4473 | static const struct nla_policy |
| 4474 | wlan_hdd_tdls_config_state_change_policy[ |
| 4475 | QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] = |
| 4476 | { |
| 4477 | [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 4478 | [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 }, |
| 4479 | [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 }, |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4480 | [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 }, |
| 4481 | [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] = |
| 4482 | {.type = NLA_S32 }, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4483 | |
| 4484 | }; |
| 4485 | |
| 4486 | static const struct nla_policy |
| 4487 | wlan_hdd_tdls_config_get_status_policy[ |
| 4488 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] = |
| 4489 | { |
| 4490 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 4491 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 }, |
| 4492 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 }, |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4493 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 }, |
| 4494 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS] |
| 4495 | = {.type = NLA_S32 }, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4496 | |
| 4497 | }; |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4498 | |
| 4499 | static const struct nla_policy |
| 4500 | wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] = |
| 4501 | { |
| 4502 | [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC }, |
| 4503 | }; |
| 4504 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4505 | static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy, |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4506 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4507 | const void *data, |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4508 | int data_len) |
| 4509 | { |
| 4510 | |
| 4511 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4512 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1]; |
| 4513 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4514 | ENTER(); |
| 4515 | |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4516 | if (0 != wlan_hdd_validate_context(pHddCtx)){ |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4517 | return -EINVAL; |
| 4518 | } |
Hanumantha Reddy Pothula | ca1d1cc | 2015-10-26 15:37:35 +0530 | [diff] [blame] | 4519 | if (0 == pHddCtx->cfg_ini->enableMacSpoofing) { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 4520 | hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini")); |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4521 | return -ENOTSUPP; |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 4522 | } |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4523 | if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){ |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 4524 | hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW")); |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4525 | return -ENOTSUPP; |
| 4526 | } |
| 4527 | |
| 4528 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX, |
| 4529 | data, data_len, wlan_hdd_mac_config)) { |
| 4530 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4531 | return -EINVAL; |
| 4532 | } |
| 4533 | |
| 4534 | /* Parse and fetch mac address */ |
| 4535 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) { |
| 4536 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 4537 | return -EINVAL; |
| 4538 | } |
| 4539 | |
| 4540 | memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data( |
| 4541 | tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]), |
| 4542 | VOS_MAC_ADDR_LAST_3_BYTES); |
| 4543 | |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 4544 | pHddCtx->spoofMacAddr.isEnabled = TRUE; |
| 4545 | |
| 4546 | vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data( |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4547 | tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]), |
| 4548 | VOS_MAC_ADDR_FIRST_3_BYTES); |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 4549 | if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) && |
| 4550 | (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) && |
| 4551 | (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0)) |
| 4552 | { |
| 4553 | hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing")); |
| 4554 | vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes, |
| 4555 | VOS_MAC_ADDRESS_LEN); |
| 4556 | pHddCtx->spoofMacAddr.isEnabled = FALSE; |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4557 | } |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4558 | |
Padma, Santhosh Kumar | db2d75b | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 4559 | schedule_delayed_work(&pHddCtx->spoof_mac_addr_work, |
| 4560 | msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL)); |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4561 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4562 | EXIT(); |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 4563 | return 0; |
| 4564 | } |
| 4565 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4566 | static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy, |
| 4567 | struct wireless_dev *wdev, |
| 4568 | const void *data, |
| 4569 | int data_len) |
| 4570 | { |
| 4571 | int ret = 0; |
| 4572 | |
| 4573 | vos_ssr_protect(__func__); |
| 4574 | ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len); |
| 4575 | vos_ssr_unprotect(__func__); |
| 4576 | |
| 4577 | return ret; |
| 4578 | } |
| 4579 | |
| 4580 | static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4581 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4582 | const void *data, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4583 | int data_len) |
| 4584 | { |
| 4585 | u8 peer[6] = {0}; |
| 4586 | struct net_device *dev = wdev->netdev; |
| 4587 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4588 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4589 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1]; |
| 4590 | eHalStatus ret; |
| 4591 | tANI_S32 state; |
| 4592 | tANI_S32 reason; |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4593 | tANI_S32 global_operating_class = 0; |
| 4594 | tANI_S32 channel = 0; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4595 | struct sk_buff *skb = NULL; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4596 | int retVal; |
| 4597 | |
| 4598 | ENTER(); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4599 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4600 | if (!pAdapter) { |
| 4601 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 4602 | return -EINVAL; |
| 4603 | } |
| 4604 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4605 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4606 | if (0 != ret) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4607 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4608 | return -EINVAL; |
| 4609 | } |
| 4610 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4611 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4612 | return -ENOTSUPP; |
| 4613 | } |
| 4614 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX, |
| 4615 | data, data_len, |
| 4616 | wlan_hdd_tdls_config_get_status_policy)) { |
| 4617 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4618 | return -EINVAL; |
| 4619 | } |
| 4620 | |
| 4621 | /* Parse and fetch mac address */ |
| 4622 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) { |
| 4623 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 4624 | return -EINVAL; |
| 4625 | } |
| 4626 | |
| 4627 | memcpy(peer, nla_data( |
| 4628 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]), |
| 4629 | sizeof(peer)); |
| 4630 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer)); |
| 4631 | |
Konamki, Sreelakshmi | abb59ed | 2015-06-12 12:13:23 +0530 | [diff] [blame] | 4632 | wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4633 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4634 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4635 | 4 * sizeof(s32) + |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4636 | NLMSG_HDRLEN); |
| 4637 | |
| 4638 | if (!skb) { |
| 4639 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4640 | FL("cfg80211_vendor_cmd_alloc_reply_skb failed")); |
| 4641 | return -EINVAL; |
| 4642 | } |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4643 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) class (%d) channel (%d) peer" MAC_ADDRESS_STR), |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4644 | reason, |
| 4645 | state, |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4646 | global_operating_class, |
| 4647 | channel, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4648 | MAC_ADDR_ARRAY(peer)); |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4649 | if (nla_put_s32(skb, |
| 4650 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE, |
| 4651 | state) || |
| 4652 | nla_put_s32(skb, |
| 4653 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON, |
| 4654 | reason) || |
| 4655 | nla_put_s32(skb, |
| 4656 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS, |
| 4657 | global_operating_class) || |
| 4658 | nla_put_s32(skb, |
| 4659 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL, |
| 4660 | channel)) { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4661 | |
| 4662 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 4663 | goto nla_put_failure; |
| 4664 | } |
| 4665 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4666 | retVal = cfg80211_vendor_cmd_reply(skb); |
| 4667 | EXIT(); |
| 4668 | return retVal; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4669 | |
| 4670 | nla_put_failure: |
| 4671 | kfree_skb(skb); |
| 4672 | return -EINVAL; |
| 4673 | } |
| 4674 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4675 | static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy, |
| 4676 | struct wireless_dev *wdev, |
| 4677 | const void *data, |
| 4678 | int data_len) |
| 4679 | { |
| 4680 | int ret = 0; |
| 4681 | |
| 4682 | vos_ssr_protect(__func__); |
| 4683 | ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len); |
| 4684 | vos_ssr_unprotect(__func__); |
| 4685 | |
| 4686 | return ret; |
| 4687 | } |
| 4688 | |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 4689 | static int wlan_hdd_cfg80211_exttdls_callback( |
| 4690 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 4691 | const tANI_U8* mac, |
| 4692 | #else |
| 4693 | tANI_U8* mac, |
| 4694 | #endif |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4695 | tANI_S32 state, |
| 4696 | tANI_S32 reason, |
| 4697 | void *ctx) |
| 4698 | { |
| 4699 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4700 | struct sk_buff *skb = NULL; |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4701 | tANI_S32 global_operating_class = 0; |
| 4702 | tANI_S32 channel = 0; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4703 | hdd_context_t *pHddCtx; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4704 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4705 | ENTER(); |
| 4706 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4707 | if (!pAdapter) { |
| 4708 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 4709 | return -EINVAL; |
| 4710 | } |
| 4711 | |
| 4712 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4713 | if (wlan_hdd_validate_context(pHddCtx)) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4714 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4715 | return -EINVAL; |
| 4716 | } |
| 4717 | |
| 4718 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4719 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4720 | return -ENOTSUPP; |
| 4721 | } |
Anand N Sunkad | 26ca6cc | 2015-07-29 09:54:52 +0530 | [diff] [blame] | 4722 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 4723 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 4724 | NULL, |
| 4725 | #endif |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4726 | EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 4727 | QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX, |
| 4728 | GFP_KERNEL); |
| 4729 | |
| 4730 | if (!skb) { |
| 4731 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4732 | FL("cfg80211_vendor_event_alloc failed")); |
| 4733 | return -EINVAL; |
| 4734 | } |
| 4735 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4736 | hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)", |
| 4737 | reason, |
| 4738 | state, |
| 4739 | global_operating_class, |
| 4740 | channel); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4741 | hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR, |
| 4742 | MAC_ADDR_ARRAY(mac)); |
| 4743 | |
Atul Mittal | 0a9f68d | 2014-10-16 15:26:38 +0530 | [diff] [blame] | 4744 | if (nla_put(skb, |
| 4745 | QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR, |
| 4746 | VOS_MAC_ADDR_SIZE, mac) || |
| 4747 | nla_put_s32(skb, |
| 4748 | QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE, |
| 4749 | state) || |
| 4750 | nla_put_s32(skb, |
| 4751 | QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON, |
| 4752 | reason) || |
| 4753 | nla_put_s32(skb, |
| 4754 | QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL, |
| 4755 | channel) || |
| 4756 | nla_put_s32(skb, |
| 4757 | QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS, |
| 4758 | global_operating_class) |
| 4759 | ) { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4760 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 4761 | goto nla_put_failure; |
| 4762 | } |
| 4763 | |
| 4764 | cfg80211_vendor_event(skb, GFP_KERNEL); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4765 | EXIT(); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4766 | return (0); |
| 4767 | |
| 4768 | nla_put_failure: |
| 4769 | kfree_skb(skb); |
| 4770 | return -EINVAL; |
| 4771 | } |
| 4772 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4773 | static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4774 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4775 | const void *data, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4776 | int data_len) |
| 4777 | { |
| 4778 | u8 peer[6] = {0}; |
| 4779 | struct net_device *dev = wdev->netdev; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4780 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4781 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1]; |
| 4782 | eHalStatus status; |
| 4783 | tdls_req_params_t pReqMsg = {0}; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4784 | int ret; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4785 | hdd_adapter_t *pAdapter; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4786 | |
| 4787 | ENTER(); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4788 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4789 | if (!dev) { |
| 4790 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL")); |
| 4791 | return -EINVAL; |
| 4792 | } |
| 4793 | |
| 4794 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4795 | if (!pAdapter) { |
| 4796 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 4797 | return -EINVAL; |
| 4798 | } |
| 4799 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4800 | status = wlan_hdd_validate_context(pHddCtx); |
| 4801 | if (0 != status) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4802 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4803 | return -EINVAL; |
| 4804 | } |
| 4805 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4806 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4807 | return -ENOTSUPP; |
| 4808 | } |
| 4809 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX, |
| 4810 | data, data_len, |
| 4811 | wlan_hdd_tdls_config_enable_policy)) { |
| 4812 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4813 | return -EINVAL; |
| 4814 | } |
| 4815 | |
| 4816 | /* Parse and fetch mac address */ |
| 4817 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) { |
| 4818 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 4819 | return -EINVAL; |
| 4820 | } |
| 4821 | |
| 4822 | memcpy(peer, nla_data( |
| 4823 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]), |
| 4824 | sizeof(peer)); |
| 4825 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer)); |
| 4826 | |
| 4827 | /* Parse and fetch channel */ |
| 4828 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) { |
| 4829 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed")); |
| 4830 | return -EINVAL; |
| 4831 | } |
| 4832 | pReqMsg.channel = nla_get_s32( |
| 4833 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]); |
| 4834 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel); |
| 4835 | |
| 4836 | /* Parse and fetch global operating class */ |
| 4837 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) { |
| 4838 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed")); |
| 4839 | return -EINVAL; |
| 4840 | } |
| 4841 | pReqMsg.global_operating_class = nla_get_s32( |
| 4842 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]); |
| 4843 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"), |
| 4844 | pReqMsg.global_operating_class); |
| 4845 | |
| 4846 | /* Parse and fetch latency ms */ |
| 4847 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) { |
| 4848 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed")); |
| 4849 | return -EINVAL; |
| 4850 | } |
| 4851 | pReqMsg.max_latency_ms = nla_get_s32( |
| 4852 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]); |
| 4853 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"), |
| 4854 | pReqMsg.max_latency_ms); |
| 4855 | |
| 4856 | /* Parse and fetch required bandwidth kbps */ |
| 4857 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) { |
| 4858 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed")); |
| 4859 | return -EINVAL; |
| 4860 | } |
| 4861 | |
| 4862 | pReqMsg.min_bandwidth_kbps = nla_get_s32( |
| 4863 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]); |
| 4864 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"), |
| 4865 | pReqMsg.min_bandwidth_kbps); |
| 4866 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4867 | ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4868 | peer, |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 4869 | &pReqMsg, |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4870 | wlan_hdd_cfg80211_exttdls_callback); |
| 4871 | |
| 4872 | EXIT(); |
| 4873 | return ret; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4874 | } |
| 4875 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4876 | static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy, |
| 4877 | struct wireless_dev *wdev, |
| 4878 | const void *data, |
| 4879 | int data_len) |
| 4880 | { |
| 4881 | int ret = 0; |
| 4882 | |
| 4883 | vos_ssr_protect(__func__); |
| 4884 | ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len); |
| 4885 | vos_ssr_unprotect(__func__); |
| 4886 | |
| 4887 | return ret; |
| 4888 | } |
| 4889 | |
| 4890 | static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4891 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4892 | const void *data, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4893 | int data_len) |
| 4894 | { |
| 4895 | u8 peer[6] = {0}; |
| 4896 | struct net_device *dev = wdev->netdev; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4897 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4898 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1]; |
| 4899 | eHalStatus status; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4900 | int ret; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4901 | hdd_adapter_t *pAdapter; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4902 | |
| 4903 | ENTER(); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4904 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 4905 | if (!dev) { |
| 4906 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL")); |
| 4907 | return -EINVAL; |
| 4908 | } |
| 4909 | |
| 4910 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4911 | if (!pAdapter) { |
| 4912 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL")); |
| 4913 | return -EINVAL; |
| 4914 | } |
| 4915 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4916 | status = wlan_hdd_validate_context(pHddCtx); |
| 4917 | if (0 != status) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4918 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4919 | return -EINVAL; |
| 4920 | } |
| 4921 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 4922 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4923 | return -ENOTSUPP; |
| 4924 | } |
| 4925 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX, |
| 4926 | data, data_len, |
| 4927 | wlan_hdd_tdls_config_disable_policy)) { |
| 4928 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4929 | return -EINVAL; |
| 4930 | } |
| 4931 | /* Parse and fetch mac address */ |
| 4932 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) { |
| 4933 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 4934 | return -EINVAL; |
| 4935 | } |
| 4936 | |
| 4937 | memcpy(peer, nla_data( |
| 4938 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]), |
| 4939 | sizeof(peer)); |
| 4940 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer)); |
| 4941 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4942 | ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer); |
| 4943 | |
| 4944 | EXIT(); |
| 4945 | return ret; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4946 | } |
| 4947 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4948 | static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy, |
| 4949 | struct wireless_dev *wdev, |
| 4950 | const void *data, |
| 4951 | int data_len) |
| 4952 | { |
| 4953 | int ret = 0; |
| 4954 | |
| 4955 | vos_ssr_protect(__func__); |
| 4956 | ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len); |
| 4957 | vos_ssr_unprotect(__func__); |
| 4958 | |
| 4959 | return ret; |
| 4960 | } |
| 4961 | |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 4962 | static int |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4963 | __wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 4964 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 4965 | const void *data, int data_len) |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 4966 | { |
| 4967 | struct net_device *dev = wdev->netdev; |
| 4968 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4969 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4970 | struct sk_buff *skb = NULL; |
| 4971 | tANI_U32 fset = 0; |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4972 | int ret = 0; |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 4973 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4974 | ENTER(); |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4975 | |
| 4976 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4977 | if (0 != ret) |
| 4978 | { |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 4979 | return ret; |
| 4980 | } |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 4981 | if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) { |
| 4982 | hddLog(LOG1, FL("Infra Station mode is supported by driver")); |
| 4983 | fset |= WIFI_FEATURE_INFRA; |
| 4984 | } |
| 4985 | |
| 4986 | if (TRUE == hdd_is_5g_supported(pHddCtx)) { |
| 4987 | hddLog(LOG1, FL("INFRA_5G is supported by firmware")); |
| 4988 | fset |= WIFI_FEATURE_INFRA_5G; |
| 4989 | } |
| 4990 | |
| 4991 | #ifdef WLAN_FEATURE_P2P |
| 4992 | if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) && |
| 4993 | (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) { |
| 4994 | hddLog(LOG1, FL("WiFi-Direct is supported by driver")); |
| 4995 | fset |= WIFI_FEATURE_P2P; |
| 4996 | } |
| 4997 | #endif |
| 4998 | |
| 4999 | /* Soft-AP is supported currently by default */ |
| 5000 | fset |= WIFI_FEATURE_SOFT_AP; |
| 5001 | |
Kanchanapally, Vidyullatha | 683aed0 | 2015-03-24 16:58:38 +0530 | [diff] [blame] | 5002 | /* HOTSPOT is a supplicant feature, enable it by default */ |
| 5003 | fset |= WIFI_FEATURE_HOTSPOT; |
| 5004 | |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5005 | #ifdef WLAN_FEATURE_EXTSCAN |
| 5006 | if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) && |
Padma, Santhosh Kumar | 2ac5499 | 2015-10-12 18:20:58 +0530 | [diff] [blame] | 5007 | sme_IsFeatureSupportedByFW(EXTENDED_SCAN) && |
| 5008 | sme_IsFeatureSupportedByFW(EXT_SCAN_ENHANCED)) { |
| 5009 | hddLog(LOG1, FL("Enhanced EXTScan is supported by firmware")); |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5010 | fset |= WIFI_FEATURE_EXTSCAN; |
| 5011 | } |
| 5012 | #endif |
| 5013 | |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5014 | if (sme_IsFeatureSupportedByFW(NAN)) { |
| 5015 | hddLog(LOG1, FL("NAN is supported by firmware")); |
| 5016 | fset |= WIFI_FEATURE_NAN; |
| 5017 | } |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5018 | |
| 5019 | /* D2D RTT is not supported currently by default */ |
| 5020 | if (sme_IsFeatureSupportedByFW(RTT)) { |
| 5021 | hddLog(LOG1, FL("RTT is supported by firmware")); |
| 5022 | fset |= WIFI_FEATURE_D2AP_RTT; |
| 5023 | } |
| 5024 | |
Padma, Santhosh Kumar | aac4c4d | 2015-12-08 16:07:47 +0530 | [diff] [blame] | 5025 | if (sme_IsFeatureSupportedByFW(RTT3)) { |
| 5026 | hddLog(LOG1, FL("RTT3 is supported by firmware")); |
| 5027 | fset |= WIFI_FEATURE_RTT3; |
| 5028 | } |
| 5029 | |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5030 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 5031 | if (fset & WIFI_FEATURE_EXTSCAN) { |
| 5032 | hddLog(LOG1, FL("Batch scan is supported as extscan is supported")); |
| 5033 | fset &= ~WIFI_FEATURE_BATCH_SCAN; |
| 5034 | } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) { |
| 5035 | hddLog(LOG1, FL("Batch scan is supported by firmware")); |
| 5036 | fset |= WIFI_FEATURE_BATCH_SCAN; |
| 5037 | } |
| 5038 | #endif |
| 5039 | |
| 5040 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 5041 | if (pHddCtx->cfg_ini->configPNOScanSupport && |
| 5042 | (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) { |
| 5043 | hddLog(LOG1, FL("PNO is supported by firmware")); |
| 5044 | fset |= WIFI_FEATURE_PNO; |
| 5045 | } |
| 5046 | #endif |
| 5047 | |
| 5048 | /* STA+STA is supported currently by default */ |
| 5049 | fset |= WIFI_FEATURE_ADDITIONAL_STA; |
| 5050 | |
| 5051 | #ifdef FEATURE_WLAN_TDLS |
| 5052 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) && |
| 5053 | sme_IsFeatureSupportedByFW(TDLS)) { |
| 5054 | hddLog(LOG1, FL("TDLS is supported by firmware")); |
| 5055 | fset |= WIFI_FEATURE_TDLS; |
| 5056 | } |
| 5057 | |
| 5058 | /* TDLS_OFFCHANNEL is not supported currently by default */ |
| 5059 | #endif |
| 5060 | |
| 5061 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 5062 | /* AP+STA concurrency is supported currently by default */ |
| 5063 | fset |= WIFI_FEATURE_AP_STA; |
| 5064 | #endif |
| 5065 | |
Mukul Sharma | 5add053 | 2015-08-17 15:57:47 +0530 | [diff] [blame] | 5066 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 5067 | fset |= WIFI_FEATURE_LINK_LAYER_STATS; |
| 5068 | hddLog(LOG1, FL("Link layer stats is supported by driver")); |
| 5069 | #endif |
| 5070 | |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5071 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) + |
| 5072 | NLMSG_HDRLEN); |
| 5073 | |
| 5074 | if (!skb) { |
| 5075 | hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed")); |
| 5076 | return -EINVAL; |
| 5077 | } |
| 5078 | hddLog(LOG1, FL("Supported Features : 0x%x"), fset); |
| 5079 | |
| 5080 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) { |
| 5081 | hddLog(LOGE, FL("nla put fail")); |
| 5082 | goto nla_put_failure; |
| 5083 | } |
| 5084 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5085 | ret = cfg80211_vendor_cmd_reply(skb); |
| 5086 | EXIT(); |
| 5087 | return ret; |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 5088 | |
| 5089 | nla_put_failure: |
| 5090 | kfree_skb(skb); |
| 5091 | return -EINVAL; |
| 5092 | } |
| 5093 | |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5094 | static int |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5095 | wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy, |
| 5096 | struct wireless_dev *wdev, |
| 5097 | const void *data, int data_len) |
| 5098 | { |
| 5099 | int ret = 0; |
| 5100 | |
| 5101 | vos_ssr_protect(__func__); |
| 5102 | ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len); |
| 5103 | vos_ssr_unprotect(__func__); |
| 5104 | |
| 5105 | return ret; |
| 5106 | } |
| 5107 | |
Sachin Ahuja | c08f72a | 2015-09-22 15:25:47 +0530 | [diff] [blame] | 5108 | |
| 5109 | static const struct |
| 5110 | nla_policy |
| 5111 | qca_wlan_vendor_wifi_logger_get_ring_data_policy |
| 5112 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1] = { |
| 5113 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID] |
| 5114 | = {.type = NLA_U32 }, |
| 5115 | }; |
| 5116 | |
| 5117 | static int |
| 5118 | __wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 5119 | struct wireless_dev *wdev, |
| 5120 | const void *data, |
| 5121 | int data_len) |
| 5122 | { |
| 5123 | int ret; |
| 5124 | VOS_STATUS status; |
| 5125 | uint32_t ring_id; |
| 5126 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5127 | struct nlattr *tb |
| 5128 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX + 1]; |
| 5129 | |
| 5130 | ENTER(); |
| 5131 | |
| 5132 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5133 | if (0 != ret) { |
| 5134 | return ret; |
| 5135 | } |
| 5136 | |
| 5137 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_MAX, |
| 5138 | data, data_len, |
| 5139 | qca_wlan_vendor_wifi_logger_get_ring_data_policy)) { |
| 5140 | hddLog(LOGE, FL("Invalid attribute")); |
| 5141 | return -EINVAL; |
| 5142 | } |
| 5143 | |
| 5144 | /* Parse and fetch ring id */ |
| 5145 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]) { |
| 5146 | hddLog(LOGE, FL("attr ATTR failed")); |
| 5147 | return -EINVAL; |
| 5148 | } |
| 5149 | |
| 5150 | ring_id = nla_get_u32( |
| 5151 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_GET_RING_DATA_ID]); |
| 5152 | |
| 5153 | hddLog(LOG1, FL("Bug report triggered by framework")); |
| 5154 | |
| 5155 | status = vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL, |
| 5156 | WLAN_LOG_INDICATOR_FRAMEWORK, |
| 5157 | WLAN_LOG_REASON_CODE_FRAMEWORK, |
Abhishek Singh | 837adf2 | 2015-10-01 17:37:37 +0530 | [diff] [blame] | 5158 | TRUE, TRUE |
Sachin Ahuja | c08f72a | 2015-09-22 15:25:47 +0530 | [diff] [blame] | 5159 | ); |
| 5160 | if (VOS_STATUS_SUCCESS != status) { |
| 5161 | hddLog(LOGE, FL("Failed to trigger bug report")); |
| 5162 | |
| 5163 | return -EINVAL; |
| 5164 | } |
| 5165 | |
| 5166 | return 0; |
| 5167 | |
| 5168 | |
| 5169 | } |
| 5170 | |
| 5171 | |
| 5172 | static int |
| 5173 | wlan_hdd_cfg80211_wifi_logger_get_ring_data(struct wiphy *wiphy, |
| 5174 | struct wireless_dev *wdev, |
| 5175 | const void *data, |
| 5176 | int data_len) |
| 5177 | { |
| 5178 | int ret = 0; |
| 5179 | |
| 5180 | vos_ssr_protect(__func__); |
| 5181 | ret = __wlan_hdd_cfg80211_wifi_logger_get_ring_data(wiphy, |
| 5182 | wdev, data, data_len); |
| 5183 | vos_ssr_unprotect(__func__); |
| 5184 | |
| 5185 | return ret; |
| 5186 | |
| 5187 | } |
| 5188 | |
Rajeev Kumar Sirasanagandla | 4c00e0d | 2017-06-13 12:04:09 +0530 | [diff] [blame] | 5189 | #define MAX_CONCURRENT_MATRIX \ |
| 5190 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX |
| 5191 | #define MATRIX_CONFIG_PARAM_SET_SIZE_MAX \ |
| 5192 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX |
| 5193 | static const struct nla_policy |
| 5194 | wlan_hdd_get_concurrency_matrix_policy[MAX_CONCURRENT_MATRIX + 1] = { |
| 5195 | [MATRIX_CONFIG_PARAM_SET_SIZE_MAX] = {.type = NLA_U32}, |
| 5196 | }; |
Sachin Ahuja | c08f72a | 2015-09-22 15:25:47 +0530 | [diff] [blame] | 5197 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5198 | static int |
| 5199 | __wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy, |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5200 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 5201 | const void *data, int data_len) |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5202 | { |
| 5203 | uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0}; |
| 5204 | uint8_t i, feature_sets, max_feature_sets; |
Rajeev Kumar Sirasanagandla | 4c00e0d | 2017-06-13 12:04:09 +0530 | [diff] [blame] | 5205 | struct nlattr *tb[MAX_CONCURRENT_MATRIX + 1]; |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5206 | struct sk_buff *reply_skb; |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5207 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 5208 | int ret; |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5209 | |
| 5210 | ENTER(); |
| 5211 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5212 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5213 | if (0 != ret) |
| 5214 | { |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5215 | return ret; |
| 5216 | } |
| 5217 | |
Rajeev Kumar Sirasanagandla | 4c00e0d | 2017-06-13 12:04:09 +0530 | [diff] [blame] | 5218 | if (nla_parse(tb, MAX_CONCURRENT_MATRIX, data, data_len, |
| 5219 | wlan_hdd_get_concurrency_matrix_policy)) { |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5220 | hddLog(LOGE, FL("Invalid ATTR")); |
| 5221 | return -EINVAL; |
| 5222 | } |
| 5223 | |
| 5224 | /* Parse and fetch max feature set */ |
Rajeev Kumar Sirasanagandla | 4c00e0d | 2017-06-13 12:04:09 +0530 | [diff] [blame] | 5225 | if (!tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) { |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5226 | hddLog(LOGE, FL("Attr max feature set size failed")); |
| 5227 | return -EINVAL; |
| 5228 | } |
Rajeev Kumar Sirasanagandla | 4c00e0d | 2017-06-13 12:04:09 +0530 | [diff] [blame] | 5229 | max_feature_sets = nla_get_u32(tb[MATRIX_CONFIG_PARAM_SET_SIZE_MAX]); |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5230 | hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets); |
| 5231 | |
| 5232 | /* Fill feature combination matrix */ |
| 5233 | feature_sets = 0; |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5234 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
| 5235 | WIFI_FEATURE_P2P; |
| 5236 | |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5237 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
| 5238 | WIFI_FEATURE_SOFT_AP; |
| 5239 | |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5240 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P | |
| 5241 | WIFI_FEATURE_SOFT_AP; |
| 5242 | |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5243 | feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA | |
| 5244 | WIFI_FEATURE_SOFT_AP | |
| 5245 | WIFI_FEATURE_P2P; |
| 5246 | |
| 5247 | /* Add more feature combinations here */ |
| 5248 | |
| 5249 | feature_sets = VOS_MIN(feature_sets, max_feature_sets); |
| 5250 | hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets); |
| 5251 | hddLog(LOG1, "Feature set matrix"); |
| 5252 | for (i = 0; i < feature_sets; i++) |
| 5253 | hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]); |
| 5254 | |
| 5255 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 5256 | sizeof(u32) * feature_sets + |
| 5257 | NLMSG_HDRLEN); |
| 5258 | |
| 5259 | if (reply_skb) { |
| 5260 | if (nla_put_u32(reply_skb, |
| 5261 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE, |
| 5262 | feature_sets) || |
| 5263 | nla_put(reply_skb, |
| 5264 | QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET, |
| 5265 | sizeof(u32) * feature_sets, feature_set_matrix)) { |
| 5266 | hddLog(LOGE, FL("nla put fail")); |
| 5267 | kfree_skb(reply_skb); |
| 5268 | return -EINVAL; |
| 5269 | } |
| 5270 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5271 | ret = cfg80211_vendor_cmd_reply(reply_skb); |
| 5272 | EXIT(); |
| 5273 | return ret; |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5274 | } |
| 5275 | hddLog(LOGE, FL("Feature set matrix: buffer alloc fail")); |
| 5276 | return -ENOMEM; |
| 5277 | |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 5278 | } |
| 5279 | |
Rajeev Kumar Sirasanagandla | 4c00e0d | 2017-06-13 12:04:09 +0530 | [diff] [blame] | 5280 | #undef MAX_CONCURRENT_MATRIX |
| 5281 | #undef MATRIX_CONFIG_PARAM_SET_SIZE_MAX |
| 5282 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5283 | static int |
| 5284 | wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy, |
| 5285 | struct wireless_dev *wdev, |
| 5286 | const void *data, int data_len) |
| 5287 | { |
| 5288 | int ret = 0; |
| 5289 | |
| 5290 | vos_ssr_protect(__func__); |
| 5291 | ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data, |
| 5292 | data_len); |
| 5293 | vos_ssr_unprotect(__func__); |
| 5294 | |
| 5295 | return ret; |
| 5296 | } |
| 5297 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 5298 | |
| 5299 | static int |
| 5300 | __wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy, |
| 5301 | struct wireless_dev *wdev, |
| 5302 | const void *data, int data_len) |
| 5303 | { |
| 5304 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 5305 | int ret; |
| 5306 | ENTER(); |
| 5307 | |
| 5308 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5309 | if (0 != ret) |
| 5310 | { |
| 5311 | return ret; |
| 5312 | } |
| 5313 | |
| 5314 | if( !pHddCtx->cfg_ini->enableFwrMemDump || |
| 5315 | (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED))) |
| 5316 | { |
| 5317 | hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported")); |
| 5318 | return -EINVAL; |
| 5319 | } |
| 5320 | /*call common API for FW mem dump req*/ |
| 5321 | ret = wlan_hdd_fw_mem_dump_req(pHddCtx); |
| 5322 | |
Abhishek Singh | c783fa7 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 5323 | if (!ret) |
c_manjee | 04b4c5c | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 5324 | { |
| 5325 | /*indicate to userspace the status of fw mem dump */ |
| 5326 | wlan_indicate_mem_dump_complete(true); |
| 5327 | } |
| 5328 | else |
| 5329 | { |
| 5330 | /*else send failure to userspace */ |
| 5331 | wlan_indicate_mem_dump_complete(false); |
| 5332 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 5333 | EXIT(); |
| 5334 | return ret; |
| 5335 | } |
| 5336 | |
| 5337 | /** |
| 5338 | * wlan_hdd_cfg80211_get_fw_mem_dump() - Get FW memory dump |
| 5339 | * @wiphy: pointer to wireless wiphy structure. |
| 5340 | * @wdev: pointer to wireless_dev structure. |
| 5341 | * @data: Pointer to the NL data. |
| 5342 | * @data_len:Length of @data |
| 5343 | * |
| 5344 | * This is called when wlan driver needs to get the firmware memory dump |
| 5345 | * via vendor specific command. |
| 5346 | * |
| 5347 | * Return: 0 on success, error number otherwise. |
| 5348 | */ |
| 5349 | |
| 5350 | static int |
| 5351 | wlan_hdd_cfg80211_get_fw_mem_dump(struct wiphy *wiphy, |
| 5352 | struct wireless_dev *wdev, |
| 5353 | const void *data, int data_len) |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 5354 | { |
| 5355 | int ret = 0; |
| 5356 | vos_ssr_protect(__func__); |
| 5357 | ret = __wlan_hdd_cfg80211_get_fw_mem_dump(wiphy, wdev, data, |
| 5358 | data_len); |
| 5359 | vos_ssr_unprotect(__func__); |
| 5360 | return ret; |
| 5361 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 5362 | |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 5363 | static const struct |
| 5364 | nla_policy |
| 5365 | qca_wlan_vendor_wifi_logger_start_policy |
| 5366 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1] = { |
| 5367 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID] |
| 5368 | = {.type = NLA_U32 }, |
| 5369 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL] |
| 5370 | = {.type = NLA_U32 }, |
| 5371 | [QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS] |
| 5372 | = {.type = NLA_U32 }, |
| 5373 | }; |
| 5374 | |
| 5375 | /** |
| 5376 | * __wlan_hdd_cfg80211_wifi_logger_start() - This function is used to enable |
| 5377 | * or disable the collection of packet statistics from the firmware |
| 5378 | * @wiphy: WIPHY structure pointer |
| 5379 | * @wdev: Wireless device structure pointer |
| 5380 | * @data: Pointer to the data received |
| 5381 | * @data_len: Length of the data received |
| 5382 | * |
| 5383 | * This function is used to enable or disable the collection of packet |
| 5384 | * statistics from the firmware |
| 5385 | * |
| 5386 | * Return: 0 on success and errno on failure |
| 5387 | */ |
| 5388 | static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 5389 | struct wireless_dev *wdev, |
| 5390 | const void *data, |
| 5391 | int data_len) |
| 5392 | { |
| 5393 | eHalStatus status; |
| 5394 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5395 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX + 1]; |
| 5396 | tAniWifiStartLog start_log; |
| 5397 | |
| 5398 | status = wlan_hdd_validate_context(hdd_ctx); |
| 5399 | if (0 != status) { |
| 5400 | return -EINVAL; |
| 5401 | } |
| 5402 | |
| 5403 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_START_MAX, |
| 5404 | data, data_len, |
| 5405 | qca_wlan_vendor_wifi_logger_start_policy)) { |
| 5406 | hddLog(LOGE, FL("Invalid attribute")); |
| 5407 | return -EINVAL; |
| 5408 | } |
| 5409 | |
| 5410 | /* Parse and fetch ring id */ |
| 5411 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]) { |
| 5412 | hddLog(LOGE, FL("attr ATTR failed")); |
| 5413 | return -EINVAL; |
| 5414 | } |
| 5415 | start_log.ringId = nla_get_u32( |
| 5416 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_RING_ID]); |
| 5417 | hddLog(LOG1, FL("Ring ID=%d"), start_log.ringId); |
| 5418 | |
| 5419 | /* Parse and fetch verbose level */ |
| 5420 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]) { |
| 5421 | hddLog(LOGE, FL("attr verbose_level failed")); |
| 5422 | return -EINVAL; |
| 5423 | } |
| 5424 | start_log.verboseLevel = nla_get_u32( |
| 5425 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_VERBOSE_LEVEL]); |
| 5426 | hddLog(LOG1, FL("verbose_level=%d"), start_log.verboseLevel); |
| 5427 | |
| 5428 | /* Parse and fetch flag */ |
| 5429 | if (!tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]) { |
| 5430 | hddLog(LOGE, FL("attr flag failed")); |
| 5431 | return -EINVAL; |
| 5432 | } |
| 5433 | start_log.flag = nla_get_u32( |
| 5434 | tb[QCA_WLAN_VENDOR_ATTR_WIFI_LOGGER_FLAGS]); |
| 5435 | hddLog(LOG1, FL("flag=%d"), start_log.flag); |
| 5436 | |
| 5437 | if ((RING_ID_PER_PACKET_STATS == start_log.ringId) && |
Sushant Kaushik | 3320057 | 2015-08-05 16:46:20 +0530 | [diff] [blame] | 5438 | (!hdd_ctx->cfg_ini->wlanPerPktStatsLogEnable || |
| 5439 | !vos_isPktStatsEnabled())) |
| 5440 | |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 5441 | { |
| 5442 | hddLog(LOGE, FL("per pkt stats not enabled")); |
| 5443 | return -EINVAL; |
| 5444 | } |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 5445 | |
Sushant Kaushik | 3320057 | 2015-08-05 16:46:20 +0530 | [diff] [blame] | 5446 | vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel); |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 5447 | return 0; |
| 5448 | } |
| 5449 | |
| 5450 | /** |
| 5451 | * wlan_hdd_cfg80211_wifi_logger_start() - Wrapper function used to enable |
| 5452 | * or disable the collection of packet statistics from the firmware |
| 5453 | * @wiphy: WIPHY structure pointer |
| 5454 | * @wdev: Wireless device structure pointer |
| 5455 | * @data: Pointer to the data received |
| 5456 | * @data_len: Length of the data received |
| 5457 | * |
| 5458 | * This function is used to enable or disable the collection of packet |
| 5459 | * statistics from the firmware |
| 5460 | * |
| 5461 | * Return: 0 on success and errno on failure |
| 5462 | */ |
| 5463 | static int wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, |
| 5464 | struct wireless_dev *wdev, |
| 5465 | const void *data, |
| 5466 | int data_len) |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 5467 | { |
| 5468 | int ret = 0; |
| 5469 | |
| 5470 | vos_ssr_protect(__func__); |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 5471 | |
| 5472 | ret = __wlan_hdd_cfg80211_wifi_logger_start(wiphy, |
| 5473 | wdev, data, data_len); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 5474 | vos_ssr_unprotect(__func__); |
| 5475 | |
| 5476 | return ret; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 5477 | } |
| 5478 | |
| 5479 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 5480 | static const struct nla_policy |
| 5481 | wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX |
| 5482 | +1] = |
| 5483 | { |
| 5484 | [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 }, |
| 5485 | }; |
| 5486 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5487 | static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy, |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 5488 | struct wireless_dev *wdev, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 5489 | const void *data, |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 5490 | int data_len) |
| 5491 | { |
| 5492 | struct net_device *dev = wdev->netdev; |
| 5493 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5494 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5495 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 5496 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1]; |
| 5497 | eHalStatus status; |
| 5498 | u32 dfsFlag = 0; |
| 5499 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5500 | ENTER(); |
| 5501 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 5502 | status = wlan_hdd_validate_context(pHddCtx); |
| 5503 | if (0 != status) { |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 5504 | return -EINVAL; |
| 5505 | } |
| 5506 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX, |
| 5507 | data, data_len, |
| 5508 | wlan_hdd_set_no_dfs_flag_config_policy)) { |
| 5509 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 5510 | return -EINVAL; |
| 5511 | } |
| 5512 | |
| 5513 | /* Parse and fetch required bandwidth kbps */ |
| 5514 | if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) { |
| 5515 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed")); |
| 5516 | return -EINVAL; |
| 5517 | } |
| 5518 | |
| 5519 | dfsFlag = nla_get_u32( |
| 5520 | tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]); |
| 5521 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"), |
| 5522 | dfsFlag); |
| 5523 | |
| 5524 | pHddCtx->disable_dfs_flag = dfsFlag; |
| 5525 | |
| 5526 | sme_disable_dfs_channel(hHal, dfsFlag); |
| 5527 | sme_FilterScanResults(hHal, pAdapter->sessionId); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5528 | |
| 5529 | EXIT(); |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 5530 | return 0; |
| 5531 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 5532 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5533 | static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy, |
| 5534 | struct wireless_dev *wdev, |
| 5535 | const void *data, |
| 5536 | int data_len) |
| 5537 | { |
| 5538 | int ret = 0; |
| 5539 | |
| 5540 | vos_ssr_protect(__func__); |
| 5541 | ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len); |
| 5542 | vos_ssr_unprotect(__func__); |
| 5543 | |
| 5544 | return ret; |
| 5545 | |
| 5546 | } |
| 5547 | |
Mukul Sharma | 2a27163 | 2014-10-13 14:59:01 +0530 | [diff] [blame] | 5548 | const struct |
| 5549 | nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] = |
| 5550 | { |
| 5551 | [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 }, |
| 5552 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC }, |
| 5553 | }; |
| 5554 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5555 | static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy, |
Jeff Johnson | 393c270 | 2014-12-16 11:09:35 +0530 | [diff] [blame] | 5556 | struct wireless_dev *wdev, const void *data, int data_len) |
Mukul Sharma | 2a27163 | 2014-10-13 14:59:01 +0530 | [diff] [blame] | 5557 | { |
| 5558 | |
| 5559 | u8 bssid[6] = {0}; |
| 5560 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 5561 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 5562 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5563 | v_U32_t isFwrRoamEnabled = FALSE; |
| 5564 | int ret; |
| 5565 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5566 | ENTER(); |
| 5567 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5568 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5569 | if (0 != ret) { |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5570 | return ret; |
Mukul Sharma | 2a27163 | 2014-10-13 14:59:01 +0530 | [diff] [blame] | 5571 | } |
| 5572 | |
| 5573 | ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, |
| 5574 | data, data_len, |
| 5575 | qca_wlan_vendor_attr); |
| 5576 | if (ret){ |
| 5577 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 5578 | return -EINVAL; |
| 5579 | } |
| 5580 | |
| 5581 | /* Parse and fetch Enable flag */ |
| 5582 | if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) { |
| 5583 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed")); |
| 5584 | return -EINVAL; |
| 5585 | } |
| 5586 | |
| 5587 | isFwrRoamEnabled = nla_get_u32( |
| 5588 | tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]); |
| 5589 | |
| 5590 | hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled); |
| 5591 | |
| 5592 | /* Parse and fetch bssid */ |
| 5593 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
| 5594 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed")); |
| 5595 | return -EINVAL; |
| 5596 | } |
| 5597 | |
| 5598 | memcpy(bssid, nla_data( |
| 5599 | tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]), |
| 5600 | sizeof(bssid)); |
| 5601 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid)); |
| 5602 | |
| 5603 | //Update roaming |
| 5604 | status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled); |
Abhishek Singh | c6ab38f | 2016-06-28 17:48:16 +0530 | [diff] [blame] | 5605 | if (!HAL_STATUS_SUCCESS(status)) { |
| 5606 | hddLog(LOGE, |
| 5607 | FL("sme_ConfigFwrRoaming failed (err=%d)"), status); |
| 5608 | return -EINVAL; |
| 5609 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5610 | EXIT(); |
Abhishek Singh | c6ab38f | 2016-06-28 17:48:16 +0530 | [diff] [blame] | 5611 | return 0; |
Mukul Sharma | 2a27163 | 2014-10-13 14:59:01 +0530 | [diff] [blame] | 5612 | } |
| 5613 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 5614 | static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy, |
| 5615 | struct wireless_dev *wdev, const void *data, int data_len) |
| 5616 | { |
| 5617 | int ret = 0; |
| 5618 | |
| 5619 | vos_ssr_protect(__func__); |
| 5620 | ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len); |
| 5621 | vos_ssr_unprotect(__func__); |
| 5622 | |
| 5623 | return ret; |
| 5624 | } |
| 5625 | |
Sushant Kaushik | 847890c | 2015-09-28 16:05:17 +0530 | [diff] [blame] | 5626 | static const struct |
| 5627 | nla_policy |
| 5628 | qca_wlan_vendor_get_wifi_info_policy[ |
| 5629 | QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX +1] = { |
| 5630 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION] = {.type = NLA_U8 }, |
| 5631 | [QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION] = {.type = NLA_U8 }, |
| 5632 | }; |
| 5633 | |
| 5634 | |
| 5635 | /** |
| 5636 | * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 5637 | * @wiphy: pointer to wireless wiphy structure. |
| 5638 | * @wdev: pointer to wireless_dev structure. |
| 5639 | * @data: Pointer to the data to be passed via vendor interface |
| 5640 | * @data_len:Length of the data to be passed |
| 5641 | * |
| 5642 | * This is called when wlan driver needs to send wifi driver related info |
| 5643 | * (driver/fw version) to the user space application upon request. |
| 5644 | * |
| 5645 | * Return: Return the Success or Failure code. |
| 5646 | */ |
| 5647 | static int __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 5648 | struct wireless_dev *wdev, |
| 5649 | const void *data, int data_len) |
| 5650 | { |
| 5651 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5652 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1]; |
| 5653 | tSirVersionString version; |
| 5654 | uint32 version_len; |
| 5655 | uint8 attr; |
| 5656 | int status; |
| 5657 | struct sk_buff *reply_skb = NULL; |
| 5658 | |
| 5659 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 5660 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 5661 | return -EINVAL; |
| 5662 | } |
| 5663 | |
| 5664 | status = wlan_hdd_validate_context(hdd_ctx); |
| 5665 | if (0 != status) { |
| 5666 | hddLog(LOGE, FL("HDD context is not valid")); |
| 5667 | return -EINVAL; |
| 5668 | } |
| 5669 | |
| 5670 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX, data, |
| 5671 | data_len, qca_wlan_vendor_get_wifi_info_policy)) { |
| 5672 | hddLog(LOGE, FL("WIFI_INFO_GET NL CMD parsing failed")); |
| 5673 | return -EINVAL; |
| 5674 | } |
| 5675 | |
| 5676 | if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { |
| 5677 | hddLog(LOG1, FL("Rcvd req for Driver version Driver version is %s"), |
| 5678 | QWLAN_VERSIONSTR); |
| 5679 | strlcpy(version, QWLAN_VERSIONSTR, sizeof(version)); |
| 5680 | attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION; |
| 5681 | } else if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION]) { |
| 5682 | hddLog(LOG1, FL("Rcvd req for FW version FW version is %s"), |
| 5683 | hdd_ctx->fw_Version); |
| 5684 | strlcpy(version, hdd_ctx->fw_Version, sizeof(version)); |
| 5685 | attr = QCA_WLAN_VENDOR_ATTR_WIFI_INFO_FIRMWARE_VERSION; |
| 5686 | } else { |
| 5687 | hddLog(LOGE, FL("Invalid attribute in get wifi info request")); |
| 5688 | return -EINVAL; |
| 5689 | } |
| 5690 | |
| 5691 | version_len = strlen(version); |
| 5692 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 5693 | version_len + NLA_HDRLEN + NLMSG_HDRLEN); |
| 5694 | if (!reply_skb) { |
| 5695 | hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed")); |
| 5696 | return -ENOMEM; |
| 5697 | } |
| 5698 | |
| 5699 | if (nla_put(reply_skb, attr, version_len, version)) { |
| 5700 | hddLog(LOGE, FL("nla put fail")); |
| 5701 | kfree_skb(reply_skb); |
| 5702 | return -EINVAL; |
| 5703 | } |
| 5704 | |
| 5705 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 5706 | } |
| 5707 | |
| 5708 | /** |
| 5709 | * __wlan_hdd_cfg80211_get_wifi_info() - Get the wifi driver related info |
| 5710 | * @wiphy: pointer to wireless wiphy structure. |
| 5711 | * @wdev: pointer to wireless_dev structure. |
| 5712 | * @data: Pointer to the data to be passed via vendor interface |
| 5713 | * @data_len:Length of the data to be passed |
| 5714 | * @data_len: Length of the data received |
| 5715 | * |
| 5716 | * This function is used to enable or disable the collection of packet |
| 5717 | * statistics from the firmware |
| 5718 | * |
| 5719 | * Return: 0 on success and errno on failure |
| 5720 | */ |
| 5721 | |
| 5722 | static int |
| 5723 | wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy, |
| 5724 | struct wireless_dev *wdev, |
| 5725 | const void *data, int data_len) |
| 5726 | |
| 5727 | |
| 5728 | { |
| 5729 | int ret = 0; |
| 5730 | |
| 5731 | vos_ssr_protect(__func__); |
| 5732 | ret = __wlan_hdd_cfg80211_get_wifi_info(wiphy, |
| 5733 | wdev, data, data_len); |
| 5734 | vos_ssr_unprotect(__func__); |
| 5735 | |
| 5736 | return ret; |
| 5737 | } |
| 5738 | |
| 5739 | |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5740 | /* |
| 5741 | * define short names for the global vendor params |
| 5742 | * used by __wlan_hdd_cfg80211_monitor_rssi() |
| 5743 | */ |
| 5744 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX |
| 5745 | #define PARAM_REQUEST_ID QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID |
| 5746 | #define PARAM_CONTROL QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CONTROL |
| 5747 | #define PARAM_MIN_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MIN_RSSI |
| 5748 | #define PARAM_MAX_RSSI QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX_RSSI |
| 5749 | |
| 5750 | /**--------------------------------------------------------------------------- |
| 5751 | |
| 5752 | \brief hdd_rssi_monitor_start_done - callback to be executed when rssi |
| 5753 | monitor start is completed successfully. |
| 5754 | |
| 5755 | \return - None |
| 5756 | |
| 5757 | --------------------------------------------------------------------------*/ |
| 5758 | void hdd_rssi_monitor_start_done(void *fwRssiMonitorCbContext, VOS_STATUS status) |
| 5759 | { |
| 5760 | hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext; |
| 5761 | |
| 5762 | if (NULL == pHddCtx) |
| 5763 | { |
| 5764 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5765 | "%s: HDD context is NULL",__func__); |
| 5766 | return; |
| 5767 | } |
| 5768 | |
| 5769 | if (VOS_STATUS_SUCCESS == status) |
| 5770 | { |
| 5771 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor start successful")); |
| 5772 | } |
| 5773 | else |
| 5774 | { |
| 5775 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor start not successful")); |
| 5776 | } |
| 5777 | |
| 5778 | return; |
| 5779 | } |
| 5780 | |
| 5781 | /**--------------------------------------------------------------------------- |
| 5782 | |
| 5783 | \brief hdd_rssi_monitor_stop_done - callback to be executed when rssi monitor |
| 5784 | stop is completed successfully. |
| 5785 | |
| 5786 | \return - None |
| 5787 | |
| 5788 | --------------------------------------------------------------------------*/ |
| 5789 | void hdd_rssi_monitor_stop_done(void *fwRssiMonitorCbContext, VOS_STATUS status) |
| 5790 | { |
| 5791 | hdd_context_t* pHddCtx = (hdd_context_t*)fwRssiMonitorCbContext; |
| 5792 | |
| 5793 | if (NULL == pHddCtx) |
| 5794 | { |
| 5795 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5796 | "%s: HDD context is NULL",__func__); |
| 5797 | return; |
| 5798 | } |
| 5799 | |
| 5800 | if (VOS_STATUS_SUCCESS == status) |
| 5801 | { |
| 5802 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Rssi Monitor stop successful")); |
| 5803 | } |
| 5804 | else |
| 5805 | { |
| 5806 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Rssi Monitor stop not successful")); |
| 5807 | } |
| 5808 | |
| 5809 | return; |
| 5810 | } |
| 5811 | |
| 5812 | /** |
| 5813 | * __wlan_hdd_cfg80211_monitor_rssi() - monitor rssi |
| 5814 | * @wiphy: Pointer to wireless phy |
| 5815 | * @wdev: Pointer to wireless device |
| 5816 | * @data: Pointer to data |
| 5817 | * @data_len: Data length |
| 5818 | * |
| 5819 | * Return: 0 on success, negative errno on failure |
| 5820 | */ |
| 5821 | |
| 5822 | static int |
| 5823 | __wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, |
| 5824 | struct wireless_dev *wdev, |
| 5825 | const void *data, |
| 5826 | int data_len) |
| 5827 | { |
| 5828 | struct net_device *dev = wdev->netdev; |
| 5829 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5830 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 5831 | hdd_station_ctx_t *pHddStaCtx; |
| 5832 | struct nlattr *tb[PARAM_MAX + 1]; |
| 5833 | tpSirRssiMonitorReq pReq; |
| 5834 | eHalStatus status; |
| 5835 | int ret; |
| 5836 | uint32_t control; |
| 5837 | static const struct nla_policy policy[PARAM_MAX + 1] = { |
| 5838 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 5839 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 5840 | [PARAM_MIN_RSSI] = { .type = NLA_S8 }, |
| 5841 | [PARAM_MAX_RSSI] = { .type = NLA_S8 }, |
| 5842 | }; |
| 5843 | |
| 5844 | ENTER(); |
| 5845 | |
| 5846 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 5847 | if (0 != ret) { |
| 5848 | return -EINVAL; |
| 5849 | } |
| 5850 | |
| 5851 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 5852 | hddLog(LOGE, FL("Not in Connected state!")); |
| 5853 | return -ENOTSUPP; |
| 5854 | } |
| 5855 | |
| 5856 | if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) { |
| 5857 | hddLog(LOGE, FL("Invalid ATTR")); |
| 5858 | return -EINVAL; |
| 5859 | } |
| 5860 | |
| 5861 | if (!tb[PARAM_REQUEST_ID]) { |
| 5862 | hddLog(LOGE, FL("attr request id failed")); |
| 5863 | return -EINVAL; |
| 5864 | } |
| 5865 | |
| 5866 | if (!tb[PARAM_CONTROL]) { |
| 5867 | hddLog(LOGE, FL("attr control failed")); |
| 5868 | return -EINVAL; |
| 5869 | } |
| 5870 | |
| 5871 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5872 | |
| 5873 | pReq = vos_mem_malloc(sizeof(tSirRssiMonitorReq)); |
| 5874 | if(NULL == pReq) |
| 5875 | { |
| 5876 | hddLog(LOGE, |
| 5877 | FL("vos_mem_alloc failed ")); |
| 5878 | return eHAL_STATUS_FAILED_ALLOC; |
| 5879 | } |
| 5880 | vos_mem_set(pReq, sizeof(tSirRssiMonitorReq), 0); |
| 5881 | |
| 5882 | pReq->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 5883 | pReq->sessionId = pAdapter->sessionId; |
| 5884 | pReq->rssiMonitorCbContext = hdd_ctx; |
| 5885 | control = nla_get_u32(tb[PARAM_CONTROL]); |
| 5886 | vos_mem_copy( &pReq->currentBssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN); |
| 5887 | |
| 5888 | hddLog(LOG1, FL("Request Id: %u Session_id: %d Control: %d"), |
| 5889 | pReq->requestId, pReq->sessionId, control); |
| 5890 | |
| 5891 | if (control == QCA_WLAN_RSSI_MONITORING_START) { |
| 5892 | if (!tb[PARAM_MIN_RSSI]) { |
| 5893 | hddLog(LOGE, FL("attr min rssi failed")); |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 5894 | goto fail; |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5895 | } |
| 5896 | |
| 5897 | if (!tb[PARAM_MAX_RSSI]) { |
| 5898 | hddLog(LOGE, FL("attr max rssi failed")); |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 5899 | goto fail; |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5900 | } |
| 5901 | |
| 5902 | pReq->minRssi = nla_get_s8(tb[PARAM_MIN_RSSI]); |
| 5903 | pReq->maxRssi = nla_get_s8(tb[PARAM_MAX_RSSI]); |
| 5904 | pReq->rssiMonitorCallback = hdd_rssi_monitor_start_done; |
| 5905 | |
| 5906 | if (!(pReq->minRssi < pReq->maxRssi)) { |
| 5907 | hddLog(LOGW, FL("min_rssi: %d must be less than max_rssi: %d"), |
| 5908 | pReq->minRssi, pReq->maxRssi); |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 5909 | goto fail; |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5910 | } |
| 5911 | hddLog(LOG1, FL("Min_rssi: %d Max_rssi: %d"), |
| 5912 | pReq->minRssi, pReq->maxRssi); |
| 5913 | status = sme_StartRssiMonitoring(hdd_ctx->hHal, pReq); |
| 5914 | |
| 5915 | } |
| 5916 | else if (control == QCA_WLAN_RSSI_MONITORING_STOP) { |
| 5917 | pReq->rssiMonitorCallback = hdd_rssi_monitor_stop_done; |
| 5918 | status = sme_StopRssiMonitoring(hdd_ctx->hHal, pReq); |
| 5919 | } |
| 5920 | else { |
| 5921 | hddLog(LOGE, FL("Invalid control cmd: %d"), control); |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 5922 | goto fail; |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5923 | } |
| 5924 | |
| 5925 | if (!HAL_STATUS_SUCCESS(status)) { |
| 5926 | hddLog(LOGE, |
| 5927 | FL("sme_set_rssi_monitoring failed(err=%d)"), status); |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 5928 | goto fail; |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5929 | } |
| 5930 | |
| 5931 | return 0; |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 5932 | fail: |
| 5933 | vos_mem_free(pReq); |
| 5934 | return -EINVAL; |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 5935 | } |
| 5936 | |
| 5937 | /* |
| 5938 | * done with short names for the global vendor params |
| 5939 | * used by __wlan_hdd_cfg80211_monitor_rssi() |
| 5940 | */ |
| 5941 | #undef PARAM_MAX |
| 5942 | #undef PARAM_CONTROL |
| 5943 | #undef PARAM_REQUEST_ID |
| 5944 | #undef PARAM_MAX_RSSI |
| 5945 | #undef PARAM_MIN_RSSI |
| 5946 | |
| 5947 | /** |
| 5948 | * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring |
| 5949 | * @wiphy: wiphy structure pointer |
| 5950 | * @wdev: Wireless device structure pointer |
| 5951 | * @data: Pointer to the data received |
| 5952 | * @data_len: Length of @data |
| 5953 | * |
| 5954 | * Return: 0 on success; errno on failure |
| 5955 | */ |
| 5956 | static int |
| 5957 | wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 5958 | const void *data, int data_len) |
| 5959 | { |
| 5960 | int ret; |
| 5961 | |
| 5962 | vos_ssr_protect(__func__); |
| 5963 | ret = __wlan_hdd_cfg80211_monitor_rssi(wiphy, wdev, data, data_len); |
| 5964 | vos_ssr_unprotect(__func__); |
| 5965 | |
| 5966 | return ret; |
| 5967 | } |
| 5968 | |
| 5969 | /** |
| 5970 | * hdd_rssi_threshold_breached_cb() - rssi breached NL event |
| 5971 | * @hddctx: HDD context |
| 5972 | * @data: rssi breached event data |
| 5973 | * |
| 5974 | * This function reads the rssi breached event %data and fill in the skb with |
| 5975 | * NL attributes and send up the NL event. |
| 5976 | * This callback execute in atomic context and must not invoke any |
| 5977 | * blocking calls. |
| 5978 | * |
| 5979 | * Return: none |
| 5980 | */ |
| 5981 | void hdd_rssi_threshold_breached_cb(void *hddctx, |
| 5982 | struct rssi_breach_event *data) |
| 5983 | { |
| 5984 | hdd_context_t *pHddCtx = (hdd_context_t *)hddctx; |
| 5985 | int status; |
| 5986 | struct sk_buff *skb; |
| 5987 | |
| 5988 | ENTER(); |
| 5989 | status = wlan_hdd_validate_context(pHddCtx); |
| 5990 | |
| 5991 | if (0 != status) { |
| 5992 | return; |
| 5993 | } |
| 5994 | |
| 5995 | if (!data) { |
| 5996 | hddLog(LOGE, FL("data is null")); |
| 5997 | return; |
| 5998 | } |
| 5999 | |
| 6000 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 6001 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 6002 | NULL, |
| 6003 | #endif |
| 6004 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 6005 | QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX, |
| 6006 | GFP_KERNEL); |
| 6007 | |
| 6008 | if (!skb) { |
| 6009 | hddLog(LOGE, FL("cfg80211_vendor_event_alloc failed")); |
| 6010 | return; |
| 6011 | } |
| 6012 | |
| 6013 | hddLog(LOG1, "Req Id: %u Current rssi: %d", |
| 6014 | data->request_id, data->curr_rssi); |
| 6015 | hddLog(LOG1, "Current BSSID: "MAC_ADDRESS_STR, |
| 6016 | MAC_ADDR_ARRAY(data->curr_bssid.bytes)); |
| 6017 | |
| 6018 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_REQUEST_ID, |
| 6019 | data->request_id) || |
| 6020 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_BSSID, |
| 6021 | sizeof(data->curr_bssid), data->curr_bssid.bytes) || |
| 6022 | nla_put_s8(skb, QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_CUR_RSSI, |
| 6023 | data->curr_rssi)) { |
| 6024 | hddLog(LOGE, FL("nla put fail")); |
| 6025 | goto fail; |
| 6026 | } |
| 6027 | |
| 6028 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 6029 | return; |
| 6030 | |
| 6031 | fail: |
| 6032 | kfree_skb(skb); |
| 6033 | return; |
| 6034 | } |
| 6035 | |
| 6036 | |
| 6037 | |
Srinivas Dasari | 41d97c9 | 2015-07-29 13:09:39 +0530 | [diff] [blame] | 6038 | /** |
| 6039 | * __wlan_hdd_cfg80211_setband() - set band |
| 6040 | * @wiphy: Pointer to wireless phy |
| 6041 | * @wdev: Pointer to wireless device |
| 6042 | * @data: Pointer to data |
| 6043 | * @data_len: Data length |
| 6044 | * |
| 6045 | * Return: 0 on success, negative errno on failure |
| 6046 | */ |
| 6047 | static int |
| 6048 | __wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 6049 | struct wireless_dev *wdev, |
| 6050 | const void *data, |
| 6051 | int data_len) |
| 6052 | { |
| 6053 | struct net_device *dev = wdev->netdev; |
| 6054 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 6055 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1]; |
| 6056 | int ret; |
| 6057 | static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1] |
| 6058 | = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }}; |
| 6059 | |
| 6060 | ENTER(); |
| 6061 | |
| 6062 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6063 | if (0 != ret) { |
| 6064 | hddLog(LOGE, FL("HDD context is not valid")); |
| 6065 | return ret; |
| 6066 | } |
| 6067 | |
| 6068 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, |
| 6069 | policy)) { |
| 6070 | hddLog(LOGE, FL("Invalid ATTR")); |
| 6071 | return -EINVAL; |
| 6072 | } |
| 6073 | |
| 6074 | if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) { |
| 6075 | hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed")); |
| 6076 | return -EINVAL; |
| 6077 | } |
| 6078 | |
Hanumantha Reddy Pothula | 1347e43 | 2015-08-05 09:53:44 +0530 | [diff] [blame] | 6079 | hdd_ctx->isSetBandByNL = TRUE; |
| 6080 | ret = hdd_setBand(dev, |
Srinivas Dasari | 41d97c9 | 2015-07-29 13:09:39 +0530 | [diff] [blame] | 6081 | nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE])); |
Hanumantha Reddy Pothula | 1347e43 | 2015-08-05 09:53:44 +0530 | [diff] [blame] | 6082 | hdd_ctx->isSetBandByNL = FALSE; |
| 6083 | |
| 6084 | EXIT(); |
| 6085 | return ret; |
Srinivas Dasari | 41d97c9 | 2015-07-29 13:09:39 +0530 | [diff] [blame] | 6086 | } |
| 6087 | |
| 6088 | /** |
| 6089 | * wlan_hdd_cfg80211_setband() - Wrapper to offload packets |
| 6090 | * @wiphy: wiphy structure pointer |
| 6091 | * @wdev: Wireless device structure pointer |
| 6092 | * @data: Pointer to the data received |
| 6093 | * @data_len: Length of @data |
| 6094 | * |
| 6095 | * Return: 0 on success; errno on failure |
| 6096 | */ |
| 6097 | static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy, |
| 6098 | struct wireless_dev *wdev, |
| 6099 | const void *data, |
| 6100 | int data_len) |
| 6101 | { |
| 6102 | int ret = 0; |
| 6103 | |
| 6104 | vos_ssr_protect(__func__); |
| 6105 | ret = __wlan_hdd_cfg80211_setband(wiphy, |
| 6106 | wdev, data, data_len); |
| 6107 | vos_ssr_unprotect(__func__); |
| 6108 | |
| 6109 | return ret; |
| 6110 | } |
| 6111 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 6112 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 6113 | /** |
| 6114 | * hdd_map_req_id_to_pattern_id() - map request id to pattern id |
| 6115 | * @hdd_ctx: HDD context |
| 6116 | * @request_id: [input] request id |
| 6117 | * @pattern_id: [output] pattern id |
| 6118 | * |
| 6119 | * This function loops through request id to pattern id array |
| 6120 | * if the slot is available, store the request id and return pattern id |
| 6121 | * if entry exists, return the pattern id |
| 6122 | * |
| 6123 | * Return: 0 on success and errno on failure |
| 6124 | */ |
| 6125 | static int hdd_map_req_id_to_pattern_id(hdd_context_t *hdd_ctx, |
| 6126 | uint32_t request_id, |
| 6127 | uint8_t *pattern_id) |
| 6128 | { |
| 6129 | uint32_t i; |
| 6130 | |
| 6131 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 6132 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) |
| 6133 | { |
| 6134 | if (hdd_ctx->op_ctx.op_table[i].request_id == 0) |
| 6135 | { |
| 6136 | hdd_ctx->op_ctx.op_table[i].request_id = request_id; |
| 6137 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 6138 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 6139 | return 0; |
| 6140 | } else if (hdd_ctx->op_ctx.op_table[i].request_id == |
| 6141 | request_id) { |
| 6142 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 6143 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 6144 | return 0; |
| 6145 | } |
| 6146 | } |
| 6147 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 6148 | return -EINVAL; |
| 6149 | } |
| 6150 | |
| 6151 | /** |
| 6152 | * hdd_unmap_req_id_to_pattern_id() - unmap request id to pattern id |
| 6153 | * @hdd_ctx: HDD context |
| 6154 | * @request_id: [input] request id |
| 6155 | * @pattern_id: [output] pattern id |
| 6156 | * |
| 6157 | * This function loops through request id to pattern id array |
| 6158 | * reset request id to 0 (slot available again) and |
| 6159 | * return pattern id |
| 6160 | * |
| 6161 | * Return: 0 on success and errno on failure |
| 6162 | */ |
| 6163 | static int hdd_unmap_req_id_to_pattern_id(hdd_context_t *hdd_ctx, |
| 6164 | uint32_t request_id, |
| 6165 | uint8_t *pattern_id) |
| 6166 | { |
| 6167 | uint32_t i; |
| 6168 | |
| 6169 | mutex_lock(&hdd_ctx->op_ctx.op_lock); |
| 6170 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) |
| 6171 | { |
| 6172 | if (hdd_ctx->op_ctx.op_table[i].request_id == request_id) |
| 6173 | { |
| 6174 | hdd_ctx->op_ctx.op_table[i].request_id = 0; |
| 6175 | *pattern_id = hdd_ctx->op_ctx.op_table[i].pattern_id; |
| 6176 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 6177 | return 0; |
| 6178 | } |
| 6179 | } |
| 6180 | mutex_unlock(&hdd_ctx->op_ctx.op_lock); |
| 6181 | return -EINVAL; |
| 6182 | } |
| 6183 | |
| 6184 | |
| 6185 | /* |
| 6186 | * define short names for the global vendor params |
| 6187 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 6188 | */ |
| 6189 | #define PARAM_MAX QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_MAX |
| 6190 | #define PARAM_REQUEST_ID \ |
| 6191 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_REQUEST_ID |
| 6192 | #define PARAM_CONTROL \ |
| 6193 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SENDING_CONTROL |
| 6194 | #define PARAM_IP_PACKET \ |
| 6195 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_IP_PACKET_DATA |
| 6196 | #define PARAM_SRC_MAC_ADDR \ |
| 6197 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_SRC_MAC_ADDR |
| 6198 | #define PARAM_DST_MAC_ADDR \ |
| 6199 | QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_DST_MAC_ADDR |
| 6200 | #define PARAM_PERIOD QCA_WLAN_VENDOR_ATTR_OFFLOADED_PACKETS_PERIOD |
| 6201 | |
| 6202 | /** |
| 6203 | * wlan_hdd_add_tx_ptrn() - add tx pattern |
| 6204 | * @adapter: adapter pointer |
| 6205 | * @hdd_ctx: hdd context |
| 6206 | * @tb: nl attributes |
| 6207 | * |
| 6208 | * This function reads the NL attributes and forms a AddTxPtrn message |
| 6209 | * posts it to SME. |
| 6210 | * |
| 6211 | */ |
| 6212 | static int |
| 6213 | wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx, |
| 6214 | struct nlattr **tb) |
| 6215 | { |
| 6216 | struct sSirAddPeriodicTxPtrn *add_req; |
| 6217 | eHalStatus status; |
| 6218 | uint32_t request_id, ret, len; |
| 6219 | uint8_t pattern_id = 0; |
| 6220 | v_MACADDR_t dst_addr; |
| 6221 | uint16_t eth_type = htons(ETH_P_IP); |
| 6222 | |
| 6223 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) |
| 6224 | { |
| 6225 | hddLog(LOGE, FL("Not in Connected state!")); |
| 6226 | return -ENOTSUPP; |
| 6227 | } |
| 6228 | |
| 6229 | add_req = vos_mem_malloc(sizeof(*add_req)); |
| 6230 | if (!add_req) |
| 6231 | { |
| 6232 | hddLog(LOGE, FL("memory allocation failed")); |
| 6233 | return -ENOMEM; |
| 6234 | } |
| 6235 | |
| 6236 | /* Parse and fetch request Id */ |
| 6237 | if (!tb[PARAM_REQUEST_ID]) |
| 6238 | { |
| 6239 | hddLog(LOGE, FL("attr request id failed")); |
| 6240 | goto fail; |
| 6241 | } |
| 6242 | |
| 6243 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 6244 | hddLog(LOG1, FL("Request Id: %u"), request_id); |
| 6245 | if (request_id == 0) |
| 6246 | { |
| 6247 | hddLog(LOGE, FL("request_id cannot be zero")); |
Sreelakshmi Konamki | deb2253 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 6248 | goto fail; |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 6249 | } |
| 6250 | |
| 6251 | if (!tb[PARAM_PERIOD]) |
| 6252 | { |
| 6253 | hddLog(LOGE, FL("attr period failed")); |
| 6254 | goto fail; |
| 6255 | } |
| 6256 | add_req->usPtrnIntervalMs = nla_get_u32(tb[PARAM_PERIOD]); |
| 6257 | hddLog(LOG1, FL("Period: %u ms"), add_req->usPtrnIntervalMs); |
| 6258 | if (add_req->usPtrnIntervalMs == 0) |
| 6259 | { |
| 6260 | hddLog(LOGE, FL("Invalid interval zero, return failure")); |
| 6261 | goto fail; |
| 6262 | } |
| 6263 | |
| 6264 | if (!tb[PARAM_SRC_MAC_ADDR]) |
| 6265 | { |
| 6266 | hddLog(LOGE, FL("attr source mac address failed")); |
| 6267 | goto fail; |
| 6268 | } |
| 6269 | nla_memcpy(add_req->macAddress, tb[PARAM_SRC_MAC_ADDR], |
| 6270 | VOS_MAC_ADDR_SIZE); |
| 6271 | hddLog(LOG1, "input src mac address: "MAC_ADDRESS_STR, |
| 6272 | MAC_ADDR_ARRAY(add_req->macAddress)); |
| 6273 | |
| 6274 | if (memcmp(add_req->macAddress, adapter->macAddressCurrent.bytes, |
| 6275 | VOS_MAC_ADDR_SIZE)) |
| 6276 | { |
| 6277 | hddLog(LOGE, |
| 6278 | FL("input src mac address and connected ap bssid are different")); |
| 6279 | goto fail; |
| 6280 | } |
| 6281 | |
| 6282 | if (!tb[PARAM_DST_MAC_ADDR]) |
| 6283 | { |
| 6284 | hddLog(LOGE, FL("attr dst mac address failed")); |
| 6285 | goto fail; |
| 6286 | } |
| 6287 | nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], VOS_MAC_ADDR_SIZE); |
| 6288 | hddLog(LOG1, "input dst mac address: "MAC_ADDRESS_STR, |
| 6289 | MAC_ADDR_ARRAY(dst_addr.bytes)); |
| 6290 | |
| 6291 | if (!tb[PARAM_IP_PACKET]) |
| 6292 | { |
| 6293 | hddLog(LOGE, FL("attr ip packet failed")); |
| 6294 | goto fail; |
| 6295 | } |
| 6296 | add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]); |
| 6297 | hddLog(LOG1, FL("IP packet len: %u"), add_req->ucPtrnSize); |
| 6298 | |
| 6299 | if (add_req->ucPtrnSize < 0 || |
| 6300 | add_req->ucPtrnSize > (PERIODIC_TX_PTRN_MAX_SIZE - |
| 6301 | HDD_ETH_HEADER_LEN)) |
| 6302 | { |
| 6303 | hddLog(LOGE, FL("Invalid IP packet len: %d"), |
| 6304 | add_req->ucPtrnSize); |
| 6305 | goto fail; |
| 6306 | } |
| 6307 | |
| 6308 | len = 0; |
| 6309 | vos_mem_copy(&add_req->ucPattern[0], dst_addr.bytes, VOS_MAC_ADDR_SIZE); |
| 6310 | len += VOS_MAC_ADDR_SIZE; |
| 6311 | vos_mem_copy(&add_req->ucPattern[len], add_req->macAddress, |
| 6312 | VOS_MAC_ADDR_SIZE); |
| 6313 | len += VOS_MAC_ADDR_SIZE; |
| 6314 | vos_mem_copy(&add_req->ucPattern[len], ð_type, 2); |
| 6315 | len += 2; |
| 6316 | |
| 6317 | /* |
| 6318 | * This is the IP packet, add 14 bytes Ethernet (802.3) header |
| 6319 | * ------------------------------------------------------------ |
| 6320 | * | 14 bytes Ethernet (802.3) header | IP header and payload | |
| 6321 | * ------------------------------------------------------------ |
| 6322 | */ |
| 6323 | vos_mem_copy(&add_req->ucPattern[len], |
| 6324 | nla_data(tb[PARAM_IP_PACKET]), |
| 6325 | add_req->ucPtrnSize); |
| 6326 | add_req->ucPtrnSize += len; |
| 6327 | |
| 6328 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6329 | add_req->ucPattern, add_req->ucPtrnSize); |
| 6330 | |
| 6331 | ret = hdd_map_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 6332 | if (ret) |
| 6333 | { |
| 6334 | hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret); |
| 6335 | goto fail; |
| 6336 | } |
| 6337 | add_req->ucPtrnId = pattern_id; |
| 6338 | hddLog(LOG1, FL("pattern id: %d"), add_req->ucPtrnId); |
| 6339 | |
| 6340 | status = sme_AddPeriodicTxPtrn(hdd_ctx->hHal, add_req); |
| 6341 | if (!HAL_STATUS_SUCCESS(status)) |
| 6342 | { |
| 6343 | hddLog(LOGE, |
| 6344 | FL("sme_AddPeriodicTxPtrn failed (err=%d)"), status); |
| 6345 | goto fail; |
| 6346 | } |
| 6347 | |
| 6348 | EXIT(); |
| 6349 | vos_mem_free(add_req); |
| 6350 | return 0; |
| 6351 | |
| 6352 | fail: |
| 6353 | vos_mem_free(add_req); |
| 6354 | return -EINVAL; |
| 6355 | } |
| 6356 | |
| 6357 | /** |
| 6358 | * wlan_hdd_del_tx_ptrn() - delete tx pattern |
| 6359 | * @adapter: adapter pointer |
| 6360 | * @hdd_ctx: hdd context |
| 6361 | * @tb: nl attributes |
| 6362 | * |
| 6363 | * This function reads the NL attributes and forms a DelTxPtrn message |
| 6364 | * posts it to SME. |
| 6365 | * |
| 6366 | */ |
| 6367 | static int |
| 6368 | wlan_hdd_del_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx, |
| 6369 | struct nlattr **tb) |
| 6370 | { |
| 6371 | struct sSirDelPeriodicTxPtrn *del_req; |
| 6372 | eHalStatus status; |
| 6373 | uint32_t request_id, ret; |
| 6374 | uint8_t pattern_id = 0; |
| 6375 | |
| 6376 | /* Parse and fetch request Id */ |
| 6377 | if (!tb[PARAM_REQUEST_ID]) |
| 6378 | { |
| 6379 | hddLog(LOGE, FL("attr request id failed")); |
| 6380 | return -EINVAL; |
| 6381 | } |
| 6382 | request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); |
| 6383 | if (request_id == 0) |
| 6384 | { |
| 6385 | hddLog(LOGE, FL("request_id cannot be zero")); |
| 6386 | return -EINVAL; |
| 6387 | } |
| 6388 | |
| 6389 | ret = hdd_unmap_req_id_to_pattern_id(hdd_ctx, request_id, &pattern_id); |
| 6390 | if (ret) |
| 6391 | { |
| 6392 | hddLog(LOGW, FL("req id to pattern id failed (ret=%d)"), ret); |
| 6393 | return -EINVAL; |
| 6394 | } |
| 6395 | |
| 6396 | del_req = vos_mem_malloc(sizeof(*del_req)); |
| 6397 | if (!del_req) |
| 6398 | { |
| 6399 | hddLog(LOGE, FL("memory allocation failed")); |
| 6400 | return -ENOMEM; |
| 6401 | } |
| 6402 | |
| 6403 | vos_mem_set(del_req, sizeof(*del_req), 0); |
| 6404 | vos_mem_copy(del_req->macAddress, adapter->macAddressCurrent.bytes, |
| 6405 | VOS_MAC_ADDR_SIZE); |
| 6406 | hddLog(LOG1, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(del_req->macAddress)); |
| 6407 | del_req->ucPatternIdBitmap |= (0x1 << pattern_id); |
| 6408 | hddLog(LOG1, FL("Request Id: %u Pattern id: %d, bitmap %04x"), |
| 6409 | request_id, pattern_id, del_req->ucPatternIdBitmap); |
| 6410 | |
| 6411 | status = sme_DelPeriodicTxPtrn(hdd_ctx->hHal, del_req); |
| 6412 | if (!HAL_STATUS_SUCCESS(status)) |
| 6413 | { |
| 6414 | hddLog(LOGE, |
| 6415 | FL("sme_DelPeriodicTxPtrn failed (err=%d)"), status); |
| 6416 | goto fail; |
| 6417 | } |
| 6418 | |
| 6419 | EXIT(); |
| 6420 | vos_mem_free(del_req); |
| 6421 | return 0; |
| 6422 | |
| 6423 | fail: |
| 6424 | vos_mem_free(del_req); |
| 6425 | return -EINVAL; |
| 6426 | } |
| 6427 | |
| 6428 | |
| 6429 | /** |
| 6430 | * __wlan_hdd_cfg80211_offloaded_packets() - send offloaded packets |
| 6431 | * @wiphy: Pointer to wireless phy |
| 6432 | * @wdev: Pointer to wireless device |
| 6433 | * @data: Pointer to data |
| 6434 | * @data_len: Data length |
| 6435 | * |
| 6436 | * Return: 0 on success, negative errno on failure |
| 6437 | */ |
| 6438 | static int |
| 6439 | __wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 6440 | struct wireless_dev *wdev, |
| 6441 | const void *data, |
| 6442 | int data_len) |
| 6443 | { |
| 6444 | struct net_device *dev = wdev->netdev; |
| 6445 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6446 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 6447 | struct nlattr *tb[PARAM_MAX + 1]; |
| 6448 | uint8_t control; |
| 6449 | int ret; |
| 6450 | static const struct nla_policy policy[PARAM_MAX + 1] = |
| 6451 | { |
| 6452 | [PARAM_REQUEST_ID] = { .type = NLA_U32 }, |
| 6453 | [PARAM_CONTROL] = { .type = NLA_U32 }, |
| 6454 | [PARAM_SRC_MAC_ADDR] = { .type = NLA_BINARY, |
| 6455 | .len = VOS_MAC_ADDR_SIZE }, |
| 6456 | [PARAM_DST_MAC_ADDR] = { .type = NLA_BINARY, |
| 6457 | .len = VOS_MAC_ADDR_SIZE }, |
| 6458 | [PARAM_PERIOD] = { .type = NLA_U32 }, |
| 6459 | }; |
| 6460 | |
| 6461 | ENTER(); |
| 6462 | |
| 6463 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6464 | if (0 != ret) |
| 6465 | { |
| 6466 | hddLog(LOGE, FL("HDD context is not valid")); |
| 6467 | return ret; |
| 6468 | } |
| 6469 | |
| 6470 | if (!sme_IsFeatureSupportedByFW(WLAN_PERIODIC_TX_PTRN)) |
| 6471 | { |
| 6472 | hddLog(LOGE, |
| 6473 | FL("Periodic Tx Pattern Offload feature is not supported in FW!")); |
| 6474 | return -ENOTSUPP; |
| 6475 | } |
| 6476 | |
| 6477 | if (nla_parse(tb, PARAM_MAX, data, data_len, policy)) |
| 6478 | { |
| 6479 | hddLog(LOGE, FL("Invalid ATTR")); |
| 6480 | return -EINVAL; |
| 6481 | } |
| 6482 | |
| 6483 | if (!tb[PARAM_CONTROL]) |
| 6484 | { |
| 6485 | hddLog(LOGE, FL("attr control failed")); |
| 6486 | return -EINVAL; |
| 6487 | } |
| 6488 | control = nla_get_u32(tb[PARAM_CONTROL]); |
| 6489 | hddLog(LOG1, FL("Control: %d"), control); |
| 6490 | |
| 6491 | if (control == WLAN_START_OFFLOADED_PACKETS) |
| 6492 | return wlan_hdd_add_tx_ptrn(adapter, hdd_ctx, tb); |
| 6493 | else if (control == WLAN_STOP_OFFLOADED_PACKETS) |
| 6494 | return wlan_hdd_del_tx_ptrn(adapter, hdd_ctx, tb); |
| 6495 | else |
| 6496 | { |
| 6497 | hddLog(LOGE, FL("Invalid control: %d"), control); |
| 6498 | return -EINVAL; |
| 6499 | } |
| 6500 | } |
| 6501 | |
| 6502 | /* |
| 6503 | * done with short names for the global vendor params |
| 6504 | * used by __wlan_hdd_cfg80211_offloaded_packets() |
| 6505 | */ |
| 6506 | #undef PARAM_MAX |
| 6507 | #undef PARAM_REQUEST_ID |
| 6508 | #undef PARAM_CONTROL |
| 6509 | #undef PARAM_IP_PACKET |
| 6510 | #undef PARAM_SRC_MAC_ADDR |
| 6511 | #undef PARAM_DST_MAC_ADDR |
| 6512 | #undef PARAM_PERIOD |
| 6513 | |
| 6514 | /** |
| 6515 | * wlan_hdd_cfg80211_offloaded_packets() - Wrapper to offload packets |
| 6516 | * @wiphy: wiphy structure pointer |
| 6517 | * @wdev: Wireless device structure pointer |
| 6518 | * @data: Pointer to the data received |
| 6519 | * @data_len: Length of @data |
| 6520 | * |
| 6521 | * Return: 0 on success; errno on failure |
| 6522 | */ |
| 6523 | static int wlan_hdd_cfg80211_offloaded_packets(struct wiphy *wiphy, |
| 6524 | struct wireless_dev *wdev, |
| 6525 | const void *data, |
| 6526 | int data_len) |
| 6527 | { |
| 6528 | int ret = 0; |
| 6529 | |
| 6530 | vos_ssr_protect(__func__); |
| 6531 | ret = __wlan_hdd_cfg80211_offloaded_packets(wiphy, |
| 6532 | wdev, data, data_len); |
| 6533 | vos_ssr_unprotect(__func__); |
| 6534 | |
| 6535 | return ret; |
| 6536 | } |
| 6537 | #endif |
| 6538 | |
Deepthi Gowri | ae6a166 | 2015-10-12 12:59:37 +0530 | [diff] [blame] | 6539 | static const struct |
| 6540 | nla_policy |
| 6541 | qca_wlan_vendor_attr_policy[QCA_WLAN_VENDOR_ATTR_MAX+1] = { |
| 6542 | [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC }, |
| 6543 | }; |
| 6544 | |
| 6545 | /** |
| 6546 | * wlan_hdd_cfg80211_get_link_properties() - This function is used to |
| 6547 | * get link properties like nss, rate flags and operating frequency for |
| 6548 | * the connection with the given peer. |
| 6549 | * @wiphy: WIPHY structure pointer |
| 6550 | * @wdev: Wireless device structure pointer |
| 6551 | * @data: Pointer to the data received |
| 6552 | * @data_len: Length of the data received |
| 6553 | * |
| 6554 | * This function return the above link properties on success. |
| 6555 | * |
| 6556 | * Return: 0 on success and errno on failure |
| 6557 | */ |
| 6558 | static int wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy, |
| 6559 | struct wireless_dev *wdev, |
| 6560 | const void *data, |
| 6561 | int data_len) |
| 6562 | { |
| 6563 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 6564 | struct net_device *dev = wdev->netdev; |
| 6565 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6566 | hdd_station_ctx_t *hdd_sta_ctx; |
| 6567 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX+1]; |
| 6568 | uint8_t peer_mac[VOS_MAC_ADDR_SIZE]; |
| 6569 | uint32_t sta_id; |
| 6570 | struct sk_buff *reply_skb; |
| 6571 | uint32_t rate_flags = 0; |
| 6572 | uint8_t nss; |
| 6573 | uint8_t final_rate_flags = 0; |
| 6574 | uint32_t freq; |
| 6575 | v_CONTEXT_t pVosContext = NULL; |
| 6576 | ptSapContext pSapCtx = NULL; |
| 6577 | |
| 6578 | if (0 != wlan_hdd_validate_context(hdd_ctx)) { |
| 6579 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid")); |
| 6580 | return -EINVAL; |
| 6581 | } |
| 6582 | |
| 6583 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len, |
| 6584 | qca_wlan_vendor_attr_policy)) { |
| 6585 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid attribute")); |
| 6586 | return -EINVAL; |
| 6587 | } |
| 6588 | |
| 6589 | if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) { |
| 6590 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6591 | FL("Attribute peerMac not provided for mode=%d"), |
| 6592 | adapter->device_mode); |
| 6593 | return -EINVAL; |
| 6594 | } |
| 6595 | |
| 6596 | memcpy(peer_mac, nla_data(tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]), |
| 6597 | sizeof(peer_mac)); |
| 6598 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6599 | FL("peerMac="MAC_ADDRESS_STR" for device_mode:%d"), |
| 6600 | MAC_ADDR_ARRAY(peer_mac), adapter->device_mode); |
| 6601 | |
| 6602 | if (adapter->device_mode == WLAN_HDD_INFRA_STATION || |
| 6603 | adapter->device_mode == WLAN_HDD_P2P_CLIENT) { |
| 6604 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6605 | if ((hdd_sta_ctx->conn_info.connState != |
| 6606 | eConnectionState_Associated) || |
| 6607 | !vos_mem_compare(hdd_sta_ctx->conn_info.bssId, peer_mac, |
| 6608 | VOS_MAC_ADDRESS_LEN)) { |
| 6609 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6610 | FL("Not Associated to mac "MAC_ADDRESS_STR), |
| 6611 | MAC_ADDR_ARRAY(peer_mac)); |
| 6612 | return -EINVAL; |
| 6613 | } |
| 6614 | |
| 6615 | nss = 1; //pronto supports only one spatial stream |
| 6616 | freq = vos_chan_to_freq( |
| 6617 | hdd_sta_ctx->conn_info.operationChannel); |
| 6618 | rate_flags = hdd_sta_ctx->conn_info.rate_flags; |
| 6619 | |
| 6620 | } else if (adapter->device_mode == WLAN_HDD_P2P_GO || |
| 6621 | adapter->device_mode == WLAN_HDD_SOFTAP) { |
| 6622 | |
| 6623 | pVosContext = ( WLAN_HDD_GET_CTX(adapter))->pvosContext; |
| 6624 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 6625 | if(pSapCtx == NULL){ |
| 6626 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6627 | FL("psapCtx is NULL")); |
| 6628 | return -ENOENT; |
| 6629 | } |
| 6630 | |
| 6631 | |
| 6632 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 6633 | if (pSapCtx->aStaInfo[sta_id].isUsed && |
| 6634 | !vos_is_macaddr_broadcast( |
| 6635 | &pSapCtx->aStaInfo[sta_id].macAddrSTA) && |
| 6636 | vos_mem_compare( |
| 6637 | &pSapCtx->aStaInfo[sta_id].macAddrSTA, |
| 6638 | peer_mac, VOS_MAC_ADDRESS_LEN)) |
| 6639 | break; |
| 6640 | } |
| 6641 | |
| 6642 | if (WLAN_MAX_STA_COUNT == sta_id) { |
| 6643 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6644 | FL("No active peer with mac="MAC_ADDRESS_STR), |
| 6645 | MAC_ADDR_ARRAY(peer_mac)); |
| 6646 | return -EINVAL; |
| 6647 | } |
| 6648 | |
| 6649 | nss = 1; //pronto supports only one spatial stream |
| 6650 | freq = vos_chan_to_freq( |
| 6651 | (WLAN_HDD_GET_AP_CTX_PTR(adapter))->operatingChannel); |
| 6652 | rate_flags = pSapCtx->aStaInfo[sta_id].rate_flags; |
| 6653 | } else { |
| 6654 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6655 | FL("Not Associated! with mac"MAC_ADDRESS_STR), |
| 6656 | MAC_ADDR_ARRAY(peer_mac)); |
| 6657 | return -EINVAL; |
| 6658 | } |
| 6659 | |
| 6660 | if (!(rate_flags & eHAL_TX_RATE_LEGACY)) { |
| 6661 | if (rate_flags & eHAL_TX_RATE_VHT80) { |
| 6662 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6663 | final_rate_flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6664 | } else if (rate_flags & eHAL_TX_RATE_VHT40) { |
| 6665 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6666 | final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6667 | } else if (rate_flags & eHAL_TX_RATE_VHT20) { |
| 6668 | final_rate_flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6669 | } else if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) { |
| 6670 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
| 6671 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6672 | final_rate_flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6673 | } |
| 6674 | |
| 6675 | if (rate_flags & eHAL_TX_RATE_SGI) { |
| 6676 | if (!(final_rate_flags & RATE_INFO_FLAGS_VHT_MCS)) |
| 6677 | final_rate_flags |= RATE_INFO_FLAGS_MCS; |
| 6678 | final_rate_flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6679 | } |
| 6680 | } |
| 6681 | |
| 6682 | reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 6683 | sizeof(u8) + sizeof(u8) + sizeof(u32) + NLMSG_HDRLEN); |
| 6684 | |
| 6685 | if (NULL == reply_skb) { |
| 6686 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6687 | FL("getLinkProperties: skb alloc failed")); |
| 6688 | return -EINVAL; |
| 6689 | } |
| 6690 | |
| 6691 | if (nla_put_u8(reply_skb, |
| 6692 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_NSS, |
| 6693 | nss) || |
| 6694 | nla_put_u8(reply_skb, |
| 6695 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_RATE_FLAGS, |
| 6696 | final_rate_flags) || |
| 6697 | nla_put_u32(reply_skb, |
| 6698 | QCA_WLAN_VENDOR_ATTR_LINK_PROPERTIES_FREQ, |
| 6699 | freq)) { |
| 6700 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_put failed")); |
| 6701 | kfree_skb(reply_skb); |
| 6702 | return -EINVAL; |
| 6703 | } |
| 6704 | |
| 6705 | return cfg80211_vendor_cmd_reply(reply_skb); |
| 6706 | } |
| 6707 | |
Ravi Kumar bokka | 7d03276 | 2016-12-12 23:33:01 +0530 | [diff] [blame] | 6708 | #define BEACON_MISS_THRESH_2_4 \ |
| 6709 | QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24 |
| 6710 | #define BEACON_MISS_THRESH_5_0 \ |
| 6711 | QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5 |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6712 | #define PARAM_WIFICONFIG_MAX QCA_WLAN_VENDOR_ATTR_CONFIG_MAX |
| 6713 | #define PARAM_MODULATED_DTIM QCA_WLAN_VENDOR_ATTR_CONFIG_MODULATED_DTIM |
| 6714 | #define PARAM_STATS_AVG_FACTOR QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR |
| 6715 | #define PARAM_GUARD_TIME QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME |
Mahesh A Saptasagar | 41f9ddd | 2016-02-09 14:01:03 +0530 | [diff] [blame] | 6716 | #define PARAM_BCNMISS_PENALTY_PARAM_COUNT \ |
| 6717 | QCA_WLAN_VENDOR_ATTR_CONFIG_PENALIZE_AFTER_NCONS_BEACON_MISS |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6718 | |
| 6719 | /** |
| 6720 | * __wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 6721 | * vendor command |
| 6722 | * |
| 6723 | * @wiphy: wiphy device pointer |
| 6724 | * @wdev: wireless device pointer |
| 6725 | * @data: Vendor command data buffer |
| 6726 | * @data_len: Buffer length |
| 6727 | * |
| 6728 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 6729 | * |
| 6730 | * Return: EOK or other error codes. |
| 6731 | */ |
| 6732 | |
| 6733 | static int __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 6734 | struct wireless_dev *wdev, |
| 6735 | const void *data, |
| 6736 | int data_len) |
| 6737 | { |
| 6738 | struct net_device *dev = wdev->netdev; |
| 6739 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6740 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6741 | hdd_station_ctx_t *pHddStaCtx; |
| 6742 | struct nlattr *tb[PARAM_WIFICONFIG_MAX + 1]; |
| 6743 | tpSetWifiConfigParams pReq; |
Mahesh A Saptasagar | 41f9ddd | 2016-02-09 14:01:03 +0530 | [diff] [blame] | 6744 | tModifyRoamParamsReqParams modifyRoamParamsReq; |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6745 | eHalStatus status; |
| 6746 | int ret_val; |
Ravi Kumar bokka | 7d03276 | 2016-12-12 23:33:01 +0530 | [diff] [blame] | 6747 | uint8_t hb_thresh_val; |
| 6748 | |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6749 | static const struct nla_policy policy[PARAM_WIFICONFIG_MAX + 1] = { |
| 6750 | [PARAM_STATS_AVG_FACTOR] = { .type = NLA_U16 }, |
| 6751 | [PARAM_MODULATED_DTIM] = { .type = NLA_U32 }, |
Mahesh A Saptasagar | 41f9ddd | 2016-02-09 14:01:03 +0530 | [diff] [blame] | 6752 | [PARAM_GUARD_TIME] = { .type = NLA_U32}, |
| 6753 | [PARAM_BCNMISS_PENALTY_PARAM_COUNT] = |
| 6754 | { .type = NLA_U32}, |
Ravi Kumar bokka | 7d03276 | 2016-12-12 23:33:01 +0530 | [diff] [blame] | 6755 | [BEACON_MISS_THRESH_2_4] = { .type = NLA_U8 }, |
| 6756 | [BEACON_MISS_THRESH_5_0] = { .type = NLA_U8 }, |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6757 | }; |
| 6758 | |
| 6759 | ENTER(); |
| 6760 | |
| 6761 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 6762 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 6763 | return -EINVAL; |
| 6764 | } |
| 6765 | |
| 6766 | ret_val = wlan_hdd_validate_context(pHddCtx); |
| 6767 | if (ret_val) { |
| 6768 | return ret_val; |
| 6769 | } |
| 6770 | |
| 6771 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6772 | |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6773 | if (nla_parse(tb, PARAM_WIFICONFIG_MAX, data, data_len, policy)) { |
| 6774 | hddLog(LOGE, FL("Invalid ATTR")); |
| 6775 | return -EINVAL; |
| 6776 | } |
| 6777 | |
| 6778 | /* check the Wifi Capability */ |
| 6779 | if ( (TRUE != pHddCtx->cfg_ini->fEnableWifiConfig) && |
| 6780 | (TRUE != sme_IsFeatureSupportedByFW(WIFI_CONFIG))) |
| 6781 | { |
| 6782 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6783 | FL("WIFICONFIG not supported by Firmware")); |
| 6784 | return -EINVAL; |
| 6785 | } |
| 6786 | |
Mahesh A Saptasagar | 41f9ddd | 2016-02-09 14:01:03 +0530 | [diff] [blame] | 6787 | if (tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]) { |
| 6788 | modifyRoamParamsReq.param = WIFI_CONFIG_SET_BCNMISS_PENALTY_COUNT; |
| 6789 | modifyRoamParamsReq.value = |
| 6790 | nla_get_u32(tb[PARAM_BCNMISS_PENALTY_PARAM_COUNT]); |
| 6791 | |
| 6792 | if (eHAL_STATUS_SUCCESS != |
| 6793 | sme_setBcnMissPenaltyCount(pHddCtx->hHal,&modifyRoamParamsReq)) |
| 6794 | { |
| 6795 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed", __func__); |
| 6796 | ret_val = -EINVAL; |
| 6797 | } |
| 6798 | return ret_val; |
| 6799 | } |
| 6800 | |
| 6801 | /* Moved this down in order to provide provision to set beacon |
| 6802 | * miss penalty count irrespective of connection state. |
| 6803 | */ |
| 6804 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 6805 | hddLog(LOGE, FL("Not in Connected state!")); |
| 6806 | return -ENOTSUPP; |
| 6807 | } |
| 6808 | |
| 6809 | pReq = vos_mem_malloc(sizeof(tSetWifiConfigParams)); |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6810 | |
| 6811 | if (!pReq) { |
| 6812 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 6813 | "%s: Not able to allocate memory for tSetWifiConfigParams", |
| 6814 | __func__); |
| 6815 | return eHAL_STATUS_E_MALLOC_FAILED; |
| 6816 | } |
| 6817 | |
| 6818 | vos_mem_set(pReq, sizeof(tSetWifiConfigParams), 0); |
| 6819 | |
| 6820 | pReq->sessionId = pAdapter->sessionId; |
| 6821 | vos_mem_copy( &pReq->bssId, pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN); |
| 6822 | |
| 6823 | if (tb[PARAM_MODULATED_DTIM]) { |
| 6824 | pReq->paramValue = nla_get_u32( |
| 6825 | tb[PARAM_MODULATED_DTIM]); |
| 6826 | hddLog(LOG1, FL("Modulated DTIM: pReq->paramValue:%d "), |
| 6827 | pReq->paramValue); |
Arun Khandavalli | 876886f | 2015-11-23 11:42:27 +0530 | [diff] [blame] | 6828 | pHddCtx->cfg_ini->enableDynamicDTIM = pReq->paramValue; |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6829 | hdd_set_pwrparams(pHddCtx); |
| 6830 | if (BMPS == pmcGetPmcState(pHddCtx->hHal)) { |
| 6831 | hddLog( LOG1, FL("WifiConfig: Requesting FullPower!")); |
| 6832 | |
| 6833 | sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6834 | iw_full_power_cbfn, pAdapter, |
| 6835 | eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6836 | } |
| 6837 | else |
| 6838 | { |
| 6839 | hddLog( LOG1, FL("WifiConfig Not in BMPS state")); |
| 6840 | } |
| 6841 | } |
| 6842 | |
| 6843 | if (tb[PARAM_STATS_AVG_FACTOR]) { |
| 6844 | pReq->paramType = WIFI_CONFIG_SET_AVG_STATS_FACTOR; |
| 6845 | pReq->paramValue = nla_get_u16( |
| 6846 | tb[PARAM_STATS_AVG_FACTOR]); |
| 6847 | hddLog(LOG1, FL("AVG_STATS_FACTOR pReq->paramType:%d,pReq->paramValue:%d "), |
| 6848 | pReq->paramType, pReq->paramValue); |
| 6849 | status = sme_set_wificonfig_params(pHddCtx->hHal, pReq); |
| 6850 | |
| 6851 | if (eHAL_STATUS_SUCCESS != status) |
| 6852 | { |
| 6853 | vos_mem_free(pReq); |
| 6854 | pReq = NULL; |
| 6855 | ret_val = -EPERM; |
| 6856 | return ret_val; |
| 6857 | } |
| 6858 | } |
| 6859 | |
| 6860 | |
| 6861 | if (tb[PARAM_GUARD_TIME]) { |
| 6862 | pReq->paramType = WIFI_CONFIG_SET_GUARD_TIME; |
| 6863 | pReq->paramValue = nla_get_u32( |
| 6864 | tb[PARAM_GUARD_TIME]); |
| 6865 | hddLog(LOG1, FL("GUARD_TIME pReq->paramType:%d,pReq->paramValue:%d "), |
| 6866 | pReq->paramType, pReq->paramValue); |
| 6867 | status = sme_set_wificonfig_params(pHddCtx->hHal, pReq); |
| 6868 | |
| 6869 | if (eHAL_STATUS_SUCCESS != status) |
| 6870 | { |
| 6871 | vos_mem_free(pReq); |
| 6872 | pReq = NULL; |
| 6873 | ret_val = -EPERM; |
| 6874 | return ret_val; |
| 6875 | } |
| 6876 | |
| 6877 | } |
| 6878 | |
Ravi Kumar bokka | 7d03276 | 2016-12-12 23:33:01 +0530 | [diff] [blame] | 6879 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]) { |
| 6880 | hb_thresh_val = nla_get_u8( |
| 6881 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_24]); |
| 6882 | |
| 6883 | hddLog(LOG1, "WLAN set heartbeat threshold for 2.4Ghz %d", |
| 6884 | hb_thresh_val); |
| 6885 | ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6886 | WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val, |
| 6887 | NULL, eANI_BOOLEAN_FALSE); |
| 6888 | |
| 6889 | status = sme_update_hb_threshold( |
| 6890 | (WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6891 | WNI_CFG_HEART_BEAT_THRESHOLD, |
| 6892 | hb_thresh_val, eCSR_BAND_24); |
| 6893 | if (eHAL_STATUS_SUCCESS != status) { |
| 6894 | hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status); |
| 6895 | vos_mem_free(pReq); |
| 6896 | pReq = NULL; |
| 6897 | return -EPERM; |
| 6898 | } |
| 6899 | } |
| 6900 | |
| 6901 | if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]) { |
| 6902 | hb_thresh_val = nla_get_u8( |
| 6903 | tb[QCA_WLAN_VENDOR_ATTR_CONFIG_BEACON_MISS_THRESHOLD_5]); |
| 6904 | |
| 6905 | hddLog(LOG1, "WLAN set heartbeat threshold for 5Ghz %d", |
| 6906 | hb_thresh_val); |
| 6907 | ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6908 | WNI_CFG_HEART_BEAT_THRESHOLD, hb_thresh_val, |
| 6909 | NULL, eANI_BOOLEAN_FALSE); |
| 6910 | |
| 6911 | status = sme_update_hb_threshold( |
| 6912 | (WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6913 | WNI_CFG_HEART_BEAT_THRESHOLD, |
| 6914 | hb_thresh_val, eCSR_BAND_5G); |
| 6915 | if (eHAL_STATUS_SUCCESS != status) { |
| 6916 | hddLog(LOGE, "WLAN set heartbeat threshold FAILED %d", status); |
| 6917 | vos_mem_free(pReq); |
| 6918 | pReq = NULL; |
| 6919 | return -EPERM; |
| 6920 | } |
| 6921 | } |
| 6922 | |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 6923 | EXIT(); |
| 6924 | return ret_val; |
| 6925 | } |
| 6926 | |
| 6927 | /** |
| 6928 | * wlan_hdd_cfg80211_wifi_configuration_set() - Wifi configuration |
| 6929 | * vendor command |
| 6930 | * |
| 6931 | * @wiphy: wiphy device pointer |
| 6932 | * @wdev: wireless device pointer |
| 6933 | * @data: Vendor command data buffer |
| 6934 | * @data_len: Buffer length |
| 6935 | * |
| 6936 | * Handles QCA_WLAN_VENDOR_ATTR_CONFIG_MAX. |
| 6937 | * |
| 6938 | * Return: EOK or other error codes. |
| 6939 | */ |
| 6940 | static int wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, |
| 6941 | struct wireless_dev *wdev, |
| 6942 | const void *data, |
| 6943 | int data_len) |
| 6944 | { |
| 6945 | int ret; |
| 6946 | |
| 6947 | vos_ssr_protect(__func__); |
| 6948 | ret = __wlan_hdd_cfg80211_wifi_configuration_set(wiphy, wdev, |
| 6949 | data, data_len); |
| 6950 | vos_ssr_unprotect(__func__); |
| 6951 | |
| 6952 | return ret; |
| 6953 | } |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 6954 | |
| 6955 | /* |
| 6956 | * define short names for the global vendor params |
| 6957 | * used by wlan_hdd_cfg80211_setarp_stats_cmd() |
| 6958 | */ |
| 6959 | #define STATS_SET_INVALID \ |
| 6960 | QCA_ATTR_NUD_STATS_SET_INVALID |
| 6961 | #define STATS_SET_START \ |
| 6962 | QCA_ATTR_NUD_STATS_SET_START |
| 6963 | #define STATS_GW_IPV4 \ |
| 6964 | QCA_ATTR_NUD_STATS_GW_IPV4 |
| 6965 | #define STATS_SET_MAX \ |
| 6966 | QCA_ATTR_NUD_STATS_SET_MAX |
| 6967 | |
| 6968 | const struct nla_policy |
| 6969 | qca_wlan_vendor_set_nud_stats[STATS_SET_MAX +1] = |
| 6970 | { |
| 6971 | [STATS_SET_START] = {.type = NLA_FLAG }, |
| 6972 | [STATS_GW_IPV4] = {.type = NLA_U32 }, |
| 6973 | }; |
| 6974 | |
| 6975 | /** |
| 6976 | * hdd_set_nud_stats_cb() - hdd callback api to get status |
| 6977 | * @data: pointer to adapter |
| 6978 | * @rsp: status |
| 6979 | * |
| 6980 | * Return: None |
| 6981 | */ |
| 6982 | static void hdd_set_nud_stats_cb(void *data, VOS_STATUS rsp) |
| 6983 | { |
| 6984 | |
| 6985 | hdd_adapter_t *adapter = (hdd_adapter_t *)data; |
| 6986 | |
| 6987 | if (NULL == adapter) |
| 6988 | return; |
| 6989 | |
| 6990 | if (VOS_STATUS_SUCCESS == rsp) { |
| 6991 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6992 | "%s success received STATS_SET_START", __func__); |
| 6993 | } else { |
| 6994 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6995 | "%s STATS_SET_START Failed!!", __func__); |
| 6996 | } |
| 6997 | return; |
| 6998 | } |
| 6999 | |
| 7000 | /** |
| 7001 | * __wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware |
| 7002 | * @wiphy: pointer to wireless wiphy structure. |
| 7003 | * @wdev: pointer to wireless_dev structure. |
| 7004 | * @data: pointer to apfind configuration data. |
| 7005 | * @data_len: the length in byte of apfind data. |
| 7006 | * |
| 7007 | * This is called when wlan driver needs to send arp stats to |
| 7008 | * firmware. |
| 7009 | * |
| 7010 | * Return: An error code or 0 on success. |
| 7011 | */ |
| 7012 | static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy, |
| 7013 | struct wireless_dev *wdev, |
| 7014 | const void *data, int data_len) |
| 7015 | { |
| 7016 | struct nlattr *tb[STATS_SET_MAX + 1]; |
| 7017 | struct net_device *dev = wdev->netdev; |
| 7018 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7019 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
Sravan Kumar Kairam | d9e8cbb | 2017-01-17 12:17:28 +0530 | [diff] [blame] | 7020 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(adapter))->pvosContext; |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 7021 | setArpStatsParams arp_stats_params; |
| 7022 | int err = 0; |
| 7023 | |
| 7024 | ENTER(); |
| 7025 | |
| 7026 | err = wlan_hdd_validate_context(hdd_ctx); |
| 7027 | if (0 != err) |
| 7028 | return err; |
| 7029 | |
| 7030 | if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) { |
| 7031 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7032 | "%s NUD_DEBUG feature not supported by firmware!!", __func__); |
| 7033 | return -EINVAL; |
| 7034 | } |
| 7035 | |
| 7036 | err = nla_parse(tb, STATS_SET_MAX, data, data_len, |
| 7037 | qca_wlan_vendor_set_nud_stats); |
| 7038 | if (err) |
| 7039 | { |
| 7040 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7041 | "%s STATS_SET_START ATTR", __func__); |
| 7042 | return err; |
| 7043 | } |
| 7044 | |
| 7045 | if (tb[STATS_SET_START]) |
| 7046 | { |
| 7047 | if (!tb[STATS_GW_IPV4]) { |
| 7048 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7049 | "%s STATS_SET_START CMD", __func__); |
| 7050 | return -EINVAL; |
| 7051 | } |
| 7052 | arp_stats_params.flag = true; |
| 7053 | arp_stats_params.ip_addr = nla_get_u32(tb[STATS_GW_IPV4]); |
| 7054 | } else { |
| 7055 | arp_stats_params.flag = false; |
| 7056 | } |
Anurag Chouhan | 630c556 | 2017-03-23 14:51:47 +0530 | [diff] [blame] | 7057 | if (arp_stats_params.flag) |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 7058 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7059 | "%s STATS_SET_START Cleared!!", __func__); |
Anurag Chouhan | 630c556 | 2017-03-23 14:51:47 +0530 | [diff] [blame] | 7060 | vos_mem_zero(&adapter->hdd_stats.hddArpStats, |
| 7061 | sizeof(adapter->hdd_stats.hddArpStats)); |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 7062 | |
| 7063 | arp_stats_params.pkt_type = 1; // ARP packet type |
| 7064 | |
Sravan Kumar Kairam | d9e8cbb | 2017-01-17 12:17:28 +0530 | [diff] [blame] | 7065 | if (arp_stats_params.flag) { |
| 7066 | hdd_ctx->track_arp_ip = arp_stats_params.ip_addr; |
| 7067 | WLANTL_SetARPFWDatapath(pVosContext, true); |
| 7068 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7069 | "%s Set FW in data path for ARP with tgt IP :%d", |
| 7070 | __func__, hdd_ctx->track_arp_ip); |
| 7071 | } |
| 7072 | else { |
| 7073 | WLANTL_SetARPFWDatapath(pVosContext, false); |
| 7074 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7075 | "%s Remove FW from data path", __func__); |
| 7076 | } |
| 7077 | |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 7078 | arp_stats_params.rsp_cb_fn = hdd_set_nud_stats_cb; |
| 7079 | arp_stats_params.data_ctx = adapter; |
| 7080 | |
| 7081 | if (eHAL_STATUS_SUCCESS != |
| 7082 | sme_set_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) { |
| 7083 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7084 | "%s STATS_SET_START CMD Failed!!", __func__); |
| 7085 | return -EINVAL; |
| 7086 | } |
| 7087 | |
| 7088 | EXIT(); |
| 7089 | |
| 7090 | return err; |
| 7091 | } |
| 7092 | |
| 7093 | /** |
| 7094 | * wlan_hdd_cfg80211_set_nud_stats() - set arp stats command to firmware |
| 7095 | * @wiphy: pointer to wireless wiphy structure. |
| 7096 | * @wdev: pointer to wireless_dev structure. |
| 7097 | * @data: pointer to apfind configuration data. |
| 7098 | * @data_len: the length in byte of apfind data. |
| 7099 | * |
| 7100 | * This is called when wlan driver needs to send arp stats to |
| 7101 | * firmware. |
| 7102 | * |
| 7103 | * Return: An error code or 0 on success. |
| 7104 | */ |
| 7105 | static int wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy, |
| 7106 | struct wireless_dev *wdev, |
| 7107 | const void *data, int data_len) |
| 7108 | { |
| 7109 | int ret; |
| 7110 | |
| 7111 | vos_ssr_protect(__func__); |
| 7112 | ret = __wlan_hdd_cfg80211_set_nud_stats(wiphy, wdev, data, data_len); |
| 7113 | vos_ssr_unprotect(__func__); |
| 7114 | |
| 7115 | return ret; |
| 7116 | } |
| 7117 | #undef STATS_SET_INVALID |
| 7118 | #undef STATS_SET_START |
| 7119 | #undef STATS_GW_IPV4 |
| 7120 | #undef STATS_SET_MAX |
| 7121 | |
| 7122 | /* |
| 7123 | * define short names for the global vendor params |
| 7124 | * used by wlan_hdd_cfg80211_setarp_stats_cmd() |
| 7125 | */ |
| 7126 | #define STATS_GET_INVALID \ |
| 7127 | QCA_ATTR_NUD_STATS_SET_INVALID |
| 7128 | #define COUNT_FROM_NETDEV \ |
| 7129 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV |
| 7130 | #define COUNT_TO_LOWER_MAC \ |
| 7131 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC |
| 7132 | #define RX_COUNT_BY_LOWER_MAC \ |
| 7133 | QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC |
| 7134 | #define COUNT_TX_SUCCESS \ |
| 7135 | QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS |
| 7136 | #define RSP_RX_COUNT_BY_LOWER_MAC \ |
| 7137 | QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC |
| 7138 | #define RSP_RX_COUNT_BY_UPPER_MAC \ |
| 7139 | QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC |
| 7140 | #define RSP_COUNT_TO_NETDEV \ |
| 7141 | QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV |
| 7142 | #define RSP_COUNT_OUT_OF_ORDER_DROP \ |
| 7143 | QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP |
| 7144 | #define AP_LINK_ACTIVE \ |
| 7145 | QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE |
| 7146 | #define AP_LINK_DAD \ |
| 7147 | QCA_ATTR_NUD_STATS_AP_LINK_DAD |
| 7148 | #define STATS_GET_MAX \ |
| 7149 | QCA_ATTR_NUD_STATS_GET_MAX |
| 7150 | |
| 7151 | const struct nla_policy |
| 7152 | qca_wlan_vendor_get_nud_stats[STATS_GET_MAX +1] = |
| 7153 | { |
| 7154 | [COUNT_FROM_NETDEV] = {.type = NLA_U16 }, |
| 7155 | [COUNT_TO_LOWER_MAC] = {.type = NLA_U16 }, |
| 7156 | [RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 }, |
| 7157 | [COUNT_TX_SUCCESS] = {.type = NLA_U16 }, |
| 7158 | [RSP_RX_COUNT_BY_LOWER_MAC] = {.type = NLA_U16 }, |
| 7159 | [RSP_RX_COUNT_BY_UPPER_MAC] = {.type = NLA_U16 }, |
| 7160 | [RSP_COUNT_TO_NETDEV] = {.type = NLA_U16 }, |
| 7161 | [RSP_COUNT_OUT_OF_ORDER_DROP] = {.type = NLA_U16 }, |
| 7162 | [AP_LINK_ACTIVE] = {.type = NLA_FLAG }, |
| 7163 | [AP_LINK_DAD] = {.type = NLA_FLAG }, |
| 7164 | }; |
| 7165 | |
| 7166 | static void hdd_get_nud_stats_cb(void *data, rsp_stats *rsp) |
| 7167 | { |
| 7168 | |
| 7169 | hdd_adapter_t *adapter = (hdd_adapter_t *)data; |
| 7170 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7171 | struct hdd_nud_stats_context *context; |
| 7172 | int status; |
| 7173 | |
| 7174 | ENTER(); |
| 7175 | |
| 7176 | if (NULL == adapter) |
| 7177 | return; |
| 7178 | |
| 7179 | status = wlan_hdd_validate_context(hdd_ctx); |
| 7180 | if (0 != status) { |
| 7181 | return; |
| 7182 | } |
| 7183 | |
| 7184 | if (!rsp) { |
| 7185 | hddLog(LOGE, FL("data is null")); |
| 7186 | return; |
| 7187 | } |
| 7188 | |
| 7189 | adapter->hdd_stats.hddArpStats.tx_fw_cnt = rsp->tx_fw_cnt; |
| 7190 | adapter->hdd_stats.hddArpStats.rx_fw_cnt = rsp->rx_fw_cnt; |
| 7191 | adapter->hdd_stats.hddArpStats.tx_ack_cnt = rsp->tx_ack_cnt; |
| 7192 | adapter->dad |= rsp->dad; |
| 7193 | |
| 7194 | spin_lock(&hdd_context_lock); |
| 7195 | context = &hdd_ctx->nud_stats_context; |
| 7196 | complete(&context->response_event); |
| 7197 | spin_unlock(&hdd_context_lock); |
| 7198 | |
| 7199 | return; |
| 7200 | } |
| 7201 | static int __wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy, |
| 7202 | struct wireless_dev *wdev, |
| 7203 | const void *data, int data_len) |
| 7204 | { |
| 7205 | int err = 0; |
| 7206 | unsigned long rc; |
| 7207 | struct hdd_nud_stats_context *context; |
| 7208 | struct net_device *dev = wdev->netdev; |
| 7209 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7210 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7211 | getArpStatsParams arp_stats_params; |
| 7212 | struct sk_buff *skb; |
| 7213 | |
| 7214 | ENTER(); |
| 7215 | |
| 7216 | err = wlan_hdd_validate_context(hdd_ctx); |
| 7217 | if (0 != err) |
| 7218 | return err; |
| 7219 | |
| 7220 | arp_stats_params.pkt_type = WLAN_NUD_STATS_ARP_PKT_TYPE; |
| 7221 | arp_stats_params.get_rsp_cb_fn = hdd_get_nud_stats_cb; |
| 7222 | arp_stats_params.data_ctx = adapter; |
| 7223 | |
| 7224 | spin_lock(&hdd_context_lock); |
| 7225 | context = &hdd_ctx->nud_stats_context; |
| 7226 | INIT_COMPLETION(context->response_event); |
| 7227 | spin_unlock(&hdd_context_lock); |
| 7228 | |
| 7229 | if (!sme_IsFeatureSupportedByFW(NUD_DEBUG)) { |
| 7230 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7231 | "%s NUD_DEBUG feature not supported by firmware!!", __func__); |
| 7232 | return -EINVAL; |
| 7233 | } |
| 7234 | |
| 7235 | if (eHAL_STATUS_SUCCESS != |
| 7236 | sme_get_nud_debug_stats(hdd_ctx->hHal, &arp_stats_params)) { |
| 7237 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7238 | "%s STATS_SET_START CMD Failed!!", __func__); |
| 7239 | return -EINVAL; |
| 7240 | } |
| 7241 | |
| 7242 | rc = wait_for_completion_timeout(&context->response_event, |
| 7243 | msecs_to_jiffies(WLAN_WAIT_TIME_NUD_STATS)); |
| 7244 | if (!rc) |
| 7245 | { |
| 7246 | hddLog(LOGE, |
| 7247 | FL("Target response timed out request ")); |
| 7248 | return -ETIMEDOUT; |
| 7249 | } |
| 7250 | |
| 7251 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 7252 | WLAN_NUD_STATS_LEN); |
| 7253 | if (!skb) |
| 7254 | { |
| 7255 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7256 | "%s: cfg80211_vendor_cmd_alloc_reply_skb failed", |
| 7257 | __func__); |
| 7258 | return -ENOMEM; |
| 7259 | } |
| 7260 | |
| 7261 | if (nla_put_u16(skb, COUNT_FROM_NETDEV, |
| 7262 | adapter->hdd_stats.hddArpStats.txCount) || |
| 7263 | nla_put_u16(skb, COUNT_TO_LOWER_MAC, |
| 7264 | adapter->hdd_stats.hddArpStats.tx_host_fw_sent) || |
| 7265 | nla_put_u16(skb, RX_COUNT_BY_LOWER_MAC, |
| 7266 | adapter->hdd_stats.hddArpStats.tx_fw_cnt) || |
| 7267 | nla_put_u16(skb, COUNT_TX_SUCCESS, |
| 7268 | adapter->hdd_stats.hddArpStats.tx_ack_cnt) || |
| 7269 | nla_put_u16(skb, RSP_RX_COUNT_BY_LOWER_MAC, |
| 7270 | adapter->hdd_stats.hddArpStats.rx_fw_cnt) || |
| 7271 | nla_put_u16(skb, RSP_RX_COUNT_BY_UPPER_MAC, |
| 7272 | adapter->hdd_stats.hddArpStats.rxCount) || |
| 7273 | nla_put_u16(skb, RSP_COUNT_TO_NETDEV, |
| 7274 | adapter->hdd_stats.hddArpStats.rxDelivered) || |
| 7275 | nla_put_u16(skb, RSP_COUNT_OUT_OF_ORDER_DROP, |
| 7276 | adapter->hdd_stats.hddArpStats.rx_host_drop_reorder)) { |
| 7277 | hddLog(LOGE, FL("nla put fail")); |
| 7278 | kfree_skb(skb); |
| 7279 | return -EINVAL; |
| 7280 | } |
| 7281 | if (adapter->con_status) |
| 7282 | nla_put_flag(skb, AP_LINK_ACTIVE); |
| 7283 | if (adapter->dad) |
| 7284 | nla_put_flag(skb, AP_LINK_DAD); |
| 7285 | |
| 7286 | cfg80211_vendor_cmd_reply(skb); |
| 7287 | return err; |
| 7288 | } |
| 7289 | |
| 7290 | static int wlan_hdd_cfg80211_get_nud_stats(struct wiphy *wiphy, |
| 7291 | struct wireless_dev *wdev, |
| 7292 | const void *data, int data_len) |
| 7293 | { |
| 7294 | int ret; |
| 7295 | |
| 7296 | vos_ssr_protect(__func__); |
| 7297 | ret = __wlan_hdd_cfg80211_get_nud_stats(wiphy, wdev, data, data_len); |
| 7298 | vos_ssr_unprotect(__func__); |
| 7299 | |
| 7300 | return ret; |
| 7301 | } |
| 7302 | |
| 7303 | #undef QCA_ATTR_NUD_STATS_SET_INVALID |
| 7304 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_FROM_NETDEV |
| 7305 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TO_LOWER_MAC |
| 7306 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_RX_COUNT_BY_LOWER_MAC |
| 7307 | #undef QCA_ATTR_NUD_STATS_ARP_REQ_COUNT_TX_SUCCESS |
| 7308 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_LOWER_MAC |
| 7309 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_RX_COUNT_BY_UPPER_MAC |
| 7310 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_TO_NETDEV |
| 7311 | #undef QCA_ATTR_NUD_STATS_ARP_RSP_COUNT_OUT_OF_ORDER_DROP |
| 7312 | #undef QCA_ATTR_NUD_STATS_AP_LINK_ACTIVE |
| 7313 | #undef QCA_ATTR_NUD_STATS_GET_MAX |
| 7314 | |
| 7315 | |
| 7316 | |
Kapil Gupta | ee33bf1 | 2016-12-20 18:27:37 +0530 | [diff] [blame] | 7317 | #ifdef WLAN_FEATURE_APFIND |
| 7318 | /** |
| 7319 | * __wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware |
| 7320 | * @wiphy: pointer to wireless wiphy structure. |
| 7321 | * @wdev: pointer to wireless_dev structure. |
| 7322 | * @data: pointer to apfind configuration data. |
| 7323 | * @data_len: the length in byte of apfind data. |
| 7324 | * |
| 7325 | * This is called when wlan driver needs to send APFIND configurations to |
| 7326 | * firmware. |
| 7327 | * |
| 7328 | * Return: An error code or 0 on success. |
| 7329 | */ |
| 7330 | static int __wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy, |
| 7331 | struct wireless_dev *wdev, |
| 7332 | const void *data, int data_len) |
| 7333 | { |
| 7334 | struct sme_ap_find_request_req apfind_req; |
| 7335 | VOS_STATUS status; |
| 7336 | int ret_val; |
| 7337 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 7338 | |
| 7339 | ENTER(); |
| 7340 | |
| 7341 | ret_val = wlan_hdd_validate_context(hdd_ctx); |
| 7342 | if (ret_val) |
| 7343 | return ret_val; |
| 7344 | |
| 7345 | if (VOS_FTM_MODE == hdd_get_conparam()) { |
| 7346 | hddLog(LOGE, FL("Command not allowed in FTM mode")); |
| 7347 | return -EPERM; |
| 7348 | } |
| 7349 | |
| 7350 | apfind_req.request_data_len = data_len; |
| 7351 | apfind_req.request_data = data; |
| 7352 | |
| 7353 | status = sme_apfind_set_cmd(&apfind_req); |
| 7354 | if (VOS_STATUS_SUCCESS != status) { |
| 7355 | ret_val = -EIO; |
| 7356 | } |
| 7357 | return ret_val; |
| 7358 | } |
| 7359 | |
| 7360 | /** |
| 7361 | * wlan_hdd_cfg80211_apfind_cmd() - set configuration to firmware |
| 7362 | * @wiphy: pointer to wireless wiphy structure. |
| 7363 | * @wdev: pointer to wireless_dev structure. |
| 7364 | * @data: pointer to apfind configuration data. |
| 7365 | * @data_len: the length in byte of apfind data. |
| 7366 | * |
| 7367 | * This is called when wlan driver needs to send APFIND configurations to |
| 7368 | * firmware. |
| 7369 | * |
| 7370 | * Return: An error code or 0 on success. |
| 7371 | */ |
| 7372 | static int wlan_hdd_cfg80211_apfind_cmd(struct wiphy *wiphy, |
| 7373 | struct wireless_dev *wdev, |
| 7374 | const void *data, int data_len) |
| 7375 | { |
| 7376 | int ret; |
| 7377 | |
| 7378 | vos_ssr_protect(__func__); |
| 7379 | ret = __wlan_hdd_cfg80211_apfind_cmd(wiphy, wdev, data, data_len); |
| 7380 | vos_ssr_unprotect(__func__); |
| 7381 | |
| 7382 | return ret; |
| 7383 | } |
| 7384 | #endif /* WLAN_FEATURE_APFIND */ |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7385 | const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = |
| 7386 | { |
Mukul Sharma | 2a27163 | 2014-10-13 14:59:01 +0530 | [diff] [blame] | 7387 | { |
| 7388 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7389 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING, |
| 7390 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7391 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7392 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7393 | .doit = wlan_hdd_cfg80211_firmware_roaming |
Mukul Sharma | 2a27163 | 2014-10-13 14:59:01 +0530 | [diff] [blame] | 7394 | }, |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 7395 | |
| 7396 | { |
| 7397 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7398 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN, |
| 7399 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7400 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7401 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7402 | .doit = wlan_hdd_cfg80211_nan_request |
| 7403 | }, |
| 7404 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7405 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 7406 | { |
| 7407 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7408 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR, |
| 7409 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7410 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7411 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7412 | .doit = wlan_hdd_cfg80211_ll_stats_clear |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7413 | }, |
| 7414 | |
| 7415 | { |
| 7416 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7417 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET, |
| 7418 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7419 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7420 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7421 | .doit = wlan_hdd_cfg80211_ll_stats_set |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7422 | }, |
| 7423 | |
| 7424 | { |
| 7425 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7426 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET, |
| 7427 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7428 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7429 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7430 | .doit = wlan_hdd_cfg80211_ll_stats_get |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7431 | }, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7432 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7433 | #ifdef WLAN_FEATURE_EXTSCAN |
| 7434 | { |
| 7435 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7436 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START, |
| 7437 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7438 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7439 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7440 | .doit = wlan_hdd_cfg80211_extscan_start |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7441 | }, |
| 7442 | { |
| 7443 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7444 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP, |
| 7445 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7446 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7447 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7448 | .doit = wlan_hdd_cfg80211_extscan_stop |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7449 | }, |
| 7450 | { |
| 7451 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7452 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS, |
| 7453 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7454 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7455 | .doit = wlan_hdd_cfg80211_extscan_get_valid_channels |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7456 | }, |
| 7457 | { |
| 7458 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7459 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES, |
| 7460 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7461 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7462 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7463 | .doit = wlan_hdd_cfg80211_extscan_get_capabilities |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7464 | }, |
| 7465 | { |
| 7466 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7467 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS, |
| 7468 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7469 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7470 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7471 | .doit = wlan_hdd_cfg80211_extscan_get_cached_results |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7472 | }, |
| 7473 | { |
| 7474 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7475 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST, |
| 7476 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7477 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7478 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7479 | .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7480 | }, |
| 7481 | { |
| 7482 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7483 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST, |
| 7484 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7485 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7486 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7487 | .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7488 | }, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7489 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7490 | /*EXT TDLS*/ |
| 7491 | { |
| 7492 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7493 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE, |
| 7494 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7495 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7496 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7497 | .doit = wlan_hdd_cfg80211_exttdls_enable |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7498 | }, |
| 7499 | { |
| 7500 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7501 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE, |
| 7502 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7503 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7504 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7505 | .doit = wlan_hdd_cfg80211_exttdls_disable |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7506 | }, |
| 7507 | { |
| 7508 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7509 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS, |
| 7510 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7511 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7512 | .doit = wlan_hdd_cfg80211_exttdls_get_status |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7513 | }, |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 7514 | { |
| 7515 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7516 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES, |
| 7517 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7518 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7519 | .doit = wlan_hdd_cfg80211_get_supported_features |
Dasari Srinivas | 7875a30 | 2014-09-26 17:50:57 +0530 | [diff] [blame] | 7520 | }, |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 7521 | { |
| 7522 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7523 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG, |
| 7524 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7525 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7526 | .doit = wlan_hdd_cfg80211_disable_dfs_channels |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 7527 | }, |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 7528 | { |
| 7529 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7530 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI, |
| 7531 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7532 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7533 | .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui |
Siddharth Bhal | a3a5cb4 | 2014-09-29 21:13:13 +0530 | [diff] [blame] | 7534 | }, |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 7535 | { |
| 7536 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7537 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX, |
| 7538 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7539 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
Edhar, Mahesh Kumar | 59129f5 | 2015-01-14 14:26:04 +0530 | [diff] [blame] | 7540 | .doit = wlan_hdd_cfg80211_get_concurrency_matrix |
Dasari Srinivas | e18b2cf | 2014-10-28 17:09:42 +0530 | [diff] [blame] | 7541 | }, |
Srinivas Dasari | 41d97c9 | 2015-07-29 13:09:39 +0530 | [diff] [blame] | 7542 | { |
| 7543 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 7544 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP, |
| 7545 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7546 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7547 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7548 | .doit = wlan_hdd_cfg80211_get_fw_mem_dump |
| 7549 | }, |
| 7550 | { |
| 7551 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
Srinivas Dasari | 41d97c9 | 2015-07-29 13:09:39 +0530 | [diff] [blame] | 7552 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND, |
| 7553 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7554 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7555 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7556 | .doit = wlan_hdd_cfg80211_setband |
Sushant Kaushik | 8e64498 | 2015-09-23 12:18:54 +0530 | [diff] [blame] | 7557 | }, |
| 7558 | { |
| 7559 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7560 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_START, |
| 7561 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7562 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 7563 | .doit = wlan_hdd_cfg80211_wifi_logger_start |
| 7564 | }, |
Sushant Kaushik | 847890c | 2015-09-28 16:05:17 +0530 | [diff] [blame] | 7565 | { |
| 7566 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7567 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO, |
| 7568 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7569 | WIPHY_VENDOR_CMD_NEED_NETDEV| |
| 7570 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7571 | .doit = wlan_hdd_cfg80211_get_wifi_info |
Sachin Ahuja | c08f72a | 2015-09-22 15:25:47 +0530 | [diff] [blame] | 7572 | }, |
| 7573 | { |
| 7574 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7575 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_RING_DATA, |
| 7576 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7577 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7578 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7579 | .doit = wlan_hdd_cfg80211_wifi_logger_get_ring_data |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 7580 | }, |
| 7581 | { |
| 7582 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7583 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI, |
| 7584 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7585 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7586 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7587 | .doit = wlan_hdd_cfg80211_monitor_rssi |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 7588 | }, |
| 7589 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7590 | { |
| 7591 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7592 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS, |
| 7593 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7594 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7595 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7596 | .doit = wlan_hdd_cfg80211_offloaded_packets |
Deepthi Gowri | ae6a166 | 2015-10-12 12:59:37 +0530 | [diff] [blame] | 7597 | }, |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 7598 | #endif |
Deepthi Gowri | ae6a166 | 2015-10-12 12:59:37 +0530 | [diff] [blame] | 7599 | { |
| 7600 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7601 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LINK_PROPERTIES, |
| 7602 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7603 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7604 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7605 | .doit = wlan_hdd_cfg80211_get_link_properties |
Arun Khandavalli | 7eeb159 | 2015-10-19 21:36:57 +0530 | [diff] [blame] | 7606 | }, |
| 7607 | { |
| 7608 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7609 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION, |
| 7610 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7611 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7612 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7613 | .doit = wlan_hdd_cfg80211_wifi_configuration_set |
Kapil Gupta | ee33bf1 | 2016-12-20 18:27:37 +0530 | [diff] [blame] | 7614 | }, |
| 7615 | #ifdef WLAN_FEATURE_APFIND |
| 7616 | { |
| 7617 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7618 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_APFIND, |
| 7619 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7620 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 7621 | .doit = wlan_hdd_cfg80211_apfind_cmd |
| 7622 | }, |
| 7623 | #endif /* WLAN_FEATURE_APFIND */ |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 7624 | { |
| 7625 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7626 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_SET, |
| 7627 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7628 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7629 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7630 | .doit = wlan_hdd_cfg80211_set_nud_stats |
| 7631 | }, |
| 7632 | { |
| 7633 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 7634 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET, |
| 7635 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 7636 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 7637 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 7638 | .doit = wlan_hdd_cfg80211_get_nud_stats |
| 7639 | }, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7640 | }; |
| 7641 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 7642 | /* vendor specific events */ |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7643 | static const |
| 7644 | struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 7645 | { |
| 7646 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7647 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7648 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7649 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 7650 | }, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7651 | #endif /* FEATURE_WLAN_CH_AVOID Index = 0*/ |
| 7652 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 7653 | { |
| 7654 | /* Index = 1*/ |
| 7655 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7656 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET |
| 7657 | }, |
| 7658 | { |
| 7659 | /* Index = 2*/ |
| 7660 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7661 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET |
| 7662 | }, |
| 7663 | { |
| 7664 | /* Index = 3*/ |
| 7665 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7666 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR |
| 7667 | }, |
| 7668 | { |
| 7669 | /* Index = 4*/ |
| 7670 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7671 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS |
| 7672 | }, |
| 7673 | { |
| 7674 | /* Index = 5*/ |
| 7675 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7676 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS |
| 7677 | }, |
| 7678 | { |
| 7679 | /* Index = 6*/ |
| 7680 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7681 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS |
| 7682 | }, |
| 7683 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7684 | #ifdef WLAN_FEATURE_EXTSCAN |
| 7685 | { |
| 7686 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7687 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START |
| 7688 | }, |
| 7689 | { |
| 7690 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7691 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP |
| 7692 | }, |
| 7693 | { |
| 7694 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7695 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES |
| 7696 | }, |
| 7697 | { |
| 7698 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7699 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS |
| 7700 | }, |
| 7701 | { |
| 7702 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7703 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE |
| 7704 | }, |
| 7705 | { |
| 7706 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7707 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT |
| 7708 | }, |
| 7709 | { |
| 7710 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7711 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT |
| 7712 | }, |
| 7713 | { |
| 7714 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7715 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND |
| 7716 | }, |
| 7717 | { |
| 7718 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7719 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST |
| 7720 | }, |
| 7721 | { |
| 7722 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7723 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST |
| 7724 | }, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 7725 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7726 | /*EXT TDLS*/ |
| 7727 | { |
| 7728 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7729 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE |
| 7730 | }, |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 7731 | [QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP_INDEX] = { |
| 7732 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7733 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_WIFI_LOGGER_MEMORY_DUMP |
| 7734 | }, |
| 7735 | |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 7736 | |
Srinivas Dasari | bd1cf64 | 2017-01-23 14:54:41 +0530 | [diff] [blame] | 7737 | [QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX] = { |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 7738 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7739 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN |
| 7740 | }, |
| 7741 | |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 7742 | { |
| 7743 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7744 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_WIFI_INFO, |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 7745 | }, |
| 7746 | [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = { |
| 7747 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7748 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI |
| 7749 | }, |
Padma, Santhosh Kumar | 7bbc7d9 | 2015-12-08 20:23:19 +0530 | [diff] [blame] | 7750 | [QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX] = { |
| 7751 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7752 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST |
| 7753 | }, |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 7754 | [QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET_INDEX] = { |
| 7755 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 7756 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_NUD_STATS_GET, |
| 7757 | }, |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 7758 | }; |
| 7759 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7760 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7761 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7762 | * This function is called by hdd_wlan_startup() |
| 7763 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7764 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7765 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7766 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7767 | { |
| 7768 | struct wiphy *wiphy; |
| 7769 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7770 | /* |
| 7771 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7772 | */ |
| 7773 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 7774 | |
| 7775 | if (!wiphy) |
| 7776 | { |
| 7777 | /* Print error and jump into err label and free the memory */ |
| 7778 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 7779 | return NULL; |
| 7780 | } |
| 7781 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 7782 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7783 | return wiphy; |
| 7784 | } |
| 7785 | |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 7786 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(4,4,0)) || \ |
| 7787 | defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT) |
| 7788 | /** |
| 7789 | * hdd_config_sched_scan_plans_to_wiphy() - configure sched scan plans to wiphy |
| 7790 | * @wiphy: pointer to wiphy |
| 7791 | * @config: pointer to config |
| 7792 | * |
| 7793 | * Return: None |
| 7794 | */ |
| 7795 | static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy, |
| 7796 | hdd_config_t *config) |
| 7797 | { |
| 7798 | wiphy->max_sched_scan_plans = MAX_SCHED_SCAN_PLANS; |
| 7799 | if (config->max_sched_scan_plan_interval) |
| 7800 | wiphy->max_sched_scan_plan_interval = |
| 7801 | config->max_sched_scan_plan_interval; |
| 7802 | if (config->max_sched_scan_plan_iterations) |
| 7803 | wiphy->max_sched_scan_plan_iterations = |
| 7804 | config->max_sched_scan_plan_iterations; |
| 7805 | } |
| 7806 | #else |
| 7807 | static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy, |
| 7808 | hdd_config_t *config) |
| 7809 | { |
| 7810 | } |
| 7811 | #endif |
| 7812 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7813 | /* |
| 7814 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7815 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7816 | * private ioctl to change the band value |
| 7817 | */ |
| 7818 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 7819 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 7820 | int i, j; |
| 7821 | eNVChannelEnabledType channelEnabledState; |
| 7822 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7823 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7824 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 7825 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7826 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 7827 | |
| 7828 | if (NULL == wiphy->bands[i]) |
| 7829 | { |
| 7830 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 7831 | __func__, i); |
| 7832 | continue; |
| 7833 | } |
| 7834 | |
| 7835 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 7836 | { |
| 7837 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 7838 | |
| 7839 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 7840 | band->channels[j].hw_value); |
| 7841 | |
| 7842 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 7843 | { |
Abhishek Singh | 678227a | 2014-11-04 10:52:38 +0530 | [diff] [blame] | 7844 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 7845 | continue; |
| 7846 | } |
| 7847 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 7848 | { |
| 7849 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 7850 | continue; |
| 7851 | } |
| 7852 | |
| 7853 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 7854 | NV_CHANNEL_INVALID == channelEnabledState) |
| 7855 | { |
| 7856 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 7857 | } |
| 7858 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 7859 | { |
| 7860 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 7861 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 7862 | } |
| 7863 | else |
| 7864 | { |
| 7865 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 7866 | |IEEE80211_CHAN_RADAR); |
| 7867 | } |
| 7868 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7869 | } |
| 7870 | return 0; |
| 7871 | } |
| 7872 | /* |
| 7873 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7874 | * This function is called by hdd_wlan_startup() |
| 7875 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7876 | * This function is used to initialize and register wiphy structure. |
| 7877 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 7878 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7879 | struct wiphy *wiphy, |
| 7880 | hdd_config_t *pCfg |
| 7881 | ) |
| 7882 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 7883 | int i, j; |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 7884 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 7885 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7886 | ENTER(); |
| 7887 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7888 | /* Now bind the underlying wlan device with wiphy */ |
| 7889 | set_wiphy_dev(wiphy, dev); |
| 7890 | |
| 7891 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7892 | |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 7893 | #ifndef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 7894 | /* the flag for the other case would be initialzed in |
| 7895 | vos_init_wiphy_from_nv_bin */ |
Manjeet Singh | 9e19de6 | 2016-08-18 18:26:41 +0530 | [diff] [blame] | 7896 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 7897 | wiphy->regulatory_flags |= REGULATORY_STRICT_REG; |
| 7898 | #else |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 7899 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 7900 | #endif |
Manjeet Singh | 9e19de6 | 2016-08-18 18:26:41 +0530 | [diff] [blame] | 7901 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7902 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7903 | /* This will disable updating of NL channels from passive to |
| 7904 | * active if a beacon is received on passive channel. */ |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 7905 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 7906 | wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS; |
| 7907 | #else |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7908 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 7909 | #endif |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7910 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7911 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7912 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 7913 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 7914 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 7915 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7916 | | WIPHY_FLAG_OFFCHAN_TX; |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 7917 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
Rajeev Kumar Sirasanagandla | 0d6dd75 | 2016-08-17 15:01:39 +0530 | [diff] [blame] | 7918 | wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE; |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 7919 | #else |
| 7920 | wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE; |
| 7921 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7922 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7923 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7924 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 7925 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 7926 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 7927 | || pCfg->isFastRoamIniFeatureEnabled |
| 7928 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7929 | #ifdef FEATURE_WLAN_ESE |
| 7930 | || pCfg->isEseIniFeatureEnabled |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 7931 | #endif |
| 7932 | ) |
| 7933 | { |
| 7934 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 7935 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 7936 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7937 | #ifdef FEATURE_WLAN_TDLS |
| 7938 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 7939 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 7940 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7941 | #ifdef FEATURE_WLAN_SCAN_PNO |
Hardik Kantilal Patel | 3dfd879 | 2013-11-13 20:34:57 +0530 | [diff] [blame] | 7942 | if (pCfg->configPNOScanSupport) |
| 7943 | { |
| 7944 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 7945 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
| 7946 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 7947 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
| 7948 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7949 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7950 | |
Abhishek Singh | 10d8597 | 2015-04-17 10:27:23 +0530 | [diff] [blame] | 7951 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 7952 | wiphy->features |= NL80211_FEATURE_HT_IBSS; |
| 7953 | #endif |
| 7954 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7955 | #ifdef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 7956 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 7957 | driver can still register regulatory callback and |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7958 | it will get regulatory settings in wiphy->band[], but |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 7959 | driver need to determine what to do with both |
| 7960 | regulatory settings */ |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7961 | |
| 7962 | wiphy->reg_notifier = wlan_hdd_linux_reg_notifier; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 7963 | #else |
| 7964 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 7965 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7966 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7967 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 7968 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 7969 | wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7970 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7971 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 7972 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7973 | /* Supports STATION & AD-HOC modes right now */ |
Bhargav Shah | 0d2e3e5 | 2015-07-24 16:51:01 +0530 | [diff] [blame] | 7974 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
| 7975 | | BIT(NL80211_IFTYPE_ADHOC) |
| 7976 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 7977 | | BIT(NL80211_IFTYPE_P2P_GO) |
| 7978 | | BIT(NL80211_IFTYPE_AP); |
| 7979 | |
| 7980 | if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 7981 | { |
| 7982 | wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); |
| 7983 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7984 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 7985 | if( pCfg->advertiseConcurrentOperation ) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 7986 | { |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 7987 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 7988 | if( pCfg->enableMCC ) |
| 7989 | { |
| 7990 | /* Currently, supports up to two channels */ |
| 7991 | wlan_hdd_iface_combination.num_different_channels = 2; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 7992 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 7993 | if( !pCfg->allowMCCGODiffBI ) |
| 7994 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 7995 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 7996 | } |
| 7997 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 7998 | wiphy->n_iface_combinations = 1; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 7999 | #endif |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 8000 | } |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 8001 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8002 | /* Before registering we need to update the ht capabilitied based |
| 8003 | * on ini values*/ |
| 8004 | if( !pCfg->ShortGI20MhzEnable ) |
| 8005 | { |
| 8006 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 8007 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8008 | } |
| 8009 | |
| 8010 | if( !pCfg->ShortGI40MhzEnable ) |
| 8011 | { |
| 8012 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 8013 | } |
| 8014 | |
| 8015 | if( !pCfg->nChannelBondingMode5GHz ) |
| 8016 | { |
| 8017 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 8018 | } |
Agrawal Ashish | 97dec50 | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 8019 | /* |
| 8020 | * In case of static linked driver at the time of driver unload, |
| 8021 | * module exit doesn't happens. Module cleanup helps in cleaning |
| 8022 | * of static memory. |
| 8023 | * If driver load happens statically, at the time of driver unload, |
| 8024 | * wiphy flags don't get reset because of static memory. |
| 8025 | * It's better not to store channel in static memory. |
| 8026 | */ |
| 8027 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 8028 | wiphy->bands[IEEE80211_BAND_2GHZ]->channels = |
| 8029 | (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_2_4_GHZ)); |
| 8030 | if (wiphy->bands[IEEE80211_BAND_2GHZ]->channels == NULL) |
| 8031 | { |
| 8032 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8033 | FL("Not enough memory to allocate channels")); |
| 8034 | return -ENOMEM; |
| 8035 | } |
| 8036 | vos_mem_copy(wiphy->bands[IEEE80211_BAND_2GHZ]->channels, |
| 8037 | &hdd_channels_2_4_GHZ[0], |
| 8038 | sizeof(hdd_channels_2_4_GHZ)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8039 | |
Agrawal Ashish | 97dec50 | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 8040 | if (true == hdd_is_5g_supported(pHddCtx)) |
| 8041 | { |
| 8042 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 8043 | wiphy->bands[IEEE80211_BAND_5GHZ]->channels = |
| 8044 | (struct ieee80211_channel *)vos_mem_malloc(sizeof(hdd_channels_5_GHZ)); |
| 8045 | if (wiphy->bands[IEEE80211_BAND_5GHZ]->channels == NULL) |
| 8046 | { |
| 8047 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8048 | FL("Not enough memory to allocate channels")); |
| 8049 | vos_mem_free(wiphy->bands[IEEE80211_BAND_2GHZ]->channels); |
| 8050 | wiphy->bands[IEEE80211_BAND_2GHZ]->channels = NULL; |
| 8051 | return -ENOMEM; |
| 8052 | } |
| 8053 | vos_mem_copy(wiphy->bands[IEEE80211_BAND_5GHZ]->channels, |
| 8054 | &hdd_channels_5_GHZ[0], |
| 8055 | sizeof(hdd_channels_5_GHZ)); |
| 8056 | } |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 8057 | |
| 8058 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 8059 | { |
| 8060 | |
| 8061 | if (NULL == wiphy->bands[i]) |
| 8062 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 8063 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d", |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 8064 | __func__, i); |
| 8065 | continue; |
| 8066 | } |
| 8067 | |
| 8068 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 8069 | { |
| 8070 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 8071 | |
| 8072 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 8073 | { |
| 8074 | // Enable social channels for P2P |
| 8075 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 8076 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 8077 | else |
| 8078 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 8079 | continue; |
| 8080 | } |
| 8081 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 8082 | { |
| 8083 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 8084 | continue; |
| 8085 | } |
| 8086 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8087 | } |
| 8088 | /*Initialise the supported cipher suite details*/ |
| 8089 | wiphy->cipher_suites = hdd_cipher_suites; |
| 8090 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 8091 | |
| 8092 | /*signal strength in mBm (100*dBm) */ |
| 8093 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 8094 | |
| 8095 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Sushant Kaushik | 4f640e4 | 2014-07-08 12:27:09 +0530 | [diff] [blame] | 8096 | wiphy->max_remain_on_channel_duration = 5000; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8097 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8098 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 8099 | wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands); |
| 8100 | wiphy->vendor_commands = hdd_wiphy_vendor_commands; |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 8101 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 8102 | wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 8103 | |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 8104 | hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg); |
| 8105 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8106 | EXIT(); |
| 8107 | return 0; |
| 8108 | } |
| 8109 | |
| 8110 | /* In this function we are registering wiphy. */ |
| 8111 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 8112 | { |
| 8113 | ENTER(); |
| 8114 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8115 | if (0 > wiphy_register(wiphy)) |
| 8116 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8117 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8118 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 8119 | return -EIO; |
| 8120 | } |
| 8121 | |
| 8122 | EXIT(); |
| 8123 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8124 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8125 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8126 | /* In this function we are updating channel list when, |
| 8127 | regulatory domain is FCC and country code is US. |
| 8128 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 8129 | As per FCC smart phone is not a indoor device. |
| 8130 | GO should not opeate on indoor channels */ |
| 8131 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 8132 | { |
| 8133 | int j; |
| 8134 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8135 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 8136 | //Default counrtycode from NV at the time of wiphy initialization. |
| 8137 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 8138 | &defaultCountryCode[0])) |
| 8139 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8140 | hddLog(LOGE, FL("Failed to get default country code from NV")); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8141 | } |
| 8142 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 8143 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8144 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 8145 | { |
| 8146 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 8147 | return; |
| 8148 | } |
| 8149 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 8150 | { |
| 8151 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 8152 | // Mark UNII -1 band channel as passive |
| 8153 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 8154 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 8155 | } |
| 8156 | } |
| 8157 | } |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 8158 | /* This function registers for all frame which supplicant is interested in */ |
| 8159 | void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8160 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8161 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8162 | /* Register for all P2P action, public action etc frames */ |
| 8163 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8164 | ENTER(); |
Abhishek Singh | 16e0576 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 8165 | /* Register frame indication call back */ |
| 8166 | sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8167 | /* Right now we are registering these frame when driver is getting |
| 8168 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 8169 | frame register ops, we will move this code as a part of that */ |
| 8170 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8171 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8172 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 8173 | |
| 8174 | /* GAS Initial Response */ |
| 8175 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8176 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8177 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8178 | /* GAS Comeback Request */ |
| 8179 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8180 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 8181 | |
| 8182 | /* GAS Comeback Response */ |
| 8183 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8184 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 8185 | |
| 8186 | /* P2P Public Action */ |
| 8187 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8188 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8189 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 8190 | |
| 8191 | /* P2P Action */ |
| 8192 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8193 | (v_U8_t*)P2P_ACTION_FRAME, |
| 8194 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 8195 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 8196 | /* WNM BSS Transition Request frame */ |
| 8197 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8198 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 8199 | WNM_BSS_ACTION_FRAME_SIZE ); |
Leela Venkata Kiran Kumar Reddy Chirala | e8e62c8 | 2013-10-29 18:23:26 -0700 | [diff] [blame] | 8200 | |
| 8201 | /* WNM-Notification */ |
| 8202 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8203 | (v_U8_t*)WNM_NOTIFICATION_FRAME, |
| 8204 | WNM_NOTIFICATION_FRAME_SIZE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8205 | } |
| 8206 | |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 8207 | void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8208 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8209 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8210 | /* Register for all P2P action, public action etc frames */ |
| 8211 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 8212 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8213 | ENTER(); |
| 8214 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8215 | /* Right now we are registering these frame when driver is getting |
| 8216 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 8217 | frame register ops, we will move this code as a part of that */ |
| 8218 | /* GAS Initial Request */ |
| 8219 | |
| 8220 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8221 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 8222 | |
| 8223 | /* GAS Initial Response */ |
| 8224 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8225 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8226 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8227 | /* GAS Comeback Request */ |
| 8228 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8229 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 8230 | |
| 8231 | /* GAS Comeback Response */ |
| 8232 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8233 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 8234 | |
| 8235 | /* P2P Public Action */ |
| 8236 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8237 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8238 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 8239 | |
| 8240 | /* P2P Action */ |
| 8241 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8242 | (v_U8_t*)P2P_ACTION_FRAME, |
| 8243 | P2P_ACTION_FRAME_SIZE ); |
Leela Venkata Kiran Kumar Reddy Chirala | e8e62c8 | 2013-10-29 18:23:26 -0700 | [diff] [blame] | 8244 | /* WNM-Notification */ |
| 8245 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 8246 | (v_U8_t*)WNM_NOTIFICATION_FRAME, |
| 8247 | WNM_NOTIFICATION_FRAME_SIZE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8248 | } |
| 8249 | |
| 8250 | #ifdef FEATURE_WLAN_WAPI |
| 8251 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 8252 | const u8 *mac_addr, const u8 *key , int key_Len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8253 | { |
| 8254 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8255 | tCsrRoamSetKey setKey; |
| 8256 | v_BOOL_t isConnected = TRUE; |
| 8257 | int status = 0; |
| 8258 | v_U32_t roamId= 0xFF; |
| 8259 | tANI_U8 *pKeyPtr = NULL; |
| 8260 | int n = 0; |
| 8261 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8262 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)", |
| 8263 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 8264 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8265 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 8266 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8267 | setKey.keyId = key_index; // Store Key ID |
| 8268 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 8269 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 8270 | setKey.paeRole = 0 ; // the PAE role |
| 8271 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 8272 | { |
| 8273 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 8274 | } |
| 8275 | else |
| 8276 | { |
| 8277 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 8278 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 8279 | } |
| 8280 | setKey.keyLength = key_Len; |
| 8281 | pKeyPtr = setKey.Key; |
| 8282 | memcpy( pKeyPtr, key, key_Len); |
| 8283 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8284 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8285 | __func__, key_Len); |
| 8286 | for (n = 0 ; n < key_Len; n++) |
| 8287 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 8288 | __func__,n,setKey.Key[n]); |
| 8289 | |
| 8290 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 8291 | if ( isConnected ) |
| 8292 | { |
| 8293 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8294 | pAdapter->sessionId, &setKey, &roamId ); |
| 8295 | } |
| 8296 | if ( status != 0 ) |
| 8297 | { |
| 8298 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8299 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 8300 | __LINE__, status ); |
| 8301 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 8302 | } |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 8303 | /* Need to clear any trace of key value in the memory. |
| 8304 | * Thus zero out the memory even though it is local |
| 8305 | * variable. |
| 8306 | */ |
| 8307 | vos_mem_zero(&setKey, sizeof(setKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8308 | } |
| 8309 | #endif /* FEATURE_WLAN_WAPI*/ |
| 8310 | |
| 8311 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8312 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8313 | beacon_data_t **ppBeacon, |
| 8314 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8315 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8316 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8317 | beacon_data_t **ppBeacon, |
| 8318 | struct cfg80211_beacon_data *params, |
| 8319 | int dtim_period) |
| 8320 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8321 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8322 | int size; |
| 8323 | beacon_data_t *beacon = NULL; |
| 8324 | beacon_data_t *old = NULL; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8325 | int head_len, tail_len, proberesp_ies_len, assocresp_ies_len; |
| 8326 | const u8 *head, *tail, *proberesp_ies, *assocresp_ies; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8327 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8328 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8329 | if (params->head && !params->head_len) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8330 | { |
| 8331 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8332 | FL("head_len is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8333 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8334 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8335 | |
| 8336 | old = pAdapter->sessionCtx.ap.beacon; |
| 8337 | |
| 8338 | if (!params->head && !old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8339 | { |
| 8340 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8341 | FL("session(%d) old and new heads points to NULL"), |
| 8342 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8343 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8344 | } |
| 8345 | |
| 8346 | if (params->tail && !params->tail_len) |
| 8347 | { |
| 8348 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8349 | FL("tail_len is zero but tail is not NULL")); |
| 8350 | return -EINVAL; |
| 8351 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8352 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8353 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 8354 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 8355 | if (!params->dtim_period) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8356 | { |
| 8357 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8358 | FL("dtim period is 0")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8359 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8360 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8361 | #endif |
| 8362 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8363 | if (params->head) |
| 8364 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8365 | head_len = params->head_len; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8366 | head = params->head; |
| 8367 | } else |
| 8368 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8369 | head_len = old->head_len; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8370 | head = old->head; |
| 8371 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8372 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8373 | if (params->tail || !old) |
| 8374 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8375 | tail_len = params->tail_len; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8376 | tail = params->tail; |
| 8377 | } else |
| 8378 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8379 | tail_len = old->tail_len; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8380 | tail = old->tail; |
| 8381 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8382 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8383 | if (params->proberesp_ies || !old) |
| 8384 | { |
| 8385 | proberesp_ies_len = params->proberesp_ies_len; |
| 8386 | proberesp_ies = params->proberesp_ies; |
| 8387 | } else |
| 8388 | { |
| 8389 | proberesp_ies_len = old->proberesp_ies_len; |
| 8390 | proberesp_ies = old->proberesp_ies; |
| 8391 | } |
| 8392 | |
| 8393 | if (params->assocresp_ies || !old) |
| 8394 | { |
| 8395 | assocresp_ies_len = params->assocresp_ies_len; |
| 8396 | assocresp_ies = params->assocresp_ies; |
| 8397 | } else |
| 8398 | { |
| 8399 | assocresp_ies_len = old->assocresp_ies_len; |
| 8400 | assocresp_ies = old->assocresp_ies; |
| 8401 | } |
| 8402 | |
| 8403 | size = sizeof(beacon_data_t) + head_len + tail_len + |
| 8404 | proberesp_ies_len + assocresp_ies_len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8405 | |
| 8406 | beacon = kzalloc(size, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8407 | if( beacon == NULL ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8408 | { |
| 8409 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8410 | FL("Mem allocation for beacon failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8411 | return -ENOMEM; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8412 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8413 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8414 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8415 | if (params->dtim_period) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8416 | beacon->dtim_period = params->dtim_period; |
| 8417 | else |
| 8418 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8419 | #else |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8420 | if (dtim_period) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8421 | beacon->dtim_period = dtim_period; |
| 8422 | else |
| 8423 | beacon->dtim_period = old->dtim_period; |
| 8424 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8425 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8426 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 8427 | beacon->tail = beacon->head + head_len; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8428 | beacon->proberesp_ies = beacon->tail + tail_len; |
| 8429 | beacon->assocresp_ies = beacon->proberesp_ies + proberesp_ies_len; |
| 8430 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8431 | beacon->head_len = head_len; |
| 8432 | beacon->tail_len = tail_len; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8433 | beacon->proberesp_ies_len = proberesp_ies_len; |
| 8434 | beacon->assocresp_ies_len= assocresp_ies_len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8435 | |
c_manjee | 527ecac | 2017-01-25 12:25:27 +0530 | [diff] [blame] | 8436 | if (head && head_len) |
| 8437 | memcpy(beacon->head, head, head_len); |
| 8438 | if (tail && tail_len) |
| 8439 | memcpy(beacon->tail, tail, tail_len); |
| 8440 | if (proberesp_ies && proberesp_ies_len) |
| 8441 | memcpy(beacon->proberesp_ies, proberesp_ies, proberesp_ies_len); |
| 8442 | if (assocresp_ies && assocresp_ies_len) |
| 8443 | memcpy(beacon->assocresp_ies, assocresp_ies, assocresp_ies_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8444 | |
| 8445 | *ppBeacon = beacon; |
| 8446 | |
| 8447 | kfree(old); |
| 8448 | |
| 8449 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8450 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8451 | |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 8452 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr( |
| 8453 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 8454 | const v_U8_t *pIes, |
| 8455 | #else |
| 8456 | v_U8_t *pIes, |
| 8457 | #endif |
| 8458 | int length, v_U8_t eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8459 | { |
| 8460 | int left = length; |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 8461 | v_U8_t *ptr = (v_U8_t *)pIes; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8462 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8463 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8464 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8465 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8466 | elem_id = ptr[0]; |
| 8467 | elem_len = ptr[1]; |
| 8468 | left -= 2; |
| 8469 | if(elem_len > left) |
| 8470 | { |
| 8471 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 8472 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8473 | eid,elem_len,left); |
| 8474 | return NULL; |
| 8475 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8476 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8477 | { |
| 8478 | return ptr; |
| 8479 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8480 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8481 | left -= elem_len; |
| 8482 | ptr += (elem_len + 2); |
| 8483 | } |
| 8484 | return NULL; |
| 8485 | } |
| 8486 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8487 | /* Check if rate is 11g rate or not */ |
| 8488 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 8489 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 8490 | static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8491 | u8 i; |
| 8492 | for (i = 0; i < 8; i++) |
| 8493 | { |
| 8494 | if(rate == gRateArray[i]) |
| 8495 | return TRUE; |
| 8496 | } |
| 8497 | return FALSE; |
| 8498 | } |
| 8499 | |
| 8500 | /* Check for 11g rate and set proper 11g only mode */ |
| 8501 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 8502 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 8503 | { |
| 8504 | u8 i, num_rates = pIe[0]; |
| 8505 | |
| 8506 | pIe += 1; |
| 8507 | for ( i = 0; i < num_rates; i++) |
| 8508 | { |
| 8509 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 8510 | { |
| 8511 | /* If rate set have 11g rate than change the mode to 11G */ |
| 8512 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 8513 | if (pIe[i] & BASIC_RATE_MASK) |
| 8514 | { |
| 8515 | /* If we have 11g rate as basic rate, it means mode |
| 8516 | is 11g only mode. |
| 8517 | */ |
| 8518 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 8519 | *pCheckRatesfor11g = FALSE; |
| 8520 | } |
| 8521 | } |
| 8522 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 8523 | { |
| 8524 | *require_ht = TRUE; |
| 8525 | } |
| 8526 | } |
| 8527 | return; |
| 8528 | } |
| 8529 | |
| 8530 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 8531 | { |
| 8532 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 8533 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 8534 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 8535 | u8 checkRatesfor11g = TRUE; |
| 8536 | u8 require_ht = FALSE; |
| 8537 | u8 *pIe=NULL; |
| 8538 | |
| 8539 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 8540 | |
| 8541 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 8542 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 8543 | if (pIe != NULL) |
| 8544 | { |
| 8545 | pIe += 1; |
| 8546 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 8547 | &pConfig->SapHw_mode); |
| 8548 | } |
| 8549 | |
| 8550 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 8551 | WLAN_EID_EXT_SUPP_RATES); |
| 8552 | if (pIe != NULL) |
| 8553 | { |
| 8554 | |
| 8555 | pIe += 1; |
| 8556 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 8557 | &pConfig->SapHw_mode); |
| 8558 | } |
| 8559 | |
| 8560 | if( pConfig->channel > 14 ) |
| 8561 | { |
| 8562 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 8563 | } |
| 8564 | |
| 8565 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 8566 | WLAN_EID_HT_CAPABILITY); |
| 8567 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8568 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8569 | { |
| 8570 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 8571 | if(require_ht) |
| 8572 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 8573 | } |
| 8574 | } |
| 8575 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8576 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 8577 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 8578 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 8579 | v_U16_t ielen = 0; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8580 | v_U8_t *pIe = NULL; |
| 8581 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 8582 | |
| 8583 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 8584 | pBeacon->tail, pBeacon->tail_len); |
| 8585 | |
| 8586 | if (pIe) |
| 8587 | { |
| 8588 | ielen = pIe[1] + 2; |
| 8589 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 8590 | { |
| 8591 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 8592 | } |
| 8593 | else |
| 8594 | { |
| 8595 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 8596 | return -EINVAL; |
| 8597 | } |
| 8598 | *total_ielen += ielen; |
| 8599 | } |
| 8600 | return 0; |
| 8601 | } |
| 8602 | |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 8603 | static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter, |
| 8604 | v_U8_t *genie, v_U8_t *total_ielen) |
| 8605 | { |
| 8606 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 8607 | int left = pBeacon->tail_len; |
| 8608 | v_U8_t *ptr = pBeacon->tail; |
| 8609 | v_U8_t elem_id, elem_len; |
| 8610 | v_U16_t ielen = 0; |
| 8611 | |
| 8612 | if ( NULL == ptr || 0 == left ) |
| 8613 | return; |
| 8614 | |
| 8615 | while (left >= 2) |
| 8616 | { |
| 8617 | elem_id = ptr[0]; |
| 8618 | elem_len = ptr[1]; |
| 8619 | left -= 2; |
| 8620 | if (elem_len > left) |
| 8621 | { |
| 8622 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 8623 | "****Invalid IEs eid = %d elem_len=%d left=%d*****", |
| 8624 | elem_id, elem_len, left); |
| 8625 | return; |
| 8626 | } |
| 8627 | if (IE_EID_VENDOR == elem_id) |
| 8628 | { |
| 8629 | /* skipping the VSIE's which we don't want to include or |
| 8630 | * it will be included by existing code |
| 8631 | */ |
| 8632 | if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) && |
| 8633 | #ifdef WLAN_FEATURE_WFD |
| 8634 | (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) && |
| 8635 | #endif |
| 8636 | (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 8637 | (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 8638 | (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) && |
| 8639 | (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 8640 | (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0)) |
| 8641 | { |
| 8642 | ielen = ptr[1] + 2; |
| 8643 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 8644 | { |
| 8645 | vos_mem_copy(&genie[*total_ielen], ptr, ielen); |
| 8646 | *total_ielen += ielen; |
| 8647 | } |
| 8648 | else |
| 8649 | { |
| 8650 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 8651 | "IE Length is too big " |
| 8652 | "IEs eid=%d elem_len=%d total_ie_lent=%d", |
| 8653 | elem_id, elem_len, *total_ielen); |
| 8654 | } |
| 8655 | } |
| 8656 | } |
| 8657 | |
| 8658 | left -= elem_len; |
| 8659 | ptr += (elem_len + 2); |
| 8660 | } |
| 8661 | return; |
| 8662 | } |
| 8663 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8664 | int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *pHostapdAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8665 | { |
| 8666 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8667 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8668 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8669 | int ret = 0; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8670 | beacon_data_t *pBeacon = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8671 | |
| 8672 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 8673 | |
| 8674 | if(genie == NULL) { |
| 8675 | |
| 8676 | return -ENOMEM; |
| 8677 | } |
| 8678 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8679 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8680 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 8681 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8682 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8683 | hddLog(LOGE, |
| 8684 | FL("Adding WPS IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8685 | ret = -EINVAL; |
| 8686 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8687 | } |
| 8688 | |
| 8689 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8690 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 8691 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 8692 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8693 | hddLog(LOGE, |
| 8694 | FL("Adding WFD IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8695 | ret = -EINVAL; |
| 8696 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8697 | } |
| 8698 | #endif |
| 8699 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8700 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 8701 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8702 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8703 | hddLog(LOGE, |
| 8704 | FL("Adding P2P IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8705 | ret = -EINVAL; |
| 8706 | goto done; |
| 8707 | } |
| 8708 | |
| 8709 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 8710 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 8711 | wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8712 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8713 | |
| 8714 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8715 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 8716 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 8717 | { |
| 8718 | hddLog(LOGE, |
| 8719 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8720 | ret = -EINVAL; |
| 8721 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8722 | } |
| 8723 | |
| 8724 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8725 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 8726 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 8727 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 8728 | ==eHAL_STATUS_FAILURE) |
| 8729 | { |
| 8730 | hddLog(LOGE, |
| 8731 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8732 | ret = -EINVAL; |
| 8733 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8734 | } |
| 8735 | |
| 8736 | // Added for ProResp IE |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8737 | if ((pBeacon->proberesp_ies != NULL) && (pBeacon->proberesp_ies_len != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8738 | { |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8739 | u16 rem_probe_resp_ie_len = pBeacon->proberesp_ies_len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8740 | u8 probe_rsp_ie_len[3] = {0}; |
| 8741 | u8 counter = 0; |
| 8742 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 8743 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 8744 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 8745 | Store More then 255 bytes into One Variable. |
| 8746 | */ |
| 8747 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 8748 | { |
| 8749 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 8750 | { |
| 8751 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 8752 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 8753 | } |
| 8754 | else |
| 8755 | { |
| 8756 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 8757 | rem_probe_resp_ie_len = 0; |
| 8758 | } |
| 8759 | } |
| 8760 | |
| 8761 | rem_probe_resp_ie_len = 0; |
| 8762 | |
| 8763 | if (probe_rsp_ie_len[0] > 0) |
| 8764 | { |
| 8765 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8766 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8767 | (tANI_U8*)&pBeacon-> |
| 8768 | proberesp_ies[rem_probe_resp_ie_len], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8769 | probe_rsp_ie_len[0], NULL, |
| 8770 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 8771 | { |
| 8772 | hddLog(LOGE, |
| 8773 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8774 | ret = -EINVAL; |
| 8775 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8776 | } |
| 8777 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 8778 | } |
| 8779 | |
| 8780 | if (probe_rsp_ie_len[1] > 0) |
| 8781 | { |
| 8782 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8783 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8784 | (tANI_U8*)&pBeacon-> |
| 8785 | proberesp_ies[rem_probe_resp_ie_len], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8786 | probe_rsp_ie_len[1], NULL, |
| 8787 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 8788 | { |
| 8789 | hddLog(LOGE, |
| 8790 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8791 | ret = -EINVAL; |
| 8792 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8793 | } |
| 8794 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 8795 | } |
| 8796 | |
| 8797 | if (probe_rsp_ie_len[2] > 0) |
| 8798 | { |
| 8799 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8800 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8801 | (tANI_U8*)&pBeacon-> |
| 8802 | proberesp_ies[rem_probe_resp_ie_len], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8803 | probe_rsp_ie_len[2], NULL, |
| 8804 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 8805 | { |
| 8806 | hddLog(LOGE, |
| 8807 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8808 | ret = -EINVAL; |
| 8809 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8810 | } |
| 8811 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 8812 | } |
| 8813 | |
| 8814 | if (probe_rsp_ie_len[1] == 0 ) |
| 8815 | { |
| 8816 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8817 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 8818 | eANI_BOOLEAN_FALSE) ) |
| 8819 | { |
| 8820 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8821 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8822 | } |
| 8823 | } |
| 8824 | |
| 8825 | if (probe_rsp_ie_len[2] == 0 ) |
| 8826 | { |
| 8827 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8828 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 8829 | eANI_BOOLEAN_FALSE) ) |
| 8830 | { |
| 8831 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8832 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8833 | } |
| 8834 | } |
| 8835 | |
| 8836 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8837 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 8838 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 8839 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 8840 | == eHAL_STATUS_FAILURE) |
| 8841 | { |
| 8842 | hddLog(LOGE, |
| 8843 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8844 | ret = -EINVAL; |
| 8845 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8846 | } |
| 8847 | } |
| 8848 | else |
| 8849 | { |
| 8850 | // Reset WNI_CFG_PROBE_RSP Flags |
| 8851 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 8852 | |
| 8853 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8854 | "%s: No Probe Response IE received in set beacon", |
| 8855 | __func__); |
| 8856 | } |
| 8857 | |
| 8858 | // Added for AssocResp IE |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8859 | if ((pBeacon->assocresp_ies != NULL) && (pBeacon->assocresp_ies_len != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8860 | { |
| 8861 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 8862 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)pBeacon->assocresp_ies, |
| 8863 | pBeacon->assocresp_ies_len, NULL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8864 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 8865 | { |
| 8866 | hddLog(LOGE, |
| 8867 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8868 | ret = -EINVAL; |
| 8869 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8870 | } |
| 8871 | |
| 8872 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8873 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 8874 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 8875 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 8876 | == eHAL_STATUS_FAILURE) |
| 8877 | { |
| 8878 | hddLog(LOGE, |
| 8879 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8880 | ret = -EINVAL; |
| 8881 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8882 | } |
| 8883 | } |
| 8884 | else |
| 8885 | { |
| 8886 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8887 | "%s: No Assoc Response IE received in set beacon", |
| 8888 | __func__); |
| 8889 | |
| 8890 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8891 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 8892 | eANI_BOOLEAN_FALSE) ) |
| 8893 | { |
| 8894 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8895 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8896 | } |
| 8897 | } |
| 8898 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8899 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8900 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 8901 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8902 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8903 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8904 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8905 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 8906 | * called by wlan_hdd_cfg80211_start_bss() and |
| 8907 | * wlan_hdd_cfg80211_set_channel() |
| 8908 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8909 | * channel list. |
| 8910 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 8911 | VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8912 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8913 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8914 | v_U32_t num_ch = 0; |
| 8915 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 8916 | u32 indx = 0; |
| 8917 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 8918 | v_U8_t fValidChannel = FALSE, count = 0; |
| 8919 | hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8920 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8921 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 8922 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 8923 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8924 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 8925 | /* Validate the channel */ |
| 8926 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8927 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 8928 | if ( channel == rfChannels[count].channelNum ) |
| 8929 | { |
| 8930 | fValidChannel = TRUE; |
| 8931 | break; |
| 8932 | } |
| 8933 | } |
| 8934 | if (fValidChannel != TRUE) |
| 8935 | { |
| 8936 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8937 | "%s: Invalid Channel [%d]", __func__, channel); |
| 8938 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8939 | } |
| 8940 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 8941 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8942 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 8943 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 8944 | valid_ch, &num_ch)) |
| 8945 | { |
| 8946 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8947 | "%s: failed to get valid channel list", __func__); |
| 8948 | return VOS_STATUS_E_FAILURE; |
| 8949 | } |
| 8950 | for (indx = 0; indx < num_ch; indx++) |
| 8951 | { |
| 8952 | if (channel == valid_ch[indx]) |
| 8953 | { |
| 8954 | break; |
| 8955 | } |
| 8956 | } |
| 8957 | |
Rashmi Ramanna | 3b59e12 | 2014-04-10 14:45:13 +0530 | [diff] [blame] | 8958 | if (indx >= num_ch) |
| 8959 | { |
| 8960 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 8961 | { |
| 8962 | eCsrBand band; |
| 8963 | unsigned int freq; |
| 8964 | |
| 8965 | sme_GetFreqBand(hHal, &band); |
| 8966 | |
| 8967 | if (eCSR_BAND_5G == band) |
| 8968 | { |
| 8969 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 8970 | if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 8971 | { |
| 8972 | freq = ieee80211_channel_to_frequency(channel, |
| 8973 | IEEE80211_BAND_2GHZ); |
| 8974 | } |
| 8975 | else |
| 8976 | { |
| 8977 | freq = ieee80211_channel_to_frequency(channel, |
| 8978 | IEEE80211_BAND_5GHZ); |
| 8979 | } |
| 8980 | #else |
| 8981 | freq = ieee80211_channel_to_frequency(channel); |
| 8982 | #endif |
| 8983 | if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq)) |
| 8984 | return VOS_STATUS_SUCCESS; |
| 8985 | } |
| 8986 | } |
| 8987 | |
| 8988 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8989 | "%s: Invalid Channel [%d]", __func__, channel); |
| 8990 | return VOS_STATUS_E_FAILURE; |
| 8991 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8992 | } |
Rashmi Ramanna | 3b59e12 | 2014-04-10 14:45:13 +0530 | [diff] [blame] | 8993 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8994 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8995 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8996 | } |
| 8997 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 8998 | /** |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 8999 | * FUNCTION: __wlan_hdd_cfg80211_set_channel |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9000 | * This function is used to set the channel number |
| 9001 | */ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 9002 | static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9003 | struct ieee80211_channel *chan, |
| 9004 | enum nl80211_channel_type channel_type |
| 9005 | ) |
| 9006 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9007 | hdd_adapter_t *pAdapter = NULL; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9008 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 9009 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9010 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9011 | hdd_context_t *pHddCtx; |
| 9012 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9013 | |
| 9014 | ENTER(); |
| 9015 | |
| 9016 | if( NULL == dev ) |
| 9017 | { |
| 9018 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9019 | "%s: Called with dev = NULL.", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9020 | return -ENODEV; |
| 9021 | } |
| 9022 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9023 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9024 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9025 | TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId, |
| 9026 | channel_type )); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9027 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 9028 | "%s: device_mode = %s (%d) freq = %d", __func__, |
| 9029 | hdd_device_modetoString(pAdapter->device_mode), |
| 9030 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9031 | |
| 9032 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9033 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9034 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9035 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9036 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9037 | } |
| 9038 | |
| 9039 | /* |
| 9040 | * Do freq to chan conversion |
| 9041 | * TODO: for 11a |
| 9042 | */ |
| 9043 | |
| 9044 | channel = ieee80211_frequency_to_channel(freq); |
| 9045 | |
| 9046 | /* Check freq range */ |
| 9047 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 9048 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 9049 | { |
| 9050 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9051 | "%s: Channel [%d] is outside valid range from %d to %d", |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9052 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 9053 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 9054 | return -EINVAL; |
| 9055 | } |
| 9056 | |
| 9057 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 9058 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 9059 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 9060 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9061 | { |
| 9062 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 9063 | { |
| 9064 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9065 | "%s: Invalid Channel [%d]", __func__, channel); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9066 | return -EINVAL; |
| 9067 | } |
| 9068 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 9069 | "%s: set channel to [%d] for device mode =%d", |
| 9070 | __func__, channel,pAdapter->device_mode); |
| 9071 | } |
| 9072 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9073 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9074 | ) |
| 9075 | { |
| 9076 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9077 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 9078 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9079 | |
| 9080 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 9081 | { |
| 9082 | /* Link is up then return cant set channel*/ |
| 9083 | hddLog( VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9084 | "%s: IBSS Associated, can't set the channel", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9085 | return -EINVAL; |
| 9086 | } |
| 9087 | |
| 9088 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 9089 | pHddStaCtx->conn_info.operationChannel = channel; |
| 9090 | pRoamProfile->ChannelInfo.ChannelList = |
| 9091 | &pHddStaCtx->conn_info.operationChannel; |
| 9092 | } |
| 9093 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9094 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9095 | ) |
| 9096 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 9097 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 9098 | { |
| 9099 | if(VOS_STATUS_SUCCESS != |
| 9100 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 9101 | { |
| 9102 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9103 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 9104 | return -EINVAL; |
| 9105 | } |
| 9106 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 9107 | } |
| 9108 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9109 | { |
| 9110 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 9111 | |
| 9112 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 9113 | channel set by supplicant |
| 9114 | */ |
| 9115 | if ( cfg_param->apAutoChannelSelection ) |
| 9116 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 9117 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 9118 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9119 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 9120 | "%s: set channel to auto channel (0) for device mode =%s (%d)", |
| 9121 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 9122 | pAdapter->device_mode); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9123 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 9124 | else |
| 9125 | { |
| 9126 | if(VOS_STATUS_SUCCESS != |
| 9127 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 9128 | { |
| 9129 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9130 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 9131 | return -EINVAL; |
| 9132 | } |
| 9133 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 9134 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9135 | } |
| 9136 | } |
| 9137 | else |
| 9138 | { |
| 9139 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9140 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 9141 | return -EINVAL; |
| 9142 | } |
| 9143 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9144 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 9145 | } |
| 9146 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 9147 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, |
| 9148 | struct net_device *dev, |
| 9149 | struct ieee80211_channel *chan, |
| 9150 | enum nl80211_channel_type channel_type |
| 9151 | ) |
| 9152 | { |
| 9153 | int ret; |
| 9154 | |
| 9155 | vos_ssr_protect(__func__); |
| 9156 | ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type); |
| 9157 | vos_ssr_unprotect(__func__); |
| 9158 | |
| 9159 | return ret; |
| 9160 | } |
| 9161 | |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9162 | #ifdef DHCP_SERVER_OFFLOAD |
| 9163 | void hdd_dhcp_server_offload_done(void *fw_dhcp_srv_offload_cb_context, |
| 9164 | VOS_STATUS status) |
| 9165 | { |
| 9166 | hdd_adapter_t* adapter = (hdd_adapter_t*)fw_dhcp_srv_offload_cb_context; |
| 9167 | |
| 9168 | ENTER(); |
| 9169 | |
| 9170 | if (NULL == adapter) |
| 9171 | { |
| 9172 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9173 | "%s: adapter is NULL",__func__); |
| 9174 | return; |
| 9175 | } |
| 9176 | |
| 9177 | adapter->dhcp_status.dhcp_offload_status = status; |
| 9178 | vos_event_set(&adapter->dhcp_status.vos_event); |
| 9179 | return; |
| 9180 | } |
| 9181 | |
| 9182 | /** |
| 9183 | * wlan_hdd_set_dhcp_server_offload() - set dhcp server offload |
| 9184 | * @hostapd_adapter: pointer to hostapd adapter. |
Anurag Chouhan | 638f5e2 | 2017-03-06 12:28:43 +0530 | [diff] [blame] | 9185 | * @re_init: flag set if api called post ssr |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9186 | * |
| 9187 | * Return: None |
| 9188 | */ |
Anurag Chouhan | 638f5e2 | 2017-03-06 12:28:43 +0530 | [diff] [blame] | 9189 | VOS_STATUS wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *hostapd_adapter, |
| 9190 | bool re_init) |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9191 | { |
| 9192 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter); |
| 9193 | sir_dhcp_srv_offload_info dhcp_srv_info; |
| 9194 | tANI_U8 num_entries = 0; |
| 9195 | tANI_U8 srv_ip[IPADDR_NUM_ENTRIES]; |
| 9196 | tANI_U8 num; |
| 9197 | tANI_U32 temp; |
| 9198 | VOS_STATUS ret; |
| 9199 | |
| 9200 | ENTER(); |
| 9201 | |
Anurag Chouhan | 638f5e2 | 2017-03-06 12:28:43 +0530 | [diff] [blame] | 9202 | if (!re_init) { |
| 9203 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9204 | if (0 != ret) |
| 9205 | return VOS_STATUS_E_INVAL; |
| 9206 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9207 | |
| 9208 | /* Prepare the request to send to SME */ |
| 9209 | dhcp_srv_info = vos_mem_malloc(sizeof(*dhcp_srv_info)); |
| 9210 | if (NULL == dhcp_srv_info) { |
| 9211 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9212 | "%s: could not allocate tDhcpSrvOffloadInfo!", __func__); |
| 9213 | return VOS_STATUS_E_NOMEM; |
| 9214 | } |
| 9215 | |
| 9216 | vos_mem_zero(dhcp_srv_info, sizeof(*dhcp_srv_info)); |
| 9217 | |
| 9218 | dhcp_srv_info->bssidx = hostapd_adapter->sessionId; |
| 9219 | dhcp_srv_info->dhcp_srv_offload_enabled = TRUE; |
| 9220 | dhcp_srv_info->dhcp_client_num = hdd_ctx->cfg_ini->dhcp_max_num_clients; |
| 9221 | dhcp_srv_info->start_lsb = hdd_ctx->cfg_ini->dhcp_start_lsb; |
| 9222 | dhcp_srv_info->dhcp_offload_callback = hdd_dhcp_server_offload_done; |
| 9223 | dhcp_srv_info->dhcp_server_offload_cb_context = hostapd_adapter; |
| 9224 | |
| 9225 | hdd_string_to_u8_array(hdd_ctx->cfg_ini->dhcp_srv_ip, |
| 9226 | srv_ip, |
| 9227 | &num_entries, |
Anurag Chouhan | ac145c2 | 2016-11-22 16:51:47 +0530 | [diff] [blame] | 9228 | IPADDR_NUM_ENTRIES, "."); |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9229 | if (num_entries != IPADDR_NUM_ENTRIES) { |
| 9230 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9231 | "%s: incorrect IP address (%s) assigned for DHCP server!", |
| 9232 | __func__, hdd_ctx->cfg_ini->dhcp_srv_ip); |
| 9233 | vos_mem_free(dhcp_srv_info); |
| 9234 | return VOS_STATUS_E_FAILURE; |
| 9235 | } |
| 9236 | |
| 9237 | if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) { |
| 9238 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9239 | "%s: invalid IP address (%s)! It could NOT be multicast IP address!", |
| 9240 | __func__, hdd_ctx->cfg_ini->dhcp_srv_ip); |
| 9241 | vos_mem_free(dhcp_srv_info); |
| 9242 | return VOS_STATUS_E_FAILURE; |
| 9243 | } |
| 9244 | |
| 9245 | if (srv_ip[IPADDR_NUM_ENTRIES-1] >= DHCP_START_POOL_ADDRESS) { |
| 9246 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9247 | "%s: invalid IP address (%s)! The last field must be less than 100!", |
| 9248 | __func__, hdd_ctx->cfg_ini->dhcp_srv_ip); |
| 9249 | vos_mem_free(dhcp_srv_info); |
| 9250 | return VOS_STATUS_E_FAILURE; |
| 9251 | } |
| 9252 | |
| 9253 | for (num = 0; num < num_entries; num++) { |
| 9254 | temp = srv_ip[num]; |
| 9255 | dhcp_srv_info->dhcp_srv_ip |= (temp << (8 * num)); |
| 9256 | } |
| 9257 | |
| 9258 | if (eHAL_STATUS_SUCCESS != |
| 9259 | sme_set_dhcp_srv_offload(hdd_ctx->hHal, dhcp_srv_info)) { |
| 9260 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9261 | "%s: sme_set_dhcp_srv_offload fail!", __func__); |
| 9262 | vos_mem_free(dhcp_srv_info); |
| 9263 | return VOS_STATUS_E_FAILURE; |
| 9264 | } |
| 9265 | |
| 9266 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 9267 | "%s: enable DHCP Server offload successfully!", __func__); |
| 9268 | |
| 9269 | vos_mem_free(dhcp_srv_info); |
| 9270 | return 0; |
| 9271 | } |
| 9272 | #endif /* DHCP_SERVER_OFFLOAD */ |
| 9273 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9274 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 9275 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 9276 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9277 | #else |
| 9278 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 9279 | struct cfg80211_beacon_data *params, |
| 9280 | const u8 *ssid, size_t ssid_len, |
Kanchanapally, Vidyullatha | acc5925 | 2015-05-20 16:49:07 +0530 | [diff] [blame] | 9281 | enum nl80211_hidden_ssid hidden_ssid, |
| 9282 | v_U8_t auth_type) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9283 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9284 | { |
| 9285 | tsap_Config_t *pConfig; |
| 9286 | beacon_data_t *pBeacon = NULL; |
| 9287 | struct ieee80211_mgmt *pMgmt_frame; |
| 9288 | v_U8_t *pIe=NULL; |
| 9289 | v_U16_t capab_info; |
| 9290 | eCsrAuthType RSNAuthType; |
| 9291 | eCsrEncryptionType RSNEncryptType; |
| 9292 | eCsrEncryptionType mcRSNEncryptType; |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9293 | int status = VOS_STATUS_SUCCESS, ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9294 | tpWLAN_SAPEventCB pSapEventCallback; |
| 9295 | hdd_hostapd_state_t *pHostapdState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9296 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 9297 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9298 | struct qc_mac_acl_entry *acl_entry = NULL; |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 9299 | hdd_config_t *iniConfig; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9300 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 9301 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 9302 | tSmeConfigParams *psmeConfig; |
Chet Lanctot | 4014244 | 2014-05-20 13:39:25 -0700 | [diff] [blame] | 9303 | v_BOOL_t MFPCapable = VOS_FALSE; |
| 9304 | v_BOOL_t MFPRequired = VOS_FALSE; |
Sushant Kaushik | 7dc0327 | 2015-02-18 11:25:12 +0530 | [diff] [blame] | 9305 | v_BOOL_t sapEnable11AC = |
| 9306 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9307 | u_int16_t prev_rsn_length = 0; |
| 9308 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9309 | ENTER(); |
| 9310 | |
Nitesh Shah | 9b06628 | 2017-06-06 18:05:52 +0530 | [diff] [blame] | 9311 | wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx); |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 9312 | iniConfig = pHddCtx->cfg_ini; |
| 9313 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9314 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 9315 | |
| 9316 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 9317 | |
| 9318 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 9319 | |
| 9320 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 9321 | |
| 9322 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 9323 | |
| 9324 | //channel is already set in the set_channel Call back |
| 9325 | //pConfig->channel = pCommitConfig->channel; |
| 9326 | |
| 9327 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9328 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9329 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 9330 | |
| 9331 | pConfig->dtim_period = pBeacon->dtim_period; |
| 9332 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9333 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9334 | pConfig->dtim_period); |
| 9335 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 9336 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9337 | { |
| 9338 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9339 | WLAN_EID_COUNTRY); |
Kiet Lam | 083504c | 2013-11-25 14:17:45 +0530 | [diff] [blame] | 9340 | if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0) |
| 9341 | { |
| 9342 | tANI_BOOLEAN restartNeeded; |
| 9343 | pConfig->ieee80211d = 1; |
| 9344 | vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3); |
| 9345 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 9346 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
| 9347 | } |
| 9348 | else if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9349 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9350 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9351 | pConfig->ieee80211d = 1; |
| 9352 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 9353 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 9354 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9355 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9356 | else |
| 9357 | { |
| 9358 | pConfig->ieee80211d = 0; |
| 9359 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 9360 | /* |
| 9361 | * If auto channel is configured i.e. channel is 0, |
| 9362 | * so skip channel validation. |
| 9363 | */ |
| 9364 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 9365 | { |
| 9366 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 9367 | { |
| 9368 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9369 | "%s: Invalid Channel [%d]", __func__, pConfig->channel); |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 9370 | return -EINVAL; |
| 9371 | } |
| 9372 | } |
| 9373 | else |
| 9374 | { |
| 9375 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 9376 | { |
| 9377 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 9378 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 9379 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 9380 | } |
| 9381 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 9382 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9383 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9384 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9385 | { |
| 9386 | pConfig->ieee80211d = 0; |
| 9387 | } |
Kanchanapally, Vidyullatha | acc5925 | 2015-05-20 16:49:07 +0530 | [diff] [blame] | 9388 | |
| 9389 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 9390 | if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) |
| 9391 | pConfig->authType = eSAP_OPEN_SYSTEM; |
| 9392 | else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY) |
| 9393 | pConfig->authType = eSAP_SHARED_KEY; |
| 9394 | else |
| 9395 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 9396 | #else |
| 9397 | if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) |
| 9398 | pConfig->authType = eSAP_OPEN_SYSTEM; |
| 9399 | else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY) |
| 9400 | pConfig->authType = eSAP_SHARED_KEY; |
| 9401 | else |
| 9402 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 9403 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9404 | |
| 9405 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9406 | |
| 9407 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9408 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 9409 | #ifdef SAP_AUTH_OFFLOAD |
| 9410 | /* In case of sap offload, hostapd.conf is configuted with open mode and |
| 9411 | * security is configured from ini file. Due to open mode in hostapd.conf |
| 9412 | * privacy bit is set to false which will result in not sending, |
| 9413 | * data packets as encrypted. |
| 9414 | * If enable_sap_auth_offload is enabled in ini and |
| 9415 | * sap_auth_offload_sec_type is type of WPA2-PSK, |
| 9416 | * driver will set privacy bit to 1. |
| 9417 | */ |
| 9418 | if (pHddCtx->cfg_ini->enable_sap_auth_offload && |
| 9419 | pHddCtx->cfg_ini->sap_auth_offload_sec_type) |
| 9420 | pConfig->privacy = VOS_TRUE; |
| 9421 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9422 | |
| 9423 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 9424 | |
| 9425 | /*Set wps station to configured*/ |
| 9426 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 9427 | |
| 9428 | if(pIe) |
| 9429 | { |
| 9430 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 9431 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9432 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9433 | return -EINVAL; |
| 9434 | } |
| 9435 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 9436 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 9437 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9438 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 9439 | * WPS state |
| 9440 | */ |
| 9441 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 9442 | { |
| 9443 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 9444 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 9445 | { |
| 9446 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 9447 | } |
| 9448 | } |
| 9449 | } |
| 9450 | else |
| 9451 | { |
| 9452 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 9453 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9454 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9455 | |
c_hpothu | fe599e9 | 2014-06-16 11:38:55 +0530 | [diff] [blame] | 9456 | pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE; |
| 9457 | pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE; |
| 9458 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType = |
| 9459 | eCSR_ENCRYPT_TYPE_NONE; |
| 9460 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9461 | pConfig->RSNWPAReqIELength = 0; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9462 | memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9463 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9464 | WLAN_EID_RSN); |
| 9465 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9466 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9467 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9468 | if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE)) |
| 9469 | memcpy(&pConfig->RSNWPAReqIE[0], pIe, |
| 9470 | pConfig->RSNWPAReqIELength); |
| 9471 | else |
| 9472 | hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d", |
| 9473 | pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9474 | /* The actual processing may eventually be more extensive than |
| 9475 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9476 | * by the app. |
| 9477 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9478 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9479 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 9480 | &RSNEncryptType, |
| 9481 | &mcRSNEncryptType, |
| 9482 | &RSNAuthType, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 9483 | &MFPCapable, |
| 9484 | &MFPRequired, |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9485 | pConfig->RSNWPAReqIE[1]+2, |
| 9486 | pConfig->RSNWPAReqIE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9487 | |
| 9488 | if( VOS_STATUS_SUCCESS == status ) |
| 9489 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9490 | /* Now copy over all the security attributes you have |
| 9491 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9492 | * */ |
| 9493 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 9494 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 9495 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 9496 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9497 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9498 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9499 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 9500 | } |
| 9501 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9502 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9503 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 9504 | pBeacon->tail, pBeacon->tail_len); |
| 9505 | |
| 9506 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 9507 | { |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9508 | if (pConfig->RSNWPAReqIE[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9509 | { |
| 9510 | /*Mixed mode WPA/WPA2*/ |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9511 | prev_rsn_length = pConfig->RSNWPAReqIELength; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9512 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9513 | if (pConfig->RSNWPAReqIELength <= |
| 9514 | (sizeof(pConfig->RSNWPAReqIE) - prev_rsn_length)) |
| 9515 | memcpy(&pConfig->RSNWPAReqIE[0] + prev_rsn_length, pIe, |
| 9516 | pIe[1] + 2); |
| 9517 | else |
| 9518 | hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d", |
| 9519 | pConfig->RSNWPAReqIELength); |
| 9520 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9521 | } |
| 9522 | else |
| 9523 | { |
| 9524 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9525 | if (pConfig->RSNWPAReqIELength <= sizeof(pConfig->RSNWPAReqIE)) |
| 9526 | memcpy(&pConfig->RSNWPAReqIE[0], pIe, |
| 9527 | pConfig->RSNWPAReqIELength); |
| 9528 | else |
| 9529 | hddLog(LOGE, "RSNWPA IE MAX Length exceeded; length =%d", |
| 9530 | pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9531 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9532 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 9533 | &RSNEncryptType, |
| 9534 | &mcRSNEncryptType, |
| 9535 | &RSNAuthType, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 9536 | &MFPCapable, |
| 9537 | &MFPRequired, |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9538 | pConfig->RSNWPAReqIE[1]+2, |
| 9539 | pConfig->RSNWPAReqIE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9540 | |
| 9541 | if( VOS_STATUS_SUCCESS == status ) |
| 9542 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9543 | /* Now copy over all the security attributes you have |
| 9544 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9545 | * */ |
| 9546 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 9547 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 9548 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 9549 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9550 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9551 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9552 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 9553 | } |
| 9554 | } |
| 9555 | } |
| 9556 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9557 | if (pConfig->RSNWPAReqIELength > sizeof(pConfig->RSNWPAReqIE)) { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 9558 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 9559 | return -EINVAL; |
| 9560 | } |
| 9561 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9562 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 9563 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9564 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9565 | if (params->ssid != NULL) |
| 9566 | { |
| 9567 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 9568 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 9569 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 9570 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 9571 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9572 | #else |
| 9573 | if (ssid != NULL) |
| 9574 | { |
| 9575 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 9576 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 9577 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 9578 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 9579 | } |
| 9580 | #endif |
| 9581 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9582 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9583 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9584 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9585 | /* default value */ |
| 9586 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 9587 | pConfig->num_accept_mac = 0; |
| 9588 | pConfig->num_deny_mac = 0; |
| 9589 | |
| 9590 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 9591 | pBeacon->tail, pBeacon->tail_len); |
| 9592 | |
| 9593 | /* pIe for black list is following form: |
| 9594 | type : 1 byte |
| 9595 | length : 1 byte |
| 9596 | OUI : 4 bytes |
| 9597 | acl type : 1 byte |
| 9598 | no of mac addr in black list: 1 byte |
| 9599 | list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9600 | */ |
| 9601 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9602 | { |
| 9603 | pConfig->SapMacaddr_acl = pIe[6]; |
| 9604 | pConfig->num_deny_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9605 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9606 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9607 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 9608 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9609 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 9610 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 9611 | { |
| 9612 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 9613 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9614 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9615 | } |
| 9616 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 9617 | pBeacon->tail, pBeacon->tail_len); |
| 9618 | |
| 9619 | /* pIe for white list is following form: |
| 9620 | type : 1 byte |
| 9621 | length : 1 byte |
| 9622 | OUI : 4 bytes |
| 9623 | acl type : 1 byte |
| 9624 | no of mac addr in white list: 1 byte |
| 9625 | list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9626 | */ |
| 9627 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9628 | { |
| 9629 | pConfig->SapMacaddr_acl = pIe[6]; |
| 9630 | pConfig->num_accept_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9631 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9632 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9633 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 9634 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9635 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 9636 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 9637 | { |
| 9638 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 9639 | acl_entry++; |
| 9640 | } |
| 9641 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9642 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9643 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 9644 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9645 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 9646 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
Sushant Kaushik | 7dc0327 | 2015-02-18 11:25:12 +0530 | [diff] [blame] | 9647 | * This is valid only if mode is set to 11n in hostapd, sapEnable11AC |
| 9648 | * is set in .ini and 11ac is supported by both host and firmware. |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 9649 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) |
| 9650 | */ |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 9651 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 9652 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Sushant Kaushik | 7dc0327 | 2015-02-18 11:25:12 +0530 | [diff] [blame] | 9653 | (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) && |
| 9654 | (sme_IsFeatureSupportedByFW(DOT11AC)) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9655 | { |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 9656 | v_U32_t operatingBand = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9657 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 9658 | ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand); |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 9659 | |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 9660 | /* If ACS disable and selected channel <= 14 |
| 9661 | * OR |
| 9662 | * ACS enabled and ACS operating band is choosen as 2.4 |
| 9663 | * AND |
| 9664 | * VHT in 2.4G Disabled |
| 9665 | * THEN |
| 9666 | * Fallback to 11N mode |
| 9667 | */ |
| 9668 | if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END) |
| 9669 | || (AUTO_CHANNEL_SELECT == pConfig->channel && |
Deepthi Gowri | 7db41f3 | 2014-10-13 17:02:29 +0530 | [diff] [blame] | 9670 | operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) && |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 9671 | iniConfig->enableVhtFor24GHzBand == FALSE) |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 9672 | { |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 9673 | hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"), |
| 9674 | operatingBand, pConfig->channel); |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 9675 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 9676 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9677 | } |
| 9678 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9679 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9680 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 9681 | pConfig->ht_capab = |
| 9682 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 9683 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 9684 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9685 | { |
| 9686 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 9687 | return -EINVAL; |
| 9688 | } |
| 9689 | |
| 9690 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9691 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9692 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 9693 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9694 | pConfig->obssProtEnabled = |
| 9695 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9696 | |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 9697 | #ifdef WLAN_FEATURE_11W |
| 9698 | pConfig->mfpCapable = MFPCapable; |
| 9699 | pConfig->mfpRequired = MFPRequired; |
| 9700 | hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"), |
| 9701 | pConfig->mfpCapable, pConfig->mfpRequired); |
| 9702 | #endif |
| 9703 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9704 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9705 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9706 | hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"), |
| 9707 | pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int, |
| 9708 | (int)pConfig->channel); |
| 9709 | hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"), |
| 9710 | pConfig->SapHw_mode, pConfig->privacy, |
| 9711 | pConfig->authType); |
| 9712 | hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"), |
| 9713 | (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable); |
| 9714 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"), |
| 9715 | pConfig->protEnabled, pConfig->obssProtEnabled); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9716 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9717 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9718 | { |
| 9719 | //Bss already started. just return. |
| 9720 | //TODO Probably it should update some beacon params. |
| 9721 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 9722 | EXIT(); |
| 9723 | return 0; |
| 9724 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9725 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 9726 | if (vos_max_concurrent_connections_reached()) { |
| 9727 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 9728 | return -EINVAL; |
| 9729 | } |
| 9730 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9731 | pConfig->persona = pHostapdAdapter->device_mode; |
| 9732 | |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 9733 | psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams)); |
| 9734 | if ( NULL != psmeConfig) |
| 9735 | { |
Hardik Kantilal Patel | 086e0a3 | 2014-11-20 14:56:26 +0530 | [diff] [blame] | 9736 | vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams)); |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 9737 | sme_GetConfigParam(hHal, psmeConfig); |
| 9738 | pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference; |
Hardik Kantilal Patel | 086e0a3 | 2014-11-20 14:56:26 +0530 | [diff] [blame] | 9739 | #ifdef WLAN_FEATURE_AP_HT40_24G |
| 9740 | if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 9741 | || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 9742 | && pHddCtx->cfg_ini->apHT40_24GEnabled) |
| 9743 | { |
| 9744 | psmeConfig->csrConfig.apHT40_24GEnabled = 1; |
| 9745 | sme_UpdateConfig (hHal, psmeConfig); |
| 9746 | } |
| 9747 | #endif |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 9748 | vos_mem_free(psmeConfig); |
| 9749 | } |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 9750 | pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold; |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 9751 | |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9752 | set_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags); |
| 9753 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9754 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 9755 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 9756 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 9757 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9758 | hddLog(LOGE,FL("SAP Start Bss fail")); |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9759 | ret = -EINVAL; |
| 9760 | goto error; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9761 | } |
| 9762 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9763 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9764 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 9765 | |
| 9766 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9768 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9769 | { |
| 9770 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9771 | ("ERROR: HDD vos wait for single_event failed!!")); |
Tushnim Bhattacharyya | ad37df1 | 2013-10-02 12:01:33 -0700 | [diff] [blame] | 9772 | smeGetCommandQStatus(hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9773 | VOS_ASSERT(0); |
| 9774 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9775 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9776 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
Nishank Aggarwal | c11826c | 2016-12-15 18:54:10 +0530 | [diff] [blame] | 9777 | if (WLANSAP_get_sessionId(pVosContext, &pHostapdAdapter->sessionId) != |
| 9778 | VOS_STATUS_SUCCESS) |
| 9779 | { |
| 9780 | hddLog(LOGE,FL("Fail to get Softap sessionID")); |
| 9781 | VOS_ASSERT(0); |
| 9782 | } |
Kaushik, Sushant | f607080 | 2014-10-15 15:09:23 +0530 | [diff] [blame] | 9783 | /* Initialize WMM configuation */ |
| 9784 | hdd_wmm_init(pHostapdAdapter); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 9785 | wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9786 | |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9787 | #ifdef DHCP_SERVER_OFFLOAD |
| 9788 | /* set dhcp server offload */ |
| 9789 | if (iniConfig->enable_dhcp_srv_offload && |
| 9790 | sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) { |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9791 | vos_event_reset(&pHostapdAdapter->dhcp_status.vos_event); |
Anurag Chouhan | 638f5e2 | 2017-03-06 12:28:43 +0530 | [diff] [blame] | 9792 | status = wlan_hdd_set_dhcp_server_offload(pHostapdAdapter, false); |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9793 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9794 | { |
| 9795 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9796 | ("HDD DHCP Server Offload Failed!!")); |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9797 | vos_event_reset(&pHostapdState->vosEvent); |
| 9798 | if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 9799 | status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 9800 | 10000); |
| 9801 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9802 | hddLog(LOGE, FL("SAP Stop Failed")); |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9803 | ret = -EINVAL; |
| 9804 | goto error; |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9805 | } |
| 9806 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9807 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9808 | status = vos_wait_single_event(&pHostapdAdapter->dhcp_status.vos_event, 2000); |
| 9809 | if (!VOS_IS_STATUS_SUCCESS(status) || pHostapdAdapter->dhcp_status.dhcp_offload_status) |
| 9810 | { |
| 9811 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9812 | ("ERROR: DHCP HDD vos wait for single_event failed!! %d"), |
| 9813 | pHostapdAdapter->dhcp_status.dhcp_offload_status); |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9814 | vos_event_reset(&pHostapdState->vosEvent); |
| 9815 | if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 9816 | status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 9817 | 10000); |
| 9818 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9819 | hddLog(LOGE, FL("SAP Stop Failed")); |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9820 | ret = -EINVAL; |
| 9821 | goto error; |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9822 | } |
| 9823 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9824 | } |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 9825 | #ifdef MDNS_OFFLOAD |
| 9826 | if (iniConfig->enable_mdns_offload) { |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9827 | vos_event_reset(&pHostapdAdapter->mdns_status.vos_event); |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 9828 | status = wlan_hdd_set_mdns_offload(pHostapdAdapter); |
| 9829 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 9830 | { |
| 9831 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9832 | ("HDD MDNS Server Offload Failed!!")); |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9833 | vos_event_reset(&pHostapdState->vosEvent); |
| 9834 | if (VOS_STATUS_SUCCESS == |
| 9835 | WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 9836 | status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 9837 | 10000); |
| 9838 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9839 | hddLog(LOGE, FL("SAP Stop Failed")); |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9840 | ret = -EINVAL; |
| 9841 | goto error; |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9842 | } |
| 9843 | } |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 9844 | } |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 9845 | status = vos_wait_single_event(&pHostapdAdapter-> |
| 9846 | mdns_status.vos_event, 2000); |
| 9847 | if (!VOS_IS_STATUS_SUCCESS(status) || |
| 9848 | pHostapdAdapter->mdns_status.mdns_enable_status || |
| 9849 | pHostapdAdapter->mdns_status.mdns_fqdn_status || |
| 9850 | pHostapdAdapter->mdns_status.mdns_resp_status) |
| 9851 | { |
| 9852 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9853 | ("MDNS HDD vos wait for single_event failed!! enable %d fqdn %d resp %d"), |
| 9854 | pHostapdAdapter->mdns_status.mdns_enable_status, |
| 9855 | pHostapdAdapter->mdns_status.mdns_fqdn_status, |
| 9856 | pHostapdAdapter->mdns_status.mdns_resp_status); |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9857 | vos_event_reset(&pHostapdState->vosEvent); |
| 9858 | if (VOS_STATUS_SUCCESS == |
| 9859 | WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 9860 | status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 9861 | 10000); |
| 9862 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9863 | hddLog(LOGE, FL("SAP Stop Failed")); |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9864 | ret = -EINVAL; |
| 9865 | goto error; |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 9866 | } |
| 9867 | } |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 9868 | } |
| 9869 | } |
| 9870 | #endif /* MDNS_OFFLOAD */ |
| 9871 | } else { |
| 9872 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9873 | ("DHCP Disabled ini %d, FW %d"), |
| 9874 | iniConfig->enable_dhcp_srv_offload, |
| 9875 | sme_IsFeatureSupportedByFW(SAP_OFFLOADS)); |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9876 | } |
| 9877 | #endif /* DHCP_SERVER_OFFLOAD */ |
| 9878 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 9879 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 9880 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 9881 | { |
| 9882 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 9883 | { |
| 9884 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 9885 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 9886 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 9887 | } |
| 9888 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 9889 | { |
| 9890 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 9891 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 9892 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 9893 | } |
| 9894 | } |
| 9895 | #endif |
Ashish Kumar Dhanotiya | 42aa515 | 2017-01-03 20:25:57 +0530 | [diff] [blame] | 9896 | /* Check and restart SAP if it is on Unsafe channel */ |
| 9897 | hdd_check_for_unsafe_ch(pHostapdAdapter, pHddCtx); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 9898 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9899 | pHostapdState->bCommit = TRUE; |
| 9900 | EXIT(); |
| 9901 | |
| 9902 | return 0; |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 9903 | error: |
| 9904 | clear_bit(SOFTAP_INIT_DONE, &pHostapdAdapter->event_flags); |
| 9905 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9906 | } |
| 9907 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9908 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 9909 | static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9910 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9911 | struct beacon_parameters *params) |
| 9912 | { |
| 9913 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9914 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9915 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9916 | |
| 9917 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9918 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9919 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9920 | TRACE_CODE_HDD_CFG80211_ADD_BEACON, |
| 9921 | pAdapter->sessionId, params->interval)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 9922 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)", |
| 9923 | hdd_device_modetoString(pAdapter->device_mode), |
| 9924 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9925 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9926 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9927 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9928 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9929 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9930 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9931 | } |
| 9932 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 9933 | if (vos_max_concurrent_connections_reached()) { |
| 9934 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 9935 | return -EINVAL; |
| 9936 | } |
| 9937 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9938 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9939 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9940 | ) |
| 9941 | { |
| 9942 | beacon_data_t *old,*new; |
| 9943 | |
| 9944 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9945 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9946 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9947 | { |
| 9948 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 9949 | FL("already beacon info added to session(%d)"), |
| 9950 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9951 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9952 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9953 | |
| 9954 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 9955 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9956 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9957 | { |
| 9958 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9959 | "%s:Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9960 | return -EINVAL; |
| 9961 | } |
| 9962 | |
| 9963 | pAdapter->sessionCtx.ap.beacon = new; |
| 9964 | |
| 9965 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 9966 | } |
| 9967 | |
| 9968 | EXIT(); |
| 9969 | return status; |
| 9970 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9971 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 9972 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 9973 | struct net_device *dev, |
| 9974 | struct beacon_parameters *params) |
| 9975 | { |
| 9976 | int ret; |
| 9977 | |
| 9978 | vos_ssr_protect(__func__); |
| 9979 | ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params); |
| 9980 | vos_ssr_unprotect(__func__); |
| 9981 | |
| 9982 | return ret; |
| 9983 | } |
| 9984 | |
| 9985 | static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9986 | struct net_device *dev, |
| 9987 | struct beacon_parameters *params) |
| 9988 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9989 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9990 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9991 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9992 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9993 | |
| 9994 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 9995 | |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9996 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9997 | TRACE_CODE_HDD_CFG80211_SET_BEACON, |
| 9998 | pAdapter->sessionId, pHddStaCtx->conn_info.authType)); |
| 9999 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 10000 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10001 | pAdapter->device_mode); |
| 10002 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10003 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10004 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10005 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10006 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10007 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10008 | } |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10009 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10010 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10011 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10012 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10013 | { |
| 10014 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10015 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10016 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10017 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10018 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10019 | { |
| 10020 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10021 | FL("session(%d) old and new heads points to NULL"), |
| 10022 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10023 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10024 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10025 | |
| 10026 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 10027 | |
| 10028 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10029 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10030 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10031 | return -EINVAL; |
| 10032 | } |
| 10033 | |
| 10034 | pAdapter->sessionCtx.ap.beacon = new; |
| 10035 | |
| 10036 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 10037 | } |
| 10038 | |
| 10039 | EXIT(); |
| 10040 | return status; |
| 10041 | } |
| 10042 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10043 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
| 10044 | struct net_device *dev, |
| 10045 | struct beacon_parameters *params) |
| 10046 | { |
| 10047 | int ret; |
| 10048 | |
| 10049 | vos_ssr_protect(__func__); |
| 10050 | ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params); |
| 10051 | vos_ssr_unprotect(__func__); |
| 10052 | |
| 10053 | return ret; |
| 10054 | } |
| 10055 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10056 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 10057 | |
| 10058 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10059 | static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10060 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10061 | #else |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10062 | static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10063 | struct net_device *dev) |
| 10064 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10065 | { |
| 10066 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10067 | hdd_context_t *pHddCtx = NULL; |
| 10068 | hdd_scaninfo_t *pScanInfo = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10069 | VOS_STATUS status; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10070 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10071 | |
| 10072 | ENTER(); |
| 10073 | |
| 10074 | if (NULL == pAdapter) |
| 10075 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10076 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10077 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10078 | return -ENODEV; |
| 10079 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 10080 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10081 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10082 | TRACE_CODE_HDD_CFG80211_STOP_AP, |
| 10083 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10084 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10085 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10086 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 10087 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10088 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 10089 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 10090 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 10091 | pScanInfo = &pHddCtx->scan_info; |
| 10092 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10093 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 10094 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10095 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10096 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10097 | ret = wlan_hdd_scan_abort(pAdapter); |
| 10098 | |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10099 | if (ret < 0) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10100 | { |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10101 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10102 | FL("Timeout occurred while waiting for abortscan %ld"), ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10103 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10104 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10105 | { |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10106 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10107 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 10108 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10109 | VOS_ASSERT(pScanInfo->mScanPending); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10110 | return -EAGAIN; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10111 | } |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10112 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10113 | } |
| 10114 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10115 | /* Delete all associated STAs before stopping AP/P2P GO */ |
| 10116 | hdd_del_all_sta(pAdapter); |
Arun Kumar Khandavalli | a3bd800 | 2014-01-17 16:21:19 +0530 | [diff] [blame] | 10117 | hdd_hostapd_stop(dev); |
| 10118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10119 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10120 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10121 | ) |
| 10122 | { |
| 10123 | beacon_data_t *old; |
| 10124 | |
| 10125 | old = pAdapter->sessionCtx.ap.beacon; |
| 10126 | |
| 10127 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10128 | { |
| 10129 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10130 | FL("session(%d) beacon data points to NULL"), |
| 10131 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10132 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10133 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10134 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10135 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10136 | |
| 10137 | mutex_lock(&pHddCtx->sap_lock); |
| 10138 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10139 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 10140 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10141 | { |
| 10142 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 10143 | |
| 10144 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 10145 | |
| 10146 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 10147 | { |
| 10148 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10149 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10150 | VOS_ASSERT(0); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10151 | } |
| 10152 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10153 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10154 | /* BSS stopped, clear the active sessions for this device mode */ |
| 10155 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10156 | } |
| 10157 | mutex_unlock(&pHddCtx->sap_lock); |
| 10158 | |
| 10159 | if(status != VOS_STATUS_SUCCESS) |
| 10160 | { |
| 10161 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10162 | "%s:Error!!! Stopping the BSS",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10163 | return -EINVAL; |
| 10164 | } |
| 10165 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 10166 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10167 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 10168 | ==eHAL_STATUS_FAILURE) |
| 10169 | { |
| 10170 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10171 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10172 | } |
| 10173 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 10174 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10175 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 10176 | eANI_BOOLEAN_FALSE) ) |
| 10177 | { |
| 10178 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10179 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10180 | } |
| 10181 | |
| 10182 | // Reset WNI_CFG_PROBE_RSP Flags |
| 10183 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 10184 | |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 10185 | clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags); |
| 10186 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10187 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 10188 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 10189 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 10190 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 10191 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 10192 | { |
| 10193 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 10194 | "GO got removed"); |
| 10195 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 10196 | } |
| 10197 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10198 | } |
| 10199 | EXIT(); |
| 10200 | return status; |
| 10201 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10202 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10203 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 10204 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 10205 | struct net_device *dev) |
| 10206 | { |
| 10207 | int ret; |
| 10208 | |
| 10209 | vos_ssr_protect(__func__); |
| 10210 | ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev); |
| 10211 | vos_ssr_unprotect(__func__); |
| 10212 | |
| 10213 | return ret; |
| 10214 | } |
| 10215 | #else |
| 10216 | static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, |
| 10217 | struct net_device *dev) |
| 10218 | { |
| 10219 | int ret; |
| 10220 | |
| 10221 | vos_ssr_protect(__func__); |
| 10222 | ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev); |
| 10223 | vos_ssr_unprotect(__func__); |
| 10224 | |
| 10225 | return ret; |
| 10226 | } |
| 10227 | #endif |
| 10228 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10229 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 10230 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10231 | static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10232 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10233 | struct cfg80211_ap_settings *params) |
| 10234 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10235 | hdd_adapter_t *pAdapter; |
| 10236 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10237 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10238 | |
| 10239 | ENTER(); |
| 10240 | |
Girish Gowli | b143d7a | 2015-02-18 19:39:55 +0530 | [diff] [blame] | 10241 | if (NULL == dev || NULL == params) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 10242 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | b143d7a | 2015-02-18 19:39:55 +0530 | [diff] [blame] | 10244 | "%s: Device or params is Null", __func__); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10245 | return -ENODEV; |
| 10246 | } |
| 10247 | |
| 10248 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10249 | if (NULL == pAdapter) |
| 10250 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10251 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10252 | "%s: HDD adapter is Null", __func__); |
| 10253 | return -ENODEV; |
| 10254 | } |
| 10255 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10256 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10257 | TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId, |
| 10258 | params-> beacon_interval)); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10259 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 10260 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10261 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10262 | "%s: HDD adapter magic is invalid", __func__); |
| 10263 | return -ENODEV; |
| 10264 | } |
| 10265 | |
Hanumanth Reddy Pothula | 1428c61 | 2017-03-06 11:35:34 +0530 | [diff] [blame] | 10266 | clear_bit(SOFTAP_INIT_DONE, &pAdapter->event_flags); |
| 10267 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10268 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10269 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10270 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10271 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10272 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10273 | } |
| 10274 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10275 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)", |
| 10276 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10277 | pAdapter->device_mode); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10278 | |
| 10279 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10280 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10281 | ) |
| 10282 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10283 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10284 | |
| 10285 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10286 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10287 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10288 | { |
| 10289 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 10290 | FL("already beacon info added to session(%d)"), |
| 10291 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10292 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10293 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10294 | |
Girish Gowli | b143d7a | 2015-02-18 19:39:55 +0530 | [diff] [blame] | 10295 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 10296 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, |
| 10297 | &new, |
| 10298 | ¶ms->beacon); |
| 10299 | #else |
| 10300 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, |
| 10301 | &new, |
| 10302 | ¶ms->beacon, |
| 10303 | params->dtim_period); |
| 10304 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10305 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10306 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10307 | { |
| 10308 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 10309 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10310 | return -EINVAL; |
| 10311 | } |
| 10312 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 10313 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 10314 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 10315 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 10316 | params->channel, params->channel_type); |
| 10317 | #else |
| 10318 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 10319 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 10320 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10321 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
Kanchanapally, Vidyullatha | acc5925 | 2015-05-20 16:49:07 +0530 | [diff] [blame] | 10322 | params->ssid_len, params->hidden_ssid, |
| 10323 | params->auth_type); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10324 | } |
| 10325 | |
| 10326 | EXIT(); |
| 10327 | return status; |
| 10328 | } |
| 10329 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10330 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 10331 | struct net_device *dev, |
| 10332 | struct cfg80211_ap_settings *params) |
| 10333 | { |
| 10334 | int ret; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10335 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10336 | vos_ssr_protect(__func__); |
| 10337 | ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params); |
| 10338 | vos_ssr_unprotect(__func__); |
| 10339 | |
| 10340 | return ret; |
| 10341 | } |
| 10342 | |
| 10343 | static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10344 | struct net_device *dev, |
| 10345 | struct cfg80211_beacon_data *params) |
| 10346 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10347 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10348 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10349 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10350 | |
| 10351 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10352 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10353 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10354 | TRACE_CODE_HDD_CFG80211_CHANGE_BEACON, |
| 10355 | pAdapter->sessionId, pAdapter->device_mode)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10356 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10357 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10358 | |
| 10359 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10360 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10361 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 10362 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10363 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 10364 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10365 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10366 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10367 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10368 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10369 | { |
| 10370 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10371 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10372 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10373 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10374 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10375 | { |
| 10376 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10377 | FL("session(%d) beacon data points to NULL"), |
| 10378 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10379 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10380 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10381 | |
| 10382 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 10383 | |
| 10384 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10385 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10386 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10387 | return -EINVAL; |
| 10388 | } |
| 10389 | |
| 10390 | pAdapter->sessionCtx.ap.beacon = new; |
| 10391 | |
Kanchanapally, Vidyullatha | acc5925 | 2015-05-20 16:49:07 +0530 | [diff] [blame] | 10392 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0, |
| 10393 | pAdapter->sessionCtx.ap.sapConfig.authType); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10394 | } |
| 10395 | |
| 10396 | EXIT(); |
| 10397 | return status; |
| 10398 | } |
| 10399 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10400 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
| 10401 | struct net_device *dev, |
| 10402 | struct cfg80211_beacon_data *params) |
| 10403 | { |
| 10404 | int ret; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 10405 | |
Mukul Sharma | b0e0a98 | 2014-12-15 18:58:53 +0530 | [diff] [blame] | 10406 | vos_ssr_protect(__func__); |
| 10407 | ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params); |
| 10408 | vos_ssr_unprotect(__func__); |
| 10409 | |
| 10410 | return ret; |
| 10411 | } |
| 10412 | |
| 10413 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10414 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 10415 | static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10416 | struct net_device *dev, |
| 10417 | struct bss_parameters *params) |
| 10418 | { |
| 10419 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 10420 | hdd_context_t *pHddCtx; |
| 10421 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10422 | |
| 10423 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10424 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 10425 | if (NULL == pAdapter) |
| 10426 | { |
| 10427 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10428 | "%s: HDD adapter is Null", __func__); |
| 10429 | return -ENODEV; |
| 10430 | } |
| 10431 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 10432 | ret = wlan_hdd_validate_context(pHddCtx); |
| 10433 | if (0 != ret) |
| 10434 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 10435 | return ret; |
| 10436 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10437 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10438 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
| 10439 | pAdapter->sessionId, params->ap_isolate)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10440 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 10441 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10442 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10443 | |
| 10444 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10445 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10446 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10447 | { |
| 10448 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 10449 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10450 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10451 | { |
| 10452 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10453 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10454 | } |
| 10455 | |
| 10456 | EXIT(); |
| 10457 | return 0; |
| 10458 | } |
| 10459 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 10460 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 10461 | struct net_device *dev, |
| 10462 | struct bss_parameters *params) |
| 10463 | { |
| 10464 | int ret; |
| 10465 | |
| 10466 | vos_ssr_protect(__func__); |
| 10467 | ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
| 10468 | vos_ssr_unprotect(__func__); |
| 10469 | |
| 10470 | return ret; |
| 10471 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10472 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 10473 | * to wait for contry code completion |
| 10474 | */ |
| 10475 | void* wlan_hdd_change_country_code_cb(void *pAdapter) |
| 10476 | { |
| 10477 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 10478 | complete(&call_back_pAdapter->change_country_code); |
| 10479 | return NULL; |
| 10480 | } |
| 10481 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10482 | /* |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 10483 | * FUNCTION: __wlan_hdd_cfg80211_change_iface |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10484 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 10485 | */ |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 10486 | int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10487 | struct net_device *ndev, |
| 10488 | enum nl80211_iftype type, |
| 10489 | u32 *flags, |
| 10490 | struct vif_params *params |
| 10491 | ) |
| 10492 | { |
| 10493 | struct wireless_dev *wdev; |
| 10494 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 10495 | hdd_context_t *pHddCtx; |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 10496 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10497 | tCsrRoamProfile *pRoamProfile = NULL; |
| 10498 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10499 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10500 | eMib_dot11DesiredBssType connectedBssType; |
| 10501 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10502 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10503 | |
| 10504 | ENTER(); |
| 10505 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10506 | if (!pAdapter) |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 10507 | { |
| 10508 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10509 | "%s: Adapter context is null", __func__); |
| 10510 | return VOS_STATUS_E_FAILURE; |
| 10511 | } |
| 10512 | |
| 10513 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10514 | if (!pHddCtx) |
| 10515 | { |
| 10516 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10517 | "%s: HDD context is null", __func__); |
| 10518 | return VOS_STATUS_E_FAILURE; |
| 10519 | } |
| 10520 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10521 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10522 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
| 10523 | pAdapter->sessionId, type)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10524 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10525 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10526 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10527 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10528 | } |
| 10529 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10530 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 10531 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10532 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10533 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10534 | if (vos_max_concurrent_connections_reached()) { |
| 10535 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 10536 | return -EINVAL; |
| 10537 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10538 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10539 | wdev = ndev->ieee80211_ptr; |
| 10540 | |
| 10541 | #ifdef WLAN_BTAMP_FEATURE |
| 10542 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 10543 | (NL80211_IFTYPE_ADHOC == type)|| |
| 10544 | (NL80211_IFTYPE_AP == type)|| |
| 10545 | (NL80211_IFTYPE_P2P_GO == type)) |
| 10546 | { |
| 10547 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 10548 | // stop AMP traffic |
| 10549 | status = WLANBAP_StopAmp(); |
| 10550 | if(VOS_STATUS_SUCCESS != status ) |
| 10551 | { |
| 10552 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 10553 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10554 | "%s: Failed to stop AMP", __func__); |
| 10555 | return -EINVAL; |
| 10556 | } |
| 10557 | } |
| 10558 | #endif //WLAN_BTAMP_FEATURE |
| 10559 | /* Reset the current device mode bit mask*/ |
| 10560 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 10561 | |
Masti, Narayanraddi | 575ccc7 | 2015-08-17 18:04:57 +0530 | [diff] [blame] | 10562 | if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) && |
| 10563 | ((type == NL80211_IFTYPE_P2P_CLIENT) || |
| 10564 | (type == NL80211_IFTYPE_P2P_GO))) |
| 10565 | { |
| 10566 | /* Notify Mode change in case of concurrency. |
| 10567 | * Below function invokes TDLS teardown Functionality Since TDLS is |
| 10568 | * not Supported in case of concurrency i.e Once P2P session |
| 10569 | * is detected disable offchannel and teardown TDLS links |
| 10570 | */ |
| 10571 | hddLog(LOG1, |
| 10572 | FL("Device mode = %d Interface type = %d"), |
| 10573 | pAdapter->device_mode, type); |
| 10574 | hdd_tdls_notify_mode_change(pAdapter, pHddCtx); |
| 10575 | } |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 10576 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10577 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10578 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10579 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10580 | ) |
| 10581 | { |
| 10582 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 10583 | if (!pWextState) |
| 10584 | { |
| 10585 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10586 | "%s: pWextState is null", __func__); |
| 10587 | return VOS_STATUS_E_FAILURE; |
| 10588 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10589 | pRoamProfile = &pWextState->roamProfile; |
| 10590 | LastBSSType = pRoamProfile->BSSType; |
| 10591 | |
| 10592 | switch (type) |
| 10593 | { |
| 10594 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10595 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10596 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10597 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 10598 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10599 | #ifdef WLAN_FEATURE_11AC |
| 10600 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 10601 | { |
| 10602 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 10603 | } |
| 10604 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10605 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10606 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10607 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 10608 | //Check for sub-string p2p to confirm its a p2p interface |
| 10609 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10610 | { |
Mahesh A Saptasagar | c48ae8a | 2015-08-09 00:04:35 +0530 | [diff] [blame] | 10611 | #ifdef FEATURE_WLAN_TDLS |
| 10612 | mutex_lock(&pHddCtx->tdls_lock); |
| 10613 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
| 10614 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10615 | #endif |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 10616 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 10617 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 10618 | } |
| 10619 | else |
| 10620 | { |
| 10621 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10622 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 10623 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10624 | break; |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 10625 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10626 | case NL80211_IFTYPE_ADHOC: |
| 10627 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10628 | "%s: setting interface Type to ADHOC", __func__); |
| 10629 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 10630 | pRoamProfile->phyMode = |
| 10631 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 10632 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10633 | wdev->iftype = type; |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 10634 | hdd_set_ibss_ops( pAdapter ); |
| 10635 | hdd_ibss_init_tx_rx( pAdapter ); |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 10636 | |
| 10637 | status = hdd_sta_id_hash_attach(pAdapter); |
| 10638 | if (VOS_STATUS_SUCCESS != status) { |
| 10639 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10640 | FL("Failed to initialize hash for IBSS")); |
| 10641 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10642 | break; |
| 10643 | |
| 10644 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10645 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10646 | { |
| 10647 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 10648 | "%s: setting interface Type to %s", __func__, |
| 10649 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 10650 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 10651 | //Cancel any remain on channel for GO mode |
| 10652 | if (NL80211_IFTYPE_P2P_GO == type) |
| 10653 | { |
| 10654 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 10655 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 10656 | if (NL80211_IFTYPE_AP == type) |
| 10657 | { |
| 10658 | /* As Loading WLAN Driver one interface being created for p2p device |
| 10659 | * address. This will take one HW STA and the max number of clients |
| 10660 | * that can connect to softAP will be reduced by one. so while changing |
| 10661 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 10662 | * interface as it is not required in SoftAP mode. |
| 10663 | */ |
| 10664 | |
| 10665 | // Get P2P Adapter |
| 10666 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 10667 | |
| 10668 | if (pP2pAdapter) |
| 10669 | { |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10670 | hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 10671 | hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 10672 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 10673 | } |
| 10674 | } |
Swaroop Golti | a2e3221 | 2014-04-09 23:37:33 +0530 | [diff] [blame] | 10675 | //Disable IMPS & BMPS for SAP/GO |
| 10676 | if(VOS_STATUS_E_FAILURE == |
| 10677 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 10678 | { |
| 10679 | //Fail to Exit BMPS |
| 10680 | VOS_ASSERT(0); |
| 10681 | } |
Deepthi Gowri | 500fc47 | 2014-08-11 19:53:10 +0530 | [diff] [blame] | 10682 | |
| 10683 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
| 10684 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10685 | #ifdef FEATURE_WLAN_TDLS |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 10686 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10687 | /* A Mutex Lock is introduced while changing the mode to |
| 10688 | * protect the concurrent access for the Adapters by TDLS |
| 10689 | * module. |
| 10690 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10691 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10692 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10693 | //De-init the adapter. |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 10694 | hdd_deinit_adapter( pHddCtx, pAdapter, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10695 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10696 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 10697 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10698 | #ifdef FEATURE_WLAN_TDLS |
| 10699 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10700 | #endif |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 10701 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 10702 | (pConfig->apRandomBssidEnabled)) |
| 10703 | { |
| 10704 | /* To meet Android requirements create a randomized |
| 10705 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 10706 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 10707 | ndev->dev_addr[0] = 0x02; |
| 10708 | ndev->dev_addr[1] = 0x1A; |
| 10709 | ndev->dev_addr[2] = 0x11; |
| 10710 | ndev->dev_addr[3] |= 0xF0; |
| 10711 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 10712 | VOS_MAC_ADDR_SIZE); |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 10713 | pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n", |
| 10714 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 10715 | } |
| 10716 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10717 | hdd_set_ap_ops( pAdapter->dev ); |
| 10718 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10719 | /* This is for only SAP mode where users can |
| 10720 | * control country through ini. |
| 10721 | * P2P GO follows station country code |
| 10722 | * acquired during the STA scanning. */ |
| 10723 | if((NL80211_IFTYPE_AP == type) && |
| 10724 | (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)) |
| 10725 | { |
| 10726 | int status = 0; |
| 10727 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO, |
| 10728 | "%s: setting country code from INI ", __func__); |
| 10729 | init_completion(&pAdapter->change_country_code); |
| 10730 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 10731 | (void *)(tSmeChangeCountryCallback) |
| 10732 | wlan_hdd_change_country_code_cb, |
| 10733 | pConfig->apCntryCode, pAdapter, |
| 10734 | pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 10735 | eSIR_FALSE, |
| 10736 | eSIR_TRUE); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10737 | if (eHAL_STATUS_SUCCESS == status) |
| 10738 | { |
| 10739 | /* Wait for completion */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10740 | ret = wait_for_completion_interruptible_timeout( |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10741 | &pAdapter->change_country_code, |
| 10742 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10743 | if (ret <= 0) |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10744 | { |
| 10745 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10746 | FL("SME Timed out while setting country code %ld"), |
| 10747 | ret); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 10748 | |
| 10749 | if (pHddCtx->isLogpInProgress) |
| 10750 | { |
| 10751 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10752 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 10753 | return -EAGAIN; |
| 10754 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10755 | } |
| 10756 | } |
| 10757 | else |
| 10758 | { |
| 10759 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10760 | "%s: SME Change Country code failed",__func__); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 10761 | return -EINVAL; |
| 10762 | } |
| 10763 | } |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 10764 | status = hdd_init_ap_mode(pAdapter, false); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10765 | if(status != VOS_STATUS_SUCCESS) |
| 10766 | { |
| 10767 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10768 | "%s: Error initializing the ap mode", __func__); |
| 10769 | return -EINVAL; |
| 10770 | } |
| 10771 | hdd_set_conparam(1); |
| 10772 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 10773 | status = hdd_sta_id_hash_attach(pAdapter); |
| 10774 | if (VOS_STATUS_SUCCESS != status) |
| 10775 | { |
| 10776 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10777 | FL("Failed to initialize hash for AP")); |
| 10778 | return -EINVAL; |
| 10779 | } |
| 10780 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10781 | /*interface type changed update in wiphy structure*/ |
| 10782 | if(wdev) |
| 10783 | { |
| 10784 | wdev->iftype = type; |
| 10785 | pHddCtx->change_iface = type; |
| 10786 | } |
| 10787 | else |
| 10788 | { |
| 10789 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10790 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 10791 | return -EINVAL; |
| 10792 | } |
| 10793 | goto done; |
| 10794 | } |
| 10795 | |
| 10796 | default: |
| 10797 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 10798 | __func__); |
| 10799 | return -EOPNOTSUPP; |
| 10800 | } |
| 10801 | } |
| 10802 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10803 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10804 | ) |
| 10805 | { |
| 10806 | switch(type) |
| 10807 | { |
| 10808 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10809 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10810 | case NL80211_IFTYPE_ADHOC: |
Deepthi Gowri | 500fc47 | 2014-08-11 19:53:10 +0530 | [diff] [blame] | 10811 | |
| 10812 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10813 | #ifdef FEATURE_WLAN_TDLS |
| 10814 | |
| 10815 | /* A Mutex Lock is introduced while changing the mode to |
| 10816 | * protect the concurrent access for the Adapters by TDLS |
| 10817 | * module. |
| 10818 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10819 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10820 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 10821 | hdd_deinit_adapter( pHddCtx, pAdapter, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10822 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 10823 | //Check for sub-string p2p to confirm its a p2p interface |
| 10824 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 10825 | { |
| 10826 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 10827 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 10828 | } |
| 10829 | else |
| 10830 | { |
| 10831 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10832 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 10833 | } |
Agrawal Ashish | cfe8328 | 2016-09-29 13:03:45 +0530 | [diff] [blame] | 10834 | |
| 10835 | /* set con_mode to STA only when no SAP concurrency mode */ |
| 10836 | if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO))) |
| 10837 | hdd_set_conparam(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10838 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10839 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 10840 | hdd_set_station_ops( pAdapter->dev ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10841 | #ifdef FEATURE_WLAN_TDLS |
| 10842 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10843 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 10844 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10845 | if( VOS_STATUS_SUCCESS != status ) |
| 10846 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10847 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 10848 | * This is the right place to enable back bmps_imps() |
| 10849 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10850 | if (pHddCtx->hdd_wlan_suspended) |
| 10851 | { |
| 10852 | hdd_set_pwrparams(pHddCtx); |
| 10853 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10854 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10855 | goto done; |
| 10856 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10857 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10858 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10859 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 10860 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10861 | goto done; |
| 10862 | default: |
| 10863 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 10864 | __func__); |
| 10865 | return -EOPNOTSUPP; |
| 10866 | |
| 10867 | } |
| 10868 | |
| 10869 | } |
| 10870 | else |
| 10871 | { |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10872 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))", |
| 10873 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10874 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10875 | return -EOPNOTSUPP; |
| 10876 | } |
| 10877 | |
| 10878 | |
| 10879 | if(pRoamProfile) |
| 10880 | { |
| 10881 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 10882 | { |
| 10883 | /*interface type changed update in wiphy structure*/ |
| 10884 | wdev->iftype = type; |
| 10885 | |
| 10886 | /*the BSS mode changed, We need to issue disconnect |
| 10887 | if connected or in IBSS disconnect state*/ |
| 10888 | if ( hdd_connGetConnectedBssType( |
| 10889 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 10890 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 10891 | { |
| 10892 | /*need to issue a disconnect to CSR.*/ |
| 10893 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 10894 | if( eHAL_STATUS_SUCCESS == |
| 10895 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10896 | pAdapter->sessionId, |
| 10897 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 10898 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10899 | ret = wait_for_completion_interruptible_timeout( |
| 10900 | &pAdapter->disconnect_comp_var, |
| 10901 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 10902 | if (ret <= 0) |
| 10903 | { |
| 10904 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10905 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 10906 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10907 | } |
| 10908 | } |
| 10909 | } |
| 10910 | } |
| 10911 | |
| 10912 | done: |
| 10913 | /*set bitmask based on updated value*/ |
| 10914 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 10915 | |
| 10916 | /* Only STA mode support TM now |
| 10917 | * all other mode, TM feature should be disabled */ |
| 10918 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 10919 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 10920 | { |
| 10921 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 10922 | } |
| 10923 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10924 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10925 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10926 | (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10927 | { |
| 10928 | //we are ok to do AMP |
| 10929 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 10930 | } |
| 10931 | #endif //WLAN_BTAMP_FEATURE |
| 10932 | EXIT(); |
| 10933 | return 0; |
| 10934 | } |
| 10935 | |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 10936 | /* |
| 10937 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 10938 | * wrapper function to protect the actual implementation from SSR. |
| 10939 | */ |
| 10940 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 10941 | struct net_device *ndev, |
| 10942 | enum nl80211_iftype type, |
| 10943 | u32 *flags, |
| 10944 | struct vif_params *params |
| 10945 | ) |
| 10946 | { |
| 10947 | int ret; |
| 10948 | |
| 10949 | vos_ssr_protect(__func__); |
| 10950 | ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params); |
| 10951 | vos_ssr_unprotect(__func__); |
| 10952 | |
| 10953 | return ret; |
| 10954 | } |
| 10955 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 10956 | #ifdef FEATURE_WLAN_TDLS |
| 10957 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 10958 | struct net_device *dev, |
| 10959 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 10960 | const u8 *mac, |
| 10961 | #else |
| 10962 | u8 *mac, |
| 10963 | #endif |
| 10964 | bool update, tCsrStaParams *StaParams) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 10965 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 10966 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10967 | hddTdlsPeer_t *pTdlsPeer; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10968 | long ret; |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10969 | tANI_U16 numCurrTdlsPeers; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 10970 | hdd_adapter_t *pAdapter; |
Ganesh Kondabattini | f065c1f | 2015-08-05 23:05:23 +0530 | [diff] [blame] | 10971 | VOS_STATUS status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 10972 | |
| 10973 | ENTER(); |
| 10974 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 10975 | if (!dev) { |
| 10976 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL")); |
| 10977 | return -EINVAL; |
| 10978 | } |
| 10979 | |
| 10980 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10981 | if (!pAdapter) { |
| 10982 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL")); |
| 10983 | return -EINVAL; |
| 10984 | } |
| 10985 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 10986 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 10987 | { |
| 10988 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10989 | "Invalid arguments"); |
| 10990 | return -EINVAL; |
| 10991 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 10992 | |
| 10993 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 10994 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 10995 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 10996 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 10997 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 10998 | MAC_ADDRESS_STR " Request declined.", |
| 10999 | __func__, MAC_ADDR_ARRAY(mac)); |
| 11000 | return -ENOTSUPP; |
| 11001 | } |
| 11002 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11003 | if (pHddCtx->isLogpInProgress) |
| 11004 | { |
| 11005 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11006 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 11007 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 11008 | mac, |
| 11009 | eTDLS_LINK_IDLE, |
| 11010 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11011 | return -EBUSY; |
| 11012 | } |
| 11013 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 11014 | mutex_lock(&pHddCtx->tdls_lock); |
Naresh Jayaram | 9c6f446 | 2014-02-13 12:20:31 +0530 | [diff] [blame] | 11015 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11016 | |
| 11017 | if ( NULL == pTdlsPeer ) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11018 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11019 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 11020 | __func__, MAC_ADDR_ARRAY(mac), update); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 11021 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11022 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 11023 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11024 | |
| 11025 | /* in add station, we accept existing valid staId if there is */ |
| 11026 | if ((0 == update) && |
| 11027 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 11028 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11029 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11030 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11031 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11032 | " link_status %d. staId %d. add station ignored.", |
| 11033 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11034 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11035 | return 0; |
| 11036 | } |
| 11037 | /* in change station, we accept only when staId is valid */ |
| 11038 | if ((1 == update) && |
| 11039 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 11040 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 11041 | { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11042 | tANI_U16 staId = pTdlsPeer->staId; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11043 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11044 | "%s: " MAC_ADDRESS_STR |
| 11045 | " link status %d. staId %d. change station %s.", |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11046 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, staId, |
| 11047 | (TDLS_STA_INDEX_VALID(staId)) ? "ignored" : "declined"); |
| 11048 | mutex_unlock(&pHddCtx->tdls_lock); |
| 11049 | return (TDLS_STA_INDEX_VALID(staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11050 | } |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11051 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 11052 | |
| 11053 | /* when others are on-going, we want to change link_status to idle */ |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 11054 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11055 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 11056 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11057 | "%s: " MAC_ADDRESS_STR |
| 11058 | " TDLS setup is ongoing. Request declined.", |
| 11059 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 11060 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11061 | } |
| 11062 | |
| 11063 | /* first to check if we reached to maximum supported TDLS peer. |
| 11064 | TODO: for now, return -EPERM looks working fine, |
| 11065 | but need to check if any other errno fit into this category.*/ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 11066 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 11067 | if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11068 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 11069 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11070 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 11071 | " TDLS Max peer already connected. Request declined." |
| 11072 | " Num of peers (%d), Max allowed (%d).", |
| 11073 | __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers, |
| 11074 | HDD_MAX_NUM_TDLS_STA); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 11075 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11076 | } |
| 11077 | else |
| 11078 | { |
| 11079 | hddTdlsPeer_t *pTdlsPeer; |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11080 | mutex_lock(&pHddCtx->tdls_lock); |
| 11081 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11082 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11083 | { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11084 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 11085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11086 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 11087 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11088 | return -EPERM; |
| 11089 | } |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 11090 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11091 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11092 | if (0 == update) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 11093 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 11094 | mac, |
| 11095 | eTDLS_LINK_CONNECTING, |
| 11096 | eTDLS_LINK_SUCCESS); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11097 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 11098 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 11099 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11100 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11101 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11102 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11103 | if(StaParams->htcap_present) |
| 11104 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11105 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11106 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11108 | "ht_capa->extended_capabilities: %0x", |
| 11109 | StaParams->HTCap.extendedHtCapInfo); |
| 11110 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11111 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11112 | "params->capability: %0x",StaParams->capability); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11113 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 11114 | "params->ext_capab_len: %0x",StaParams->extn_capability[0]); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11115 | if(StaParams->vhtcap_present) |
| 11116 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11117 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11118 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 11119 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 11120 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 11121 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11122 | { |
| 11123 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11124 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11125 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 11126 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11127 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 11128 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 11129 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 11130 | else if ((1 == update) && (NULL == StaParams)) |
| 11131 | { |
| 11132 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11133 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 11134 | return -EPERM; |
| 11135 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11136 | |
| 11137 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 11138 | |
| 11139 | if (!update) |
| 11140 | { |
Ganesh Kondabattini | f065c1f | 2015-08-05 23:05:23 +0530 | [diff] [blame] | 11141 | /*Before adding sta make sure that device exited from BMPS*/ |
| 11142 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 11143 | { |
| 11144 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11145 | "%s: Adding tdls peer sta. Disable BMPS", __func__); |
| 11146 | status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 11147 | if (status != VOS_STATUS_SUCCESS) { |
| 11148 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS")); |
| 11149 | } |
| 11150 | } |
| 11151 | |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 11152 | ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11153 | pAdapter->sessionId, mac); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 11154 | if (ret != eHAL_STATUS_SUCCESS) { |
Ganesh Kondabattini | f065c1f | 2015-08-05 23:05:23 +0530 | [diff] [blame] | 11155 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11156 | FL("Failed to add TDLS peer STA. Enable Bmps")); |
| 11157 | wlan_hdd_tdls_check_bmps(pAdapter); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 11158 | return -EPERM; |
| 11159 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11160 | } |
| 11161 | else |
| 11162 | { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 11163 | ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11164 | pAdapter->sessionId, mac, StaParams); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 11165 | if (ret != eHAL_STATUS_SUCCESS) { |
| 11166 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params")); |
| 11167 | return -EPERM; |
| 11168 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11169 | } |
| 11170 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11171 | ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11172 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 11173 | |
Masti, Narayanraddi | 255d8c5 | 2016-01-07 16:26:06 +0530 | [diff] [blame] | 11174 | mutex_lock(&pHddCtx->tdls_lock); |
| 11175 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
| 11176 | |
Masti, Narayanraddi | 0726246 | 2016-01-19 12:40:06 +0530 | [diff] [blame] | 11177 | if ((pTdlsPeer != NULL) && |
| 11178 | (pTdlsPeer->link_status == eTDLS_LINK_TEARING)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11179 | { |
Masti, Narayanraddi | 0726246 | 2016-01-19 12:40:06 +0530 | [diff] [blame] | 11180 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11181 | FL("peer link status %u"), pTdlsPeer->link_status); |
| 11182 | mutex_unlock(&pHddCtx->tdls_lock); |
| 11183 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11184 | } |
Masti, Narayanraddi | 255d8c5 | 2016-01-07 16:26:06 +0530 | [diff] [blame] | 11185 | mutex_unlock(&pHddCtx->tdls_lock); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11186 | |
Masti, Narayanraddi | 0726246 | 2016-01-19 12:40:06 +0530 | [diff] [blame] | 11187 | if (ret <= 0) |
| 11188 | { |
| 11189 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11190 | "%s: timeout waiting for tdls add station indication %ld", |
| 11191 | __func__, ret); |
| 11192 | goto error; |
| 11193 | } |
| 11194 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11195 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 11196 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 11197 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11198 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 11199 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11200 | } |
| 11201 | |
| 11202 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 11203 | |
| 11204 | error: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 11205 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 11206 | mac, |
| 11207 | eTDLS_LINK_IDLE, |
| 11208 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 11209 | return -EPERM; |
| 11210 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11211 | } |
| 11212 | #endif |
| 11213 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11214 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11215 | struct net_device *dev, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 11216 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 11217 | const u8 *mac, |
| 11218 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11219 | u8 *mac, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 11220 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11221 | struct station_parameters *params) |
| 11222 | { |
| 11223 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11224 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11225 | hdd_context_t *pHddCtx; |
| 11226 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11227 | v_MACADDR_t STAMacAddress; |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11228 | int ret = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 11229 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11230 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11231 | tANI_U8 isBufSta = 0; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 11232 | tANI_U8 isOffChannelSupported = 0; |
Masti, Narayanraddi | 3d79902 | 2015-12-24 18:22:36 +0530 | [diff] [blame] | 11233 | tANI_U8 isQosWmmSta = FALSE; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 11234 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11235 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11236 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11237 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11238 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11239 | if ((NULL == pAdapter)) |
| 11240 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11241 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11242 | "invalid adapter "); |
| 11243 | return -EINVAL; |
| 11244 | } |
| 11245 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11246 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11247 | TRACE_CODE_HDD_CHANGE_STATION, |
| 11248 | pAdapter->sessionId, params->listen_interval)); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11249 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11250 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11251 | ret = wlan_hdd_validate_context(pHddCtx); |
| 11252 | if (0 != ret) |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11253 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11254 | return ret; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11255 | } |
| 11256 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11257 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11258 | |
| 11259 | if (NULL == pHddStaCtx) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11260 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11261 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11262 | "invalid HDD station context"); |
| 11263 | return -EINVAL; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11264 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11265 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 11266 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11267 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 11268 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11269 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11270 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11271 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11272 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11273 | WLANTL_STA_AUTHENTICATED); |
| 11274 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11275 | if (status != VOS_STATUS_SUCCESS) |
| 11276 | { |
| 11277 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11278 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 11279 | return -EINVAL; |
| 11280 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11281 | } |
| 11282 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 11283 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 11284 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11285 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11286 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 11287 | StaParams.capability = params->capability; |
| 11288 | StaParams.uapsd_queues = params->uapsd_queues; |
| 11289 | StaParams.max_sp = params->max_sp; |
| 11290 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 11291 | /* Convert (first channel , number of channels) tuple to |
| 11292 | * the total list of channels. This goes with the assumption |
| 11293 | * that if the first channel is < 14, then the next channels |
| 11294 | * are an incremental of 1 else an incremental of 4 till the number |
| 11295 | * of channels. |
| 11296 | */ |
| 11297 | if (0 != params->supported_channels_len) { |
| 11298 | int i = 0,j = 0,k = 0, no_of_channels = 0 ; |
| 11299 | for ( i = 0 ; i < params->supported_channels_len ; i+=2) |
| 11300 | { |
| 11301 | int wifi_chan_index; |
| 11302 | StaParams.supported_channels[j] = params->supported_channels[i]; |
| 11303 | wifi_chan_index = |
| 11304 | ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 ); |
| 11305 | no_of_channels = params->supported_channels[i+1]; |
| 11306 | for(k=1; k <= no_of_channels; k++) |
| 11307 | { |
| 11308 | StaParams.supported_channels[j+1] = |
| 11309 | StaParams.supported_channels[j] + wifi_chan_index; |
| 11310 | j+=1; |
| 11311 | } |
| 11312 | } |
| 11313 | StaParams.supported_channels_len = j; |
| 11314 | } |
SaidiReddy Yenuga | 0f1a159 | 2017-04-05 13:18:26 +0530 | [diff] [blame] | 11315 | if (params->supported_oper_classes_len > |
| 11316 | SIR_MAC_MAX_SUPP_OPER_CLASSES) { |
| 11317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11318 | "received oper classes:%d, resetting it to max supported %d", |
| 11319 | params->supported_oper_classes_len, |
| 11320 | SIR_MAC_MAX_SUPP_OPER_CLASSES); |
| 11321 | params->supported_oper_classes_len = |
| 11322 | SIR_MAC_MAX_SUPP_OPER_CLASSES; |
| 11323 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 11324 | vos_mem_copy(StaParams.supported_oper_classes, |
| 11325 | params->supported_oper_classes, |
| 11326 | params->supported_oper_classes_len); |
| 11327 | StaParams.supported_oper_classes_len = |
| 11328 | params->supported_oper_classes_len; |
| 11329 | |
SaidiReddy Yenuga | 96d8ca5 | 2017-06-06 13:01:29 +0530 | [diff] [blame] | 11330 | if (params->ext_capab_len > sizeof(StaParams.extn_capability)) { |
| 11331 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11332 | "received extn capabilities:%d, resetting it to max supported", |
| 11333 | params->ext_capab_len); |
| 11334 | params->ext_capab_len = sizeof(StaParams.extn_capability); |
| 11335 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11336 | if (0 != params->ext_capab_len) |
| 11337 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
SaidiReddy Yenuga | 96d8ca5 | 2017-06-06 13:01:29 +0530 | [diff] [blame] | 11338 | params->ext_capab_len); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11339 | |
| 11340 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11341 | { |
| 11342 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11343 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11344 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11345 | |
| 11346 | StaParams.supported_rates_len = params->supported_rates_len; |
| 11347 | |
| 11348 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 11349 | * The supported_rates array , for all the structures propogating till Add Sta |
| 11350 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 11351 | * modified to send more rates. |
| 11352 | */ |
| 11353 | |
| 11354 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 11355 | */ |
| 11356 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 11357 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 11358 | |
| 11359 | if (0 != StaParams.supported_rates_len) { |
| 11360 | int i = 0; |
| 11361 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 11362 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11363 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11364 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 11365 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 11366 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11367 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 11368 | } |
| 11369 | |
| 11370 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11371 | { |
| 11372 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11373 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 11374 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 11375 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11376 | if (0 != params->ext_capab_len ) { |
| 11377 | /*Define A Macro : TODO Sunil*/ |
| 11378 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 11379 | isBufSta = 1; |
| 11380 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 11381 | /* TDLS Channel Switching Support */ |
| 11382 | if ((1<<6) & StaParams.extn_capability[3]) { |
| 11383 | isOffChannelSupported = 1; |
| 11384 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11385 | } |
Masti, Narayanraddi | 3d79902 | 2015-12-24 18:22:36 +0530 | [diff] [blame] | 11386 | |
| 11387 | if (pHddCtx->cfg_ini->fEnableTDLSWmmMode && |
Nitesh Shah | 48df4c0 | 2016-08-12 16:27:33 +0530 | [diff] [blame] | 11388 | (params->ht_capa || params->vht_capa || |
| 11389 | (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME)))) |
Masti, Narayanraddi | 3d79902 | 2015-12-24 18:22:36 +0530 | [diff] [blame] | 11390 | /* TDLS Peer is WME/QoS capable */ |
| 11391 | isQosWmmSta = TRUE; |
Masti, Narayanraddi | 3d79902 | 2015-12-24 18:22:36 +0530 | [diff] [blame] | 11392 | |
| 11393 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11394 | "%s: TDLS Peer is QOS capable isQosWmmSta= %d HTcapPresent= %d", |
| 11395 | __func__, isQosWmmSta, StaParams.htcap_present); |
| 11396 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 11397 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, |
| 11398 | &StaParams, isBufSta, |
Masti, Narayanraddi | 3d79902 | 2015-12-24 18:22:36 +0530 | [diff] [blame] | 11399 | isOffChannelSupported, |
| 11400 | isQosWmmSta); |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 11401 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 11402 | if (VOS_STATUS_SUCCESS != status) { |
| 11403 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11404 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 11405 | return -EINVAL; |
| 11406 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 11407 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 11408 | |
| 11409 | if (VOS_STATUS_SUCCESS != status) { |
| 11410 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11411 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 11412 | return -EINVAL; |
| 11413 | } |
| 11414 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 11415 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 11416 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11417 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11418 | return status; |
| 11419 | } |
| 11420 | |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 11421 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
| 11422 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 11423 | struct net_device *dev, |
| 11424 | const u8 *mac, |
| 11425 | struct station_parameters *params) |
| 11426 | #else |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11427 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 11428 | struct net_device *dev, |
| 11429 | u8 *mac, |
| 11430 | struct station_parameters *params) |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 11431 | #endif |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11432 | { |
| 11433 | int ret; |
| 11434 | |
| 11435 | vos_ssr_protect(__func__); |
| 11436 | ret = __wlan_hdd_change_station(wiphy, dev, mac, params); |
| 11437 | vos_ssr_unprotect(__func__); |
| 11438 | |
| 11439 | return ret; |
| 11440 | } |
| 11441 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11442 | /* |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11443 | * FUNCTION: __wlan_hdd_cfg80211_add_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11444 | * This function is used to initialize the key information |
| 11445 | */ |
| 11446 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11447 | static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11448 | struct net_device *ndev, |
| 11449 | u8 key_index, bool pairwise, |
| 11450 | const u8 *mac_addr, |
| 11451 | struct key_params *params |
| 11452 | ) |
| 11453 | #else |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11454 | static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11455 | struct net_device *ndev, |
| 11456 | u8 key_index, const u8 *mac_addr, |
| 11457 | struct key_params *params |
| 11458 | ) |
| 11459 | #endif |
| 11460 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11461 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11462 | tCsrRoamSetKey setKey; |
| 11463 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11464 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11465 | v_U32_t roamId= 0xFF; |
| 11466 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11467 | hdd_hostapd_state_t *pHostapdState; |
| 11468 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 11469 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11470 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11471 | |
| 11472 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11473 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11474 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11475 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
| 11476 | pAdapter->sessionId, params->key_len)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11477 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11478 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11479 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11480 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11481 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11482 | } |
| 11483 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 11484 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 11485 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 11486 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11487 | |
| 11488 | if (CSR_MAX_NUM_KEY <= key_index) |
| 11489 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11490 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11491 | key_index); |
| 11492 | |
| 11493 | return -EINVAL; |
| 11494 | } |
| 11495 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11496 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 11497 | { |
| 11498 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 11499 | params->key_len); |
| 11500 | |
| 11501 | return -EINVAL; |
| 11502 | } |
| 11503 | |
| 11504 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 11505 | "%s: called with key index = %d & key length %d", |
| 11506 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11507 | |
| 11508 | /*extract key idx, key len and key*/ |
| 11509 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 11510 | setKey.keyId = key_index; |
| 11511 | setKey.keyLength = params->key_len; |
| 11512 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 11513 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11514 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11515 | { |
| 11516 | case WLAN_CIPHER_SUITE_WEP40: |
| 11517 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 11518 | break; |
| 11519 | |
| 11520 | case WLAN_CIPHER_SUITE_WEP104: |
| 11521 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 11522 | break; |
| 11523 | |
| 11524 | case WLAN_CIPHER_SUITE_TKIP: |
| 11525 | { |
| 11526 | u8 *pKey = &setKey.Key[0]; |
| 11527 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 11528 | |
| 11529 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 11530 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11531 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11532 | |
| 11533 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11534 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11535 | |--------------|----------|----------| |
| 11536 | <---16bytes---><--8bytes--><--8bytes--> |
| 11537 | |
| 11538 | */ |
| 11539 | /*Sme expects the 32 bytes key to be in the below order |
| 11540 | |
| 11541 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11542 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11543 | |--------------|----------|----------| |
| 11544 | <---16bytes---><--8bytes--><--8bytes--> |
| 11545 | */ |
| 11546 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11547 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11548 | |
| 11549 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11550 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11551 | |
| 11552 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11553 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11554 | |
| 11555 | |
| 11556 | break; |
| 11557 | } |
| 11558 | |
| 11559 | case WLAN_CIPHER_SUITE_CCMP: |
| 11560 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 11561 | break; |
| 11562 | |
| 11563 | #ifdef FEATURE_WLAN_WAPI |
| 11564 | case WLAN_CIPHER_SUITE_SMS4: |
| 11565 | { |
| 11566 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 11567 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 11568 | params->key, params->key_len); |
| 11569 | return 0; |
| 11570 | } |
| 11571 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 11572 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 11573 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11574 | case WLAN_CIPHER_SUITE_KRK: |
| 11575 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 11576 | break; |
| 11577 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 11578 | |
| 11579 | #ifdef WLAN_FEATURE_11W |
| 11580 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 11581 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 11582 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 11583 | #endif |
| 11584 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11585 | default: |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 11586 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11587 | __func__, params->cipher); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11588 | status = -EOPNOTSUPP; |
| 11589 | goto end; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11590 | } |
| 11591 | |
| 11592 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 11593 | __func__, setKey.encType); |
| 11594 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 11595 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11596 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11597 | (!pairwise) |
| 11598 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11599 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11600 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 11601 | ) |
| 11602 | { |
| 11603 | /* set group key*/ |
| 11604 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11605 | "%s- %d: setting Broadcast key", |
| 11606 | __func__, __LINE__); |
| 11607 | setKey.keyDirection = eSIR_RX_ONLY; |
| 11608 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 11609 | } |
| 11610 | else |
| 11611 | { |
| 11612 | /* set pairwise key*/ |
| 11613 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11614 | "%s- %d: setting pairwise key", |
| 11615 | __func__, __LINE__); |
| 11616 | setKey.keyDirection = eSIR_TX_RX; |
| 11617 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 11618 | } |
| 11619 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 11620 | { |
| 11621 | setKey.keyDirection = eSIR_TX_RX; |
| 11622 | /*Set the group key*/ |
| 11623 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 11624 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11625 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 11626 | if ( 0 != status ) |
| 11627 | { |
| 11628 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11629 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11630 | status = -EINVAL; |
| 11631 | goto end; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 11632 | } |
| 11633 | /*Save the keys here and call sme_RoamSetKey for setting |
| 11634 | the PTK after peer joins the IBSS network*/ |
| 11635 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 11636 | &setKey, sizeof(tCsrRoamSetKey)); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11637 | goto end; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 11638 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 11639 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 11640 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 11641 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11642 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11643 | if( pHostapdState->bssState == BSS_START ) |
| 11644 | { |
Nirav Shah | 4b53d4b | 2015-05-08 05:35:00 -0700 | [diff] [blame] | 11645 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11646 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 11647 | |
| 11648 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 11649 | { |
| 11650 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11651 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 11652 | __LINE__, vos_status ); |
| 11653 | |
| 11654 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 11655 | |
| 11656 | status = -EINVAL; |
| 11657 | goto end; |
| 11658 | } |
| 11659 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11660 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 11661 | |
| 11662 | if ( status != eHAL_STATUS_SUCCESS ) |
| 11663 | { |
| 11664 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11665 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 11666 | __LINE__, status ); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11667 | status = -EINVAL; |
| 11668 | goto end; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11669 | } |
| 11670 | } |
| 11671 | |
| 11672 | /* Saving WEP keys */ |
| 11673 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 11674 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 11675 | { |
| 11676 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 11677 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 11678 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 11679 | } |
| 11680 | else |
| 11681 | { |
| 11682 | //Save the key in ap context. Issue setkey after the BSS is started. |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11683 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11684 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 11685 | } |
| 11686 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11687 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 11688 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11689 | { |
| 11690 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11691 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11692 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 11693 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11694 | if (!pairwise) |
| 11695 | #else |
| 11696 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 11697 | #endif |
| 11698 | { |
| 11699 | /* set group key*/ |
| 11700 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 11701 | { |
| 11702 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11703 | "%s- %d: Perform Set key Complete", |
| 11704 | __func__, __LINE__); |
| 11705 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 11706 | } |
| 11707 | } |
| 11708 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11709 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 11710 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 11711 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 11712 | |
| 11713 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 11714 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11715 | params->key, params->key_len); |
| 11716 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 11717 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11718 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 11719 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11720 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11721 | "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11722 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 11723 | setKey.peerMac[2], setKey.peerMac[3], |
| 11724 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11725 | setKey.keyDirection); |
| 11726 | |
Nirav Shah | 4b53d4b | 2015-05-08 05:35:00 -0700 | [diff] [blame] | 11727 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
Nirav Shah | 4f765af | 2015-01-21 19:51:30 +0530 | [diff] [blame] | 11728 | |
Nirav Shah | 4b53d4b | 2015-05-08 05:35:00 -0700 | [diff] [blame] | 11729 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 11730 | { |
| 11731 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11732 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 11733 | __LINE__, vos_status ); |
| 11734 | |
Nirav Shah | 4b53d4b | 2015-05-08 05:35:00 -0700 | [diff] [blame] | 11735 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11736 | |
Nirav Shah | 4b53d4b | 2015-05-08 05:35:00 -0700 | [diff] [blame] | 11737 | status = -EINVAL; |
| 11738 | goto end; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11739 | |
| 11740 | } |
| 11741 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 11742 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 11743 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 11744 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 11745 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 11746 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 11747 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 11748 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 11749 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 11750 | "%s: Update PreAuth Key success", __func__); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11751 | status = 0; |
| 11752 | goto end; |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 11753 | } |
| 11754 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 11755 | { |
| 11756 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11757 | "%s: Update PreAuth Key failed", __func__); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11758 | status = -EINVAL; |
| 11759 | goto end; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 11760 | } |
| 11761 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11762 | |
| 11763 | /* issue set key request to SME*/ |
| 11764 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 11765 | pAdapter->sessionId, &setKey, &roamId ); |
| 11766 | |
| 11767 | if ( 0 != status ) |
| 11768 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11769 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11770 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 11771 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11772 | status = -EINVAL; |
| 11773 | goto end; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11774 | } |
| 11775 | |
| 11776 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11777 | /* in case of IBSS as there was no information available about WEP keys during |
| 11778 | * IBSS join, group key intialized with NULL key, so re-initialize group key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11779 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11780 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 11781 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 11782 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11783 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 11784 | ) |
| 11785 | && |
| 11786 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 11787 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 11788 | ) |
| 11789 | ) |
| 11790 | { |
| 11791 | setKey.keyDirection = eSIR_RX_ONLY; |
| 11792 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 11793 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11794 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11795 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11796 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 11797 | setKey.peerMac[2], setKey.peerMac[3], |
| 11798 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11799 | setKey.keyDirection); |
| 11800 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11801 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11802 | pAdapter->sessionId, &setKey, &roamId ); |
| 11803 | |
| 11804 | if ( 0 != status ) |
| 11805 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11806 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11807 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11808 | __func__, status); |
| 11809 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11810 | status = -EINVAL; |
| 11811 | goto end; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11812 | } |
| 11813 | } |
| 11814 | } |
| 11815 | |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11816 | end: |
| 11817 | /* Need to clear any trace of key value in the memory. |
| 11818 | * Thus zero out the memory even though it is local |
| 11819 | * variable. |
| 11820 | */ |
| 11821 | vos_mem_zero(&setKey, sizeof(setKey)); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11822 | EXIT(); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 11823 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11824 | } |
| 11825 | |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11826 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11827 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
| 11828 | struct net_device *ndev, |
| 11829 | u8 key_index, bool pairwise, |
| 11830 | const u8 *mac_addr, |
| 11831 | struct key_params *params |
| 11832 | ) |
| 11833 | #else |
| 11834 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
| 11835 | struct net_device *ndev, |
| 11836 | u8 key_index, const u8 *mac_addr, |
| 11837 | struct key_params *params |
| 11838 | ) |
| 11839 | #endif |
| 11840 | { |
| 11841 | int ret; |
| 11842 | vos_ssr_protect(__func__); |
| 11843 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11844 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise, |
| 11845 | mac_addr, params); |
| 11846 | #else |
| 11847 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr, |
| 11848 | params); |
| 11849 | #endif |
| 11850 | vos_ssr_unprotect(__func__); |
| 11851 | |
| 11852 | return ret; |
| 11853 | } |
| 11854 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11855 | /* |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11856 | * FUNCTION: __wlan_hdd_cfg80211_get_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11857 | * This function is used to get the key information |
| 11858 | */ |
| 11859 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11860 | static int __wlan_hdd_cfg80211_get_key( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11861 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11862 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11863 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11864 | const u8 *mac_addr, void *cookie, |
| 11865 | void (*callback)(void *cookie, struct key_params*) |
| 11866 | ) |
| 11867 | #else |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11868 | static int __wlan_hdd_cfg80211_get_key( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11869 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11870 | struct net_device *ndev, |
| 11871 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 11872 | void (*callback)(void *cookie, struct key_params*) |
| 11873 | ) |
| 11874 | #endif |
| 11875 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11876 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11877 | hdd_wext_state_t *pWextState = NULL; |
| 11878 | tCsrRoamProfile *pRoamProfile = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11879 | struct key_params params; |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11880 | hdd_context_t *pHddCtx; |
| 11881 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11882 | |
| 11883 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11884 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11885 | if (NULL == pAdapter) |
| 11886 | { |
| 11887 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11888 | "%s: HDD adapter is Null", __func__); |
| 11889 | return -ENODEV; |
| 11890 | } |
| 11891 | |
| 11892 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11893 | ret = wlan_hdd_validate_context(pHddCtx); |
| 11894 | if (0 != ret) |
| 11895 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 11896 | return ret; |
| 11897 | } |
| 11898 | |
| 11899 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11900 | pRoamProfile = &(pWextState->roamProfile); |
| 11901 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 11902 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 11903 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 11904 | pAdapter->device_mode); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11905 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11906 | memset(¶ms, 0, sizeof(params)); |
| 11907 | |
| 11908 | if (CSR_MAX_NUM_KEY <= key_index) |
| 11909 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11910 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11911 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11912 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11913 | |
| 11914 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 11915 | { |
| 11916 | case eCSR_ENCRYPT_TYPE_NONE: |
| 11917 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 11918 | break; |
| 11919 | |
| 11920 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 11921 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 11922 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 11923 | break; |
| 11924 | |
| 11925 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 11926 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 11927 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 11928 | break; |
| 11929 | |
| 11930 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 11931 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 11932 | break; |
| 11933 | |
| 11934 | case eCSR_ENCRYPT_TYPE_AES: |
| 11935 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 11936 | break; |
| 11937 | |
| 11938 | default: |
| 11939 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 11940 | break; |
| 11941 | } |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11942 | |
c_hpothu | aaf1969 | 2014-05-17 17:01:48 +0530 | [diff] [blame] | 11943 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11944 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
| 11945 | pAdapter->sessionId, params.cipher)); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11946 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11947 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 11948 | params.seq_len = 0; |
| 11949 | params.seq = NULL; |
| 11950 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 11951 | callback(cookie, ¶ms); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11952 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11953 | return 0; |
| 11954 | } |
| 11955 | |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 11956 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11957 | static int wlan_hdd_cfg80211_get_key( |
| 11958 | struct wiphy *wiphy, |
| 11959 | struct net_device *ndev, |
| 11960 | u8 key_index, bool pairwise, |
| 11961 | const u8 *mac_addr, void *cookie, |
| 11962 | void (*callback)(void *cookie, struct key_params*) |
| 11963 | ) |
| 11964 | #else |
| 11965 | static int wlan_hdd_cfg80211_get_key( |
| 11966 | struct wiphy *wiphy, |
| 11967 | struct net_device *ndev, |
| 11968 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 11969 | void (*callback)(void *cookie, struct key_params*) |
| 11970 | ) |
| 11971 | #endif |
| 11972 | { |
| 11973 | int ret; |
| 11974 | |
| 11975 | vos_ssr_protect(__func__); |
| 11976 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11977 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise, |
| 11978 | mac_addr, cookie, callback); |
| 11979 | #else |
| 11980 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr, |
| 11981 | callback); |
| 11982 | #endif |
| 11983 | vos_ssr_unprotect(__func__); |
| 11984 | |
| 11985 | return ret; |
| 11986 | } |
| 11987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11988 | /* |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11989 | * FUNCTION: __wlan_hdd_cfg80211_del_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11990 | * This function is used to delete the key information |
| 11991 | */ |
| 11992 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11993 | static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11994 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11995 | u8 key_index, |
| 11996 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11997 | const u8 *mac_addr |
| 11998 | ) |
| 11999 | #else |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 12000 | static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12001 | struct net_device *ndev, |
| 12002 | u8 key_index, |
| 12003 | const u8 *mac_addr |
| 12004 | ) |
| 12005 | #endif |
| 12006 | { |
| 12007 | int status = 0; |
| 12008 | |
| 12009 | //This code needs to be revisited. There is sme_removeKey API, we should |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12010 | //plan to use that. After the change to use correct index in setkey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12011 | //it is observed that this is invalidating peer |
| 12012 | //key index whenever re-key is done. This is affecting data link. |
| 12013 | //It should be ok to ignore del_key. |
| 12014 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12015 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 12016 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12017 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 12018 | tCsrRoamSetKey setKey; |
| 12019 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12020 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12021 | ENTER(); |
| 12022 | |
| 12023 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 12024 | __func__,pAdapter->device_mode); |
| 12025 | |
| 12026 | if (CSR_MAX_NUM_KEY <= key_index) |
| 12027 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12028 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12029 | key_index); |
| 12030 | |
| 12031 | return -EINVAL; |
| 12032 | } |
| 12033 | |
| 12034 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 12035 | setKey.keyId = key_index; |
| 12036 | |
| 12037 | if (mac_addr) |
| 12038 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 12039 | else |
| 12040 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 12041 | |
| 12042 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 12043 | |
| 12044 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12045 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12046 | ) |
| 12047 | { |
| 12048 | |
| 12049 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12050 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 12051 | if( pHostapdState->bssState == BSS_START) |
| 12052 | { |
| 12053 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12054 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12055 | if ( status != eHAL_STATUS_SUCCESS ) |
| 12056 | { |
| 12057 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12058 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 12059 | __LINE__, status ); |
| 12060 | } |
| 12061 | } |
| 12062 | } |
| 12063 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12064 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12065 | ) |
| 12066 | { |
| 12067 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12068 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12069 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 12070 | |
| 12071 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12072 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12073 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 12074 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12075 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12076 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 12077 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12078 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12079 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12080 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12081 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12082 | if ( 0 != status ) |
| 12083 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12084 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12085 | "%s: sme_RoamSetKey failure, returned %d", |
| 12086 | __func__, status); |
| 12087 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 12088 | return -EINVAL; |
| 12089 | } |
| 12090 | } |
| 12091 | } |
| 12092 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12093 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12094 | return status; |
| 12095 | } |
| 12096 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 12097 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12098 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
| 12099 | struct net_device *ndev, |
| 12100 | u8 key_index, |
| 12101 | bool pairwise, |
| 12102 | const u8 *mac_addr |
| 12103 | ) |
| 12104 | #else |
| 12105 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
| 12106 | struct net_device *ndev, |
| 12107 | u8 key_index, |
| 12108 | const u8 *mac_addr |
| 12109 | ) |
| 12110 | #endif |
| 12111 | { |
| 12112 | int ret; |
| 12113 | |
| 12114 | vos_ssr_protect(__func__); |
| 12115 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12116 | ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise, |
| 12117 | mac_addr); |
| 12118 | #else |
| 12119 | ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr); |
| 12120 | #endif |
| 12121 | vos_ssr_unprotect(__func__); |
| 12122 | |
| 12123 | return ret; |
| 12124 | } |
| 12125 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12126 | /* |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 12127 | * FUNCTION: __wlan_hdd_cfg80211_set_default_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12128 | * This function is used to set the default tx key index |
| 12129 | */ |
| 12130 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 12131 | static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12132 | struct net_device *ndev, |
| 12133 | u8 key_index, |
| 12134 | bool unicast, bool multicast) |
| 12135 | #else |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 12136 | static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12137 | struct net_device *ndev, |
| 12138 | u8 key_index) |
| 12139 | #endif |
| 12140 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12141 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12142 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12143 | hdd_wext_state_t *pWextState; |
| 12144 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12145 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12146 | |
| 12147 | ENTER(); |
| 12148 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12149 | if ((NULL == pAdapter)) |
| 12150 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 12151 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12152 | "invalid adapter"); |
| 12153 | return -EINVAL; |
| 12154 | } |
| 12155 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12156 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 12157 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
| 12158 | pAdapter->sessionId, key_index)); |
| 12159 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12160 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 12161 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12162 | |
| 12163 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 12164 | { |
| 12165 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 12166 | "invalid Wext state or HDD context"); |
| 12167 | return -EINVAL; |
| 12168 | } |
| 12169 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12170 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12171 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12172 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12173 | if (CSR_MAX_NUM_KEY <= key_index) |
| 12174 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12175 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12176 | key_index); |
| 12177 | |
| 12178 | return -EINVAL; |
| 12179 | } |
| 12180 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12181 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12182 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12183 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12184 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12185 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12186 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12187 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12188 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12189 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12190 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12191 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12192 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 12193 | pHddStaCtx->conn_info.ucEncryptionType) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12194 | (eCSR_ENCRYPT_TYPE_AES != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 12195 | pHddStaCtx->conn_info.ucEncryptionType) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12196 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12197 | { |
| 12198 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12199 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12200 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12201 | tCsrRoamSetKey setKey; |
| 12202 | v_U32_t roamId= 0xFF; |
| 12203 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12204 | |
| 12205 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12206 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12208 | Keys->defaultIndex = (u8)key_index; |
| 12209 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 12210 | setKey.keyId = key_index; |
| 12211 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12212 | |
| 12213 | vos_mem_copy(&setKey.Key[0], |
| 12214 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12215 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12216 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12217 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12218 | |
| 12219 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12220 | &pHddStaCtx->conn_info.bssId[0], |
| 12221 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12222 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 12223 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 12224 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 12225 | eCSR_ENCRYPT_TYPE_WEP104) |
| 12226 | { |
| 12227 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 12228 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 12229 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 12230 | type(104) and switching encryption type to 40*/ |
| 12231 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 12232 | eCSR_ENCRYPT_TYPE_WEP40; |
| 12233 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 12234 | eCSR_ENCRYPT_TYPE_WEP40; |
| 12235 | } |
| 12236 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12237 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12238 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12239 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12240 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12241 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12242 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12243 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12244 | if ( 0 != status ) |
| 12245 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12246 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12247 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12248 | status); |
| 12249 | return -EINVAL; |
| 12250 | } |
| 12251 | } |
| 12252 | } |
| 12253 | |
| 12254 | /* In SoftAp mode setting key direction for default mode */ |
| 12255 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 12256 | { |
| 12257 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 12258 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 12259 | (eCSR_ENCRYPT_TYPE_AES != |
| 12260 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 12261 | ) |
| 12262 | { |
| 12263 | /* Saving key direction for default key index to TX default */ |
| 12264 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 12265 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 12266 | } |
| 12267 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 12268 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12269 | return status; |
| 12270 | } |
| 12271 | |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 12272 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12273 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 12274 | struct net_device *ndev, |
| 12275 | u8 key_index, |
| 12276 | bool unicast, bool multicast) |
| 12277 | #else |
| 12278 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 12279 | struct net_device *ndev, |
| 12280 | u8 key_index) |
| 12281 | #endif |
| 12282 | { |
| 12283 | int ret; |
| 12284 | vos_ssr_protect(__func__); |
| 12285 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12286 | ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast, |
| 12287 | multicast); |
| 12288 | #else |
| 12289 | ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index); |
| 12290 | #endif |
| 12291 | vos_ssr_unprotect(__func__); |
| 12292 | |
| 12293 | return ret; |
| 12294 | } |
| 12295 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12296 | /* |
| 12297 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 12298 | * This function is used to inform the BSS details to nl80211 interface. |
| 12299 | */ |
| 12300 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 12301 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 12302 | { |
| 12303 | struct net_device *dev = pAdapter->dev; |
| 12304 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 12305 | struct wiphy *wiphy = wdev->wiphy; |
| 12306 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 12307 | int chan_no; |
| 12308 | int ie_length; |
| 12309 | const char *ie; |
| 12310 | unsigned int freq; |
| 12311 | struct ieee80211_channel *chan; |
| 12312 | int rssi = 0; |
| 12313 | struct cfg80211_bss *bss = NULL; |
| 12314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12315 | if( NULL == pBssDesc ) |
| 12316 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12317 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12318 | return bss; |
| 12319 | } |
| 12320 | |
| 12321 | chan_no = pBssDesc->channelId; |
| 12322 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 12323 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 12324 | |
| 12325 | if( NULL == ie ) |
| 12326 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12327 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12328 | return bss; |
| 12329 | } |
| 12330 | |
| 12331 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 12332 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 12333 | { |
| 12334 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 12335 | } |
| 12336 | else |
| 12337 | { |
| 12338 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 12339 | } |
| 12340 | #else |
| 12341 | freq = ieee80211_channel_to_frequency(chan_no); |
| 12342 | #endif |
| 12343 | |
| 12344 | chan = __ieee80211_get_channel(wiphy, freq); |
| 12345 | |
Santhosh Kumar Padma | a45fdb1 | 2014-04-15 15:54:38 +0530 | [diff] [blame] | 12346 | if (!chan) { |
| 12347 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__); |
| 12348 | return NULL; |
| 12349 | } |
| 12350 | |
Abhishek Singh | aee4394 | 2014-06-16 18:55:47 +0530 | [diff] [blame] | 12351 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12352 | |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 12353 | return cfg80211_inform_bss(wiphy, chan, |
| 12354 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 12355 | CFG80211_BSS_FTYPE_UNKNOWN, |
| 12356 | #endif |
| 12357 | pBssDesc->bssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12358 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12359 | pBssDesc->capabilityInfo, |
| 12360 | pBssDesc->beaconInterval, ie, ie_length, |
Abhishek Singh | aee4394 | 2014-06-16 18:55:47 +0530 | [diff] [blame] | 12361 | rssi, GFP_KERNEL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12362 | } |
| 12363 | |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 12364 | /* |
| 12365 | * wlan_hdd_cfg80211_update_bss_list :to inform nl80211 |
| 12366 | * interface that BSS might have been lost. |
| 12367 | * @pAdapter: adaptor |
| 12368 | * @bssid: bssid which might have been lost |
| 12369 | * |
| 12370 | * Return: bss which is unlinked from kernel cache |
| 12371 | */ |
| 12372 | struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_list( |
| 12373 | hdd_adapter_t *pAdapter, tSirMacAddr bssid) |
| 12374 | { |
| 12375 | struct net_device *dev = pAdapter->dev; |
| 12376 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 12377 | struct wiphy *wiphy = wdev->wiphy; |
| 12378 | struct cfg80211_bss *bss = NULL; |
| 12379 | |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 12380 | bss = hdd_get_bss_entry(wiphy, |
| 12381 | NULL, bssid, |
| 12382 | NULL, 0); |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 12383 | if (bss == NULL) { |
| 12384 | hddLog(LOGE, FL("BSS not present")); |
| 12385 | } else { |
| 12386 | hddLog(LOG1, FL("cfg80211_unlink_bss called for BSSID " |
| 12387 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(bssid)); |
| 12388 | cfg80211_unlink_bss(wiphy, bss); |
| 12389 | } |
| 12390 | return bss; |
| 12391 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12392 | |
| 12393 | |
| 12394 | /* |
| 12395 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 12396 | * This function is used to inform the BSS details to nl80211 interface. |
| 12397 | */ |
| 12398 | struct cfg80211_bss* |
| 12399 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 12400 | tSirBssDescription *bss_desc |
| 12401 | ) |
| 12402 | { |
| 12403 | /* |
| 12404 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 12405 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 12406 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 12407 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 12408 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 12409 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 12410 | cfg80211_inform_bss_frame. |
| 12411 | */ |
| 12412 | struct net_device *dev = pAdapter->dev; |
| 12413 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 12414 | struct wiphy *wiphy = wdev->wiphy; |
| 12415 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 12416 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 12417 | qcom_ie_age *qie_age = NULL; |
| 12418 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 12419 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12420 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ); |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 12421 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12422 | const char *ie = |
| 12423 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 12424 | unsigned int freq; |
| 12425 | struct ieee80211_channel *chan; |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 12426 | struct ieee80211_mgmt *mgmt = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12427 | struct cfg80211_bss *bss_status = NULL; |
| 12428 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 12429 | int rssi = 0; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12430 | hdd_context_t *pHddCtx; |
| 12431 | int status; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12432 | #ifdef WLAN_OPEN_SOURCE |
| 12433 | struct timespec ts; |
| 12434 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12435 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 12436 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12437 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12438 | status = wlan_hdd_validate_context(pHddCtx); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12439 | if (0 != status) |
| 12440 | { |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 12441 | return NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12442 | } |
| 12443 | |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 12444 | mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12445 | if (!mgmt) |
| 12446 | { |
| 12447 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12448 | "%s: memory allocation failed ", __func__); |
| 12449 | return NULL; |
| 12450 | } |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 12451 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12452 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12453 | |
| 12454 | #ifdef WLAN_OPEN_SOURCE |
| 12455 | /* Android does not want the timestamp from the frame. |
| 12456 | Instead it wants a monotonic increasing value */ |
| 12457 | get_monotonic_boottime(&ts); |
| 12458 | mgmt->u.probe_resp.timestamp = |
| 12459 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 12460 | #else |
| 12461 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12462 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 12463 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12464 | |
| 12465 | #endif |
| 12466 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12467 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 12468 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 12469 | |
| 12470 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 12471 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 12472 | /* Assuming this is the last IE, copy at the end */ |
| 12473 | ie_length -=sizeof(qcom_ie_age); |
| 12474 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 12475 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 12476 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 12477 | qie_age->oui_1 = QCOM_OUI1; |
| 12478 | qie_age->oui_2 = QCOM_OUI2; |
| 12479 | qie_age->oui_3 = QCOM_OUI3; |
| 12480 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
Selvaraj, Sridhar | 4b3a836 | 2016-10-12 12:34:08 +0530 | [diff] [blame] | 12481 | /* Lowi expects the timestamp of bss in units of 1/10 ms. In driver all |
| 12482 | * bss related timestamp is in units of ms. Due to this when scan results |
| 12483 | * are sent to lowi the scan age is high.To address this, send age in units |
| 12484 | * of 1/10 ms. |
| 12485 | */ |
| 12486 | qie_age->age = (vos_timer_get_system_time() - |
| 12487 | bss_desc->nReceivedTime)/10; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 12488 | #endif |
| 12489 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12490 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 12491 | if (bss_desc->fProbeRsp) |
| 12492 | { |
| 12493 | mgmt->frame_control |= |
| 12494 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 12495 | } |
| 12496 | else |
| 12497 | { |
| 12498 | mgmt->frame_control |= |
| 12499 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 12500 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12501 | |
| 12502 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12503 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12504 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 12505 | { |
| 12506 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 12507 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12508 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12509 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 12510 | |
| 12511 | { |
| 12512 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 12513 | } |
| 12514 | else |
| 12515 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 12516 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d", |
| 12517 | __func__, chan_no); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12518 | kfree(mgmt); |
| 12519 | return NULL; |
| 12520 | } |
| 12521 | #else |
| 12522 | freq = ieee80211_channel_to_frequency(chan_no); |
| 12523 | #endif |
| 12524 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 12525 | /*when the band is changed on the fly using the GUI, three things are done |
| 12526 | * 1. scan abort 2.flush scan results from cache 3.update the band with the new band user specified(refer to the hdd_setBand_helper function) |
| 12527 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 12528 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 12529 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 12530 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 12531 | * but if the time between band update and scan done callback is very small then band change will not reflect in SME and SME reports to HDD |
| 12532 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 12533 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 12534 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 12535 | * So drop the bss and continue to next bss. |
| 12536 | */ |
| 12537 | if(chan == NULL) |
| 12538 | { |
Deepthi Gowri | 306657b | 2016-04-28 17:10:41 +0530 | [diff] [blame] | 12539 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12540 | FL("chan pointer is NULL, chan_no: %d freq: %d"), |
| 12541 | chan_no, freq); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 12542 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 12543 | return NULL; |
| 12544 | } |
Hanumantha Reddy Pothula | 904bcef | 2015-06-19 11:56:29 +0530 | [diff] [blame] | 12545 | /*To keep the rssi icon of the connected AP in the scan window |
| 12546 | *and the rssi icon of the wireless networks in sync |
| 12547 | * */ |
| 12548 | if (( eConnectionState_Associated == |
| 12549 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 12550 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 12551 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 12552 | WNI_CFG_BSSID_LEN)) && |
| 12553 | (pHddCtx->hdd_wlan_suspended == FALSE)) |
| 12554 | { |
| 12555 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 12556 | rssi = (pAdapter->rssi * 100); |
| 12557 | } |
| 12558 | else |
| 12559 | { |
| 12560 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 12561 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12562 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 12563 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d" |
Sushant Kaushik | 0b34342 | 2015-05-25 17:15:55 +0530 | [diff] [blame] | 12564 | " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid), |
| 12565 | vos_freq_to_chan(chan->center_freq), (int)(rssi/100)); |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 12566 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12567 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 12568 | frame_len, rssi, GFP_KERNEL); |
| 12569 | kfree(mgmt); |
| 12570 | return bss_status; |
| 12571 | } |
| 12572 | |
| 12573 | /* |
| 12574 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 12575 | * This function is used to update the BSS data base of CFG8011 |
| 12576 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12577 | struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12578 | tCsrRoamInfo *pRoamInfo |
| 12579 | ) |
| 12580 | { |
| 12581 | tCsrRoamConnectedProfile roamProfile; |
| 12582 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 12583 | struct cfg80211_bss *bss = NULL; |
| 12584 | |
| 12585 | ENTER(); |
| 12586 | |
| 12587 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 12588 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 12589 | |
| 12590 | if (NULL != roamProfile.pBssDesc) |
| 12591 | { |
Girish Gowli | f4b6802 | 2014-08-28 23:18:57 +0530 | [diff] [blame] | 12592 | bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 12593 | roamProfile.pBssDesc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12594 | |
| 12595 | if (NULL == bss) |
| 12596 | { |
| 12597 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 12598 | __func__); |
| 12599 | } |
| 12600 | |
| 12601 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 12602 | } |
| 12603 | else |
| 12604 | { |
| 12605 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 12606 | __func__); |
| 12607 | } |
| 12608 | return bss; |
| 12609 | } |
| 12610 | |
| 12611 | /* |
| 12612 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 12613 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12614 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 12615 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12616 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12617 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 12618 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12619 | tCsrScanResultInfo *pScanResult; |
| 12620 | eHalStatus status = 0; |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 12621 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12622 | tScanResultHandle pResult; |
| 12623 | struct cfg80211_bss *bss_status = NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12624 | hdd_context_t *pHddCtx; |
Deepthi Gowri | 10d0ae1 | 2015-05-25 14:39:50 +0530 | [diff] [blame] | 12625 | bool is_p2p_scan = false; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12626 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 12627 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12628 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 12629 | TRACE_CODE_HDD_CFG80211_UPDATE_BSS, |
| 12630 | NO_SESSION, pAdapter->sessionId)); |
| 12631 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12632 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 12633 | ret = wlan_hdd_validate_context(pHddCtx); |
| 12634 | if (0 != ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12635 | { |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 12636 | return ret; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 12637 | } |
| 12638 | |
Deepthi Gowri | 10d0ae1 | 2015-05-25 14:39:50 +0530 | [diff] [blame] | 12639 | if (pAdapter->request != NULL) |
| 12640 | { |
| 12641 | if ((pAdapter->request->n_ssids == 1) |
| 12642 | && (pAdapter->request->ssids != NULL) |
| 12643 | && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7)) |
| 12644 | is_p2p_scan = true; |
| 12645 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12646 | /* |
| 12647 | * start getting scan results and populate cgf80211 BSS database |
| 12648 | */ |
| 12649 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 12650 | |
| 12651 | /* no scan results */ |
| 12652 | if (NULL == pResult) |
| 12653 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 12654 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d", |
| 12655 | __func__, status); |
Mahesh A Saptasagar | 51dc36c | 2015-06-16 12:07:15 +0530 | [diff] [blame] | 12656 | wlan_hdd_get_frame_logs(pAdapter, |
| 12657 | WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12658 | return status; |
| 12659 | } |
| 12660 | |
| 12661 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 12662 | |
| 12663 | while (pScanResult) |
| 12664 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12665 | /* |
| 12666 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 12667 | * entry already exists in bss data base of cfg80211 for that |
| 12668 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 12669 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 12670 | * mgmt packet as input. As of now there is no possibility to get |
| 12671 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12672 | * ieee80211_mgmt(probe response) and passing to c |
| 12673 | * fg80211_inform_bss_frame. |
| 12674 | * */ |
Deepthi Gowri | 10d0ae1 | 2015-05-25 14:39:50 +0530 | [diff] [blame] | 12675 | if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) && |
| 12676 | !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) ) |
| 12677 | { |
Deepthi Gowri | 10d0ae1 | 2015-05-25 14:39:50 +0530 | [diff] [blame] | 12678 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 12679 | continue; //Skip the non p2p bss entries |
| 12680 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12681 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 12682 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12683 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12684 | |
| 12685 | if (NULL == bss_status) |
| 12686 | { |
| 12687 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12688 | "%s: NULL returned by cfg80211_inform_bss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12689 | } |
| 12690 | else |
| 12691 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 12692 | cfg80211_put_bss( |
| 12693 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 12694 | wiphy, |
| 12695 | #endif |
| 12696 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12697 | } |
| 12698 | |
| 12699 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 12700 | } |
| 12701 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12702 | sme_ScanResultPurge(hHal, pResult); |
Deepthi Gowri | 10d0ae1 | 2015-05-25 14:39:50 +0530 | [diff] [blame] | 12703 | is_p2p_scan = false; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12704 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12705 | } |
| 12706 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12707 | void |
| 12708 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 12709 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12710 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 12711 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12712 | } /****** end hddPrintMacAddr() ******/ |
| 12713 | |
| 12714 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 12715 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12716 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12717 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12718 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 12719 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 12720 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 12721 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12722 | } /****** end hddPrintPmkId() ******/ |
| 12723 | |
| 12724 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 12725 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 12726 | |
| 12727 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 12728 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 12729 | |
| 12730 | #define dump_bssid(bssid) \ |
| 12731 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12732 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 12733 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12734 | } |
| 12735 | |
| 12736 | #define dump_pmkid(pMac, pmkid) \ |
| 12737 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12738 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 12739 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12740 | } |
| 12741 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 12742 | #if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12743 | /* |
| 12744 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 12745 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 12746 | */ |
| 12747 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12748 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12749 | int index, bool preauth ) |
| 12750 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12751 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12752 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 12753 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12754 | |
| 12755 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12756 | hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12757 | |
| 12758 | if( NULL == pRoamInfo ) |
| 12759 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12760 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12761 | return -EINVAL; |
| 12762 | } |
| 12763 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 12764 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 12765 | { |
| 12766 | dump_bssid(pRoamInfo->bssid); |
| 12767 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12768 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 12769 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12770 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12771 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12772 | } |
| 12773 | #endif //FEATURE_WLAN_LFR |
| 12774 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 12775 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 12776 | /* |
| 12777 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth |
| 12778 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 12779 | * |
| 12780 | */ |
| 12781 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
| 12782 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
| 12783 | tCsrRoamInfo *pRoamInfo) |
| 12784 | { |
| 12785 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 12786 | union iwreq_data wrqu; |
| 12787 | |
| 12788 | ENTER(); |
| 12789 | |
| 12790 | if (NULL == pAdapter) |
| 12791 | { |
| 12792 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 12793 | return VOS_STATUS_E_FAILURE; |
| 12794 | } |
| 12795 | |
| 12796 | /* create the event */ |
| 12797 | memset(&wrqu, 0, sizeof(wrqu)); |
| 12798 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 12799 | |
| 12800 | wrqu.data.pointer = metrics_notification; |
| 12801 | wrqu.data.length = scnprintf(metrics_notification, |
| 12802 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT " |
| 12803 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 12804 | |
| 12805 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 12806 | |
| 12807 | EXIT(); |
| 12808 | |
| 12809 | return VOS_STATUS_SUCCESS; |
| 12810 | } |
| 12811 | |
| 12812 | /* |
| 12813 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status |
| 12814 | * 802.11r/LFR metrics reporting function to report preauth completion |
| 12815 | * or failure |
| 12816 | */ |
| 12817 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status( |
| 12818 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status) |
| 12819 | { |
| 12820 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 12821 | union iwreq_data wrqu; |
| 12822 | |
| 12823 | ENTER(); |
| 12824 | |
| 12825 | if (NULL == pAdapter) |
| 12826 | { |
| 12827 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 12828 | return VOS_STATUS_E_FAILURE; |
| 12829 | } |
| 12830 | |
| 12831 | /* create the event */ |
| 12832 | memset(&wrqu, 0, sizeof(wrqu)); |
| 12833 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 12834 | |
| 12835 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 12836 | "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR, |
| 12837 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 12838 | |
| 12839 | if (1 == preauth_status) |
| 12840 | strncat(metrics_notification, " TRUE", 5); |
| 12841 | else |
| 12842 | strncat(metrics_notification, " FALSE", 6); |
| 12843 | |
| 12844 | wrqu.data.pointer = metrics_notification; |
| 12845 | wrqu.data.length = strlen(metrics_notification); |
| 12846 | |
| 12847 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 12848 | |
| 12849 | EXIT(); |
| 12850 | |
| 12851 | return VOS_STATUS_SUCCESS; |
| 12852 | } |
| 12853 | |
| 12854 | /* |
| 12855 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover |
| 12856 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 12857 | * |
| 12858 | */ |
| 12859 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter, |
| 12860 | tCsrRoamInfo *pRoamInfo) |
| 12861 | { |
| 12862 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 12863 | union iwreq_data wrqu; |
| 12864 | |
| 12865 | ENTER(); |
| 12866 | |
| 12867 | if (NULL == pAdapter) |
| 12868 | { |
| 12869 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 12870 | return VOS_STATUS_E_FAILURE; |
| 12871 | } |
| 12872 | |
| 12873 | /* create the event */ |
| 12874 | memset(&wrqu, 0, sizeof(wrqu)); |
| 12875 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 12876 | |
| 12877 | wrqu.data.pointer = metrics_notification; |
| 12878 | wrqu.data.length = scnprintf(metrics_notification, |
| 12879 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER " |
| 12880 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 12881 | |
| 12882 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 12883 | |
| 12884 | EXIT(); |
| 12885 | |
| 12886 | return VOS_STATUS_SUCCESS; |
| 12887 | } |
| 12888 | #endif |
| 12889 | |
Manjeet Singh | aaee9cd | 2016-09-13 19:23:30 +0530 | [diff] [blame] | 12890 | |
| 12891 | /** |
| 12892 | * wlan_hdd_cfg80211_validate_scan_req - validate scan request |
| 12893 | * @scan_req: scan request to be checked |
| 12894 | * |
| 12895 | * Return: true or false |
| 12896 | */ |
| 12897 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 12898 | static inline bool wlan_hdd_cfg80211_validate_scan_req(struct |
| 12899 | cfg80211_scan_request |
| 12900 | *scan_req) |
| 12901 | { |
| 12902 | if (!scan_req || !scan_req->wiphy) { |
| 12903 | hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request"); |
| 12904 | return false; |
| 12905 | } |
| 12906 | if (vos_is_load_unload_in_progress(VOS_MODULE_ID_HDD, NULL)) { |
| 12907 | hddLog(VOS_TRACE_LEVEL_ERROR, "Load/Unload in progress"); |
| 12908 | return false; |
| 12909 | } |
| 12910 | return true; |
| 12911 | } |
| 12912 | #else |
| 12913 | static inline bool wlan_hdd_cfg80211_validate_scan_req(struct |
| 12914 | cfg80211_scan_request |
| 12915 | *scan_req) |
| 12916 | { |
| 12917 | if (!scan_req || !scan_req->wiphy) { |
| 12918 | hddLog(VOS_TRACE_LEVEL_ERROR, "Invalid scan request"); |
| 12919 | return false; |
| 12920 | } |
| 12921 | return true; |
| 12922 | } |
| 12923 | #endif |
| 12924 | |
| 12925 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12926 | /* |
| 12927 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 12928 | * scanning callback function, called after finishing scan |
| 12929 | * |
| 12930 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12931 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12932 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 12933 | { |
| 12934 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12935 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12936 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 12937 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12938 | struct cfg80211_scan_request *req = NULL; |
| 12939 | int ret = 0; |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 12940 | bool aborted = false; |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 12941 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 12942 | bool iface_down = false; |
| 12943 | #endif |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12944 | long waitRet = 0; |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 12945 | tANI_U8 i; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 12946 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12947 | |
| 12948 | ENTER(); |
| 12949 | |
c_manjee | 1b4ab9a | 2016-10-26 11:36:55 +0530 | [diff] [blame] | 12950 | if (!pAdapter || pAdapter->magic != WLAN_HDD_ADAPTER_MAGIC || |
| 12951 | !pAdapter->dev) { |
| 12952 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Adapter is not valid")); |
| 12953 | return 0; |
| 12954 | } |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 12955 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Siddharth Bhal | 5c2e02d | 2015-05-05 17:35:29 +0530 | [diff] [blame] | 12956 | if (NULL == pHddCtx) { |
| 12957 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null")); |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 12958 | return 0; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 12959 | } |
| 12960 | |
Mahesh A Saptasagar | 1129675 | 2016-01-07 17:53:02 +0530 | [diff] [blame] | 12961 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 12962 | if (!(pAdapter->dev->flags & IFF_UP)) |
| 12963 | { |
| 12964 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Interface is down")); |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 12965 | iface_down = true; |
Mahesh A Saptasagar | 1129675 | 2016-01-07 17:53:02 +0530 | [diff] [blame] | 12966 | } |
| 12967 | #endif |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 12968 | pScanInfo = &pHddCtx->scan_info; |
| 12969 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12970 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12971 | "%s called with halHandle = %p, pContext = %p," |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12972 | "scanID = %d, returned status = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12973 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 12974 | |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 12975 | pScanInfo->mScanPendingCounter = 0; |
| 12976 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12977 | //Block on scan req completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12978 | waitRet = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12979 | &pScanInfo->scan_req_completion_event, |
| 12980 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12981 | if (waitRet <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12982 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12983 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12984 | "%s wait on scan_req_completion_event failed %ld",__func__, waitRet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12985 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12986 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12987 | } |
| 12988 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 12989 | if (pScanInfo->mScanPending != VOS_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12990 | { |
| 12991 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12992 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12993 | } |
| 12994 | |
| 12995 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12996 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12997 | { |
| 12998 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12999 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 13000 | "scanId = %d", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13001 | (int) scanId); |
| 13002 | } |
| 13003 | |
Mahesh A Saptasagar | 9dd7284 | 2016-04-15 19:45:14 +0530 | [diff] [blame] | 13004 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13005 | if (!iface_down) |
Mahesh A Saptasagar | 9dd7284 | 2016-04-15 19:45:14 +0530 | [diff] [blame] | 13006 | #endif |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13007 | { |
| 13008 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
| 13009 | pAdapter); |
| 13010 | if (0 > ret) |
| 13011 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | 9dd7284 | 2016-04-15 19:45:14 +0530 | [diff] [blame] | 13012 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13013 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13014 | /* If any client wait scan result through WEXT |
| 13015 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13016 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13017 | { |
| 13018 | /* The other scan request waiting for current scan finish |
| 13019 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13020 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13021 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13022 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13023 | } |
| 13024 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13025 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13026 | { |
| 13027 | struct net_device *dev = pAdapter->dev; |
| 13028 | union iwreq_data wrqu; |
| 13029 | int we_event; |
| 13030 | char *msg; |
| 13031 | |
| 13032 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 13033 | we_event = SIOCGIWSCAN; |
| 13034 | msg = NULL; |
| 13035 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 13036 | } |
| 13037 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13038 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13039 | |
| 13040 | /* Get the Scan Req */ |
| 13041 | req = pAdapter->request; |
mukul sharma | e704182 | 2015-12-03 15:09:21 +0530 | [diff] [blame] | 13042 | pAdapter->request = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13043 | |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13044 | /* Scan is no longer pending */ |
| 13045 | pScanInfo->mScanPending = VOS_FALSE; |
| 13046 | |
Manjeet Singh | aaee9cd | 2016-09-13 19:23:30 +0530 | [diff] [blame] | 13047 | if (!wlan_hdd_cfg80211_validate_scan_req(req)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13048 | { |
Manjeet Singh | aaee9cd | 2016-09-13 19:23:30 +0530 | [diff] [blame] | 13049 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 13050 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("interface state %s"), |
| 13051 | iface_down ? "up" : "down"); |
| 13052 | #endif |
| 13053 | |
| 13054 | if (pAdapter->dev) { |
| 13055 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("device name %s"), |
| 13056 | pAdapter->dev->name); |
| 13057 | } |
mukul sharma | e704182 | 2015-12-03 15:09:21 +0530 | [diff] [blame] | 13058 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13059 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13060 | } |
| 13061 | |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13062 | /* last_scan_timestamp is used to decide if new scan |
| 13063 | * is needed or not on station interface. If last station |
| 13064 | * scan time and new station scan time is less then |
| 13065 | * last_scan_timestamp ; driver will return cached scan. |
| 13066 | */ |
| 13067 | if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find |
| 13068 | { |
| 13069 | pScanInfo->last_scan_timestamp = vos_timer_get_system_time(); |
| 13070 | |
| 13071 | if ( req->n_channels ) |
| 13072 | { |
| 13073 | for (i = 0; i < req->n_channels ; i++ ) |
| 13074 | { |
| 13075 | pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value; |
| 13076 | } |
| 13077 | /* store no of channel scanned */ |
| 13078 | pHddCtx->scan_info.last_scan_numChannels= req->n_channels; |
| 13079 | } |
| 13080 | |
| 13081 | } |
| 13082 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 13083 | /* |
| 13084 | * cfg80211_scan_done informing NL80211 about completion |
| 13085 | * of scanning |
| 13086 | */ |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 13087 | if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE) |
| 13088 | { |
| 13089 | aborted = true; |
| 13090 | } |
mukul sharma | e704182 | 2015-12-03 15:09:21 +0530 | [diff] [blame] | 13091 | |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13092 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 13093 | if (!iface_down) |
| 13094 | #endif |
| 13095 | cfg80211_scan_done(req, aborted); |
mukul sharma | e704182 | 2015-12-03 15:09:21 +0530 | [diff] [blame] | 13096 | |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 13097 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13098 | |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13099 | allow_suspend: |
Hanumantha Reddy Pothula | ca1d1cc | 2015-10-26 15:37:35 +0530 | [diff] [blame] | 13100 | if ((pHddCtx->cfg_ini->enableMacSpoofing == MAC_ADDR_SPOOFING_FW_HOST_ENABLE |
| 13101 | ) && (pHddCtx->spoofMacAddr.isEnabled |
| 13102 | || pHddCtx->spoofMacAddr.isReqDeferred)) { |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 13103 | /* Generate new random mac addr for next scan */ |
| 13104 | hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr"); |
Padma, Santhosh Kumar | db2d75b | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 13105 | |
| 13106 | schedule_delayed_work(&pHddCtx->spoof_mac_addr_work, |
| 13107 | msecs_to_jiffies(MAC_ADDR_SPOOFING_DEFER_INTERVAL)); |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 13108 | } |
| 13109 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 13110 | /* release the wake lock at the end of the scan*/ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13111 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13112 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 13113 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 13114 | * immediatly after the driver gets connect request(i.e after scan) |
| 13115 | * from supplicant, this result in app's is suspending and not able |
| 13116 | * to process the connect request to AP */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13117 | hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 13118 | |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13119 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 13120 | if (!iface_down) |
| 13121 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 13122 | #ifdef FEATURE_WLAN_TDLS |
Mahesh A Saptasagar | 08af5a3 | 2016-06-30 12:29:49 +0530 | [diff] [blame] | 13123 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 13124 | #endif |
| 13125 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13126 | EXIT(); |
| 13127 | return 0; |
| 13128 | } |
| 13129 | |
| 13130 | /* |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 13131 | * FUNCTION: hdd_isConnectionInProgress |
| 13132 | * Go through each adapter and check if Connection is in progress |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13133 | * |
| 13134 | */ |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13135 | v_BOOL_t hdd_isConnectionInProgress(hdd_context_t *pHddCtx, v_U8_t *session_id, |
| 13136 | scan_reject_states *reason) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13137 | { |
| 13138 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 13139 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 13140 | hdd_adapter_t *pAdapter = NULL; |
| 13141 | VOS_STATUS status = 0; |
| 13142 | v_U8_t staId = 0; |
| 13143 | v_U8_t *staMac = NULL; |
| 13144 | |
| 13145 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 13146 | |
| 13147 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 13148 | { |
| 13149 | pAdapter = pAdapterNode->pAdapter; |
| 13150 | |
| 13151 | if( pAdapter ) |
| 13152 | { |
| 13153 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13154 | "%s: Adapter with device mode %s (%d) exists", |
| 13155 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 13156 | pAdapter->device_mode); |
Padma, Santhosh Kumar | 98f271d | 2014-12-31 17:23:31 +0530 | [diff] [blame] | 13157 | if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 13158 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 13159 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) && |
| 13160 | (eConnectionState_Connecting == |
| 13161 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 13162 | { |
| 13163 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13164 | "%s: %p(%d) Connection is in progress", __func__, |
| 13165 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13166 | if (session_id && reason) |
| 13167 | { |
| 13168 | *session_id = pAdapter->sessionId; |
| 13169 | *reason = eHDD_CONNECTION_IN_PROGRESS; |
| 13170 | } |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 13171 | return VOS_TRUE; |
| 13172 | } |
Padma, Santhosh Kumar | 98f271d | 2014-12-31 17:23:31 +0530 | [diff] [blame] | 13173 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Padma, Santhosh Kumar | 3b9657d | 2015-02-04 19:37:32 +0530 | [diff] [blame] | 13174 | smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
Padma, Santhosh Kumar | 98f271d | 2014-12-31 17:23:31 +0530 | [diff] [blame] | 13175 | { |
| 13176 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13177 | "%s: %p(%d) Reassociation is in progress", __func__, |
| 13178 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13179 | if (session_id && reason) |
| 13180 | { |
| 13181 | *session_id = pAdapter->sessionId; |
| 13182 | *reason = eHDD_REASSOC_IN_PROGRESS; |
| 13183 | } |
Padma, Santhosh Kumar | 98f271d | 2014-12-31 17:23:31 +0530 | [diff] [blame] | 13184 | return VOS_TRUE; |
| 13185 | } |
| 13186 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13187 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 13188 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13189 | { |
| 13190 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 13191 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13192 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13193 | { |
| 13194 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 13195 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 13196 | "%s: client " MAC_ADDRESS_STR |
| 13197 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 13198 | MAC_ADDR_ARRAY(staMac)); |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13199 | if (session_id && reason) |
| 13200 | { |
| 13201 | *session_id = pAdapter->sessionId; |
| 13202 | *reason = eHDD_EAPOL_IN_PROGRESS; |
| 13203 | } |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 13204 | return VOS_TRUE; |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13205 | } |
| 13206 | } |
| 13207 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 13208 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 13209 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 13210 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 13211 | ptSapContext pSapCtx = NULL; |
| 13212 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 13213 | if(pSapCtx == NULL){ |
| 13214 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13215 | FL("psapCtx is NULL")); |
| 13216 | return VOS_FALSE; |
| 13217 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13218 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 13219 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 13220 | if ((pSapCtx->aStaInfo[staId].isUsed) && |
| 13221 | (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13222 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 13223 | staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13224 | |
| 13225 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 13226 | "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the " |
| 13227 | "middle of WPS/EAPOL exchange.", __func__, |
| 13228 | MAC_ADDR_ARRAY(staMac)); |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13229 | if (session_id && reason) |
| 13230 | { |
| 13231 | *session_id = pAdapter->sessionId; |
| 13232 | *reason = eHDD_SAP_EAPOL_IN_PROGRESS; |
| 13233 | } |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 13234 | return VOS_TRUE; |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13235 | } |
| 13236 | } |
| 13237 | } |
| 13238 | } |
| 13239 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 13240 | pAdapterNode = pNext; |
| 13241 | } |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 13242 | return VOS_FALSE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13243 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13244 | |
Selvaraj, Sridhar | d2b078a | 2016-06-18 10:44:37 +0530 | [diff] [blame] | 13245 | /** |
| 13246 | * csr_scan_request_assign_bssid() - Set the BSSID received from Supplicant |
| 13247 | * to the Scan request |
| 13248 | * @scanRequest: Pointer to the csr scan request |
| 13249 | * @request: Pointer to the scan request from supplicant |
| 13250 | * |
| 13251 | * Return: None |
| 13252 | */ |
| 13253 | #ifdef CFG80211_SCAN_BSSID |
| 13254 | static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest, |
| 13255 | struct cfg80211_scan_request *request) |
| 13256 | { |
| 13257 | vos_mem_copy(scanRequest->bssid, request->bssid, VOS_MAC_ADDR_SIZE); |
| 13258 | } |
| 13259 | #else |
| 13260 | static inline void csr_scan_request_assign_bssid(tCsrScanRequest *scanRequest, |
| 13261 | struct cfg80211_scan_request *request) |
| 13262 | { |
| 13263 | } |
| 13264 | #endif |
| 13265 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13266 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 13267 | * FUNCTION: __wlan_hdd_cfg80211_scan |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13268 | * this scan respond to scan trigger and update cfg80211 scan database |
| 13269 | * later, scan dump command can be used to recieve scan results |
| 13270 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 13271 | int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 13272 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13273 | struct net_device *dev, |
| 13274 | #endif |
| 13275 | struct cfg80211_scan_request *request) |
| 13276 | { |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 13277 | hdd_adapter_t *pAdapter = NULL; |
| 13278 | hdd_context_t *pHddCtx = NULL; |
| 13279 | hdd_wext_state_t *pwextBuf = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13280 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13281 | tCsrScanRequest scanRequest; |
| 13282 | tANI_U8 *channelList = NULL, i; |
| 13283 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13284 | int status; |
| 13285 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13286 | v_U8_t* pP2pIe = NULL; |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13287 | int ret = 0; |
Sushant Kaushik | 8659217 | 2015-04-27 16:35:03 +0530 | [diff] [blame] | 13288 | v_U8_t *pWpsIe=NULL; |
Deepthi Gowri | d5c5c2b | 2015-06-11 17:00:46 +0530 | [diff] [blame] | 13289 | bool is_p2p_scan = false; |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13290 | v_U8_t curr_session_id; |
| 13291 | scan_reject_states curr_reason; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13292 | |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 13293 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 13294 | struct net_device *dev = NULL; |
| 13295 | if (NULL == request) |
| 13296 | { |
| 13297 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13298 | "%s: scan req param null", __func__); |
| 13299 | return -EINVAL; |
| 13300 | } |
| 13301 | dev = request->wdev->netdev; |
| 13302 | #endif |
| 13303 | |
| 13304 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 13305 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 13306 | pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 13307 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13308 | ENTER(); |
| 13309 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13310 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 13311 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 13312 | pAdapter->device_mode); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 13313 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13314 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13315 | if (0 != status) |
| 13316 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13317 | return status; |
| 13318 | } |
| 13319 | |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 13320 | if (NULL == pwextBuf) |
| 13321 | { |
| 13322 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n", |
| 13323 | __func__); |
| 13324 | return -EIO; |
| 13325 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13326 | cfg_param = pHddCtx->cfg_ini; |
| 13327 | pScanInfo = &pHddCtx->scan_info; |
| 13328 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13329 | #ifdef WLAN_BTAMP_FEATURE |
| 13330 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 13331 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13332 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 13333 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13334 | "%s: No scanning when AMP is on", __func__); |
| 13335 | return -EOPNOTSUPP; |
| 13336 | } |
| 13337 | #endif |
| 13338 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 13339 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13340 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 13341 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13342 | "%s: Not scanning on device_mode = %s (%d)", |
| 13343 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 13344 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13345 | return -EOPNOTSUPP; |
| 13346 | } |
| 13347 | |
| 13348 | if (TRUE == pScanInfo->mScanPending) |
| 13349 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 13350 | if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ ) |
| 13351 | { |
| 13352 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__); |
| 13353 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 13354 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13355 | } |
| 13356 | |
Hanumantha Reddy Pothula | 4b6be06 | 2015-08-18 14:06:24 +0530 | [diff] [blame] | 13357 | // Don't allow scan if PNO scan is going on. |
| 13358 | if (pHddCtx->isPnoEnable) |
| 13359 | { |
| 13360 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13361 | FL("pno scan in progress")); |
| 13362 | return -EBUSY; |
| 13363 | } |
| 13364 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13365 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 13366 | //Channel and action frame is pending |
| 13367 | //Otherwise Cancel Remain On Channel and allow Scan |
| 13368 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 13369 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 13370 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 13371 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 13372 | return -EBUSY; |
| 13373 | } |
| 13374 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13375 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 13376 | { |
| 13377 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 13378 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13379 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13380 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13381 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 13382 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13383 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13384 | "%s: MAX TM Level Scan not allowed", __func__); |
| 13385 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13386 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13387 | } |
| 13388 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 13389 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13390 | /* Check if scan is allowed at this point of time. |
| 13391 | */ |
Hanumanth Reddy Pothula | ec96084 | 2016-09-14 19:04:26 +0530 | [diff] [blame] | 13392 | if (TRUE == pHddCtx->btCoexModeSet) |
| 13393 | { |
| 13394 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13395 | FL("BTCoex Mode operation in progress")); |
| 13396 | return -EBUSY; |
| 13397 | } |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13398 | if (hdd_isConnectionInProgress(pHddCtx, &curr_session_id, &curr_reason)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13399 | { |
Agrawal Ashish | c932a8d | 2016-08-17 19:21:02 +0530 | [diff] [blame] | 13400 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Scan not allowed")); |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13401 | if (pHddCtx->last_scan_reject_session_id != curr_session_id || |
| 13402 | pHddCtx->last_scan_reject_reason != curr_reason || |
| 13403 | !pHddCtx->last_scan_reject_timestamp) |
| 13404 | { |
| 13405 | pHddCtx->last_scan_reject_session_id = curr_session_id; |
| 13406 | pHddCtx->last_scan_reject_reason = curr_reason; |
Sreelakshmi Konamki | f0646d5 | 2016-12-09 12:35:31 +0530 | [diff] [blame] | 13407 | pHddCtx->last_scan_reject_timestamp = jiffies_to_msecs(jiffies); |
Abhishek Singh | e4b1256 | 2017-06-20 16:53:39 +0530 | [diff] [blame] | 13408 | pHddCtx->scan_reject_cnt = 0; |
Agrawal Ashish | c932a8d | 2016-08-17 19:21:02 +0530 | [diff] [blame] | 13409 | } |
Abhishek Singh | e4b1256 | 2017-06-20 16:53:39 +0530 | [diff] [blame] | 13410 | else |
| 13411 | { |
| 13412 | pHddCtx->scan_reject_cnt++; |
| 13413 | |
| 13414 | hddLog(LOGE, FL("Reject cnt %d time delta %lu ms"), pHddCtx->scan_reject_cnt, |
| 13415 | (jiffies_to_msecs(jiffies) - |
| 13416 | pHddCtx->last_scan_reject_timestamp)); |
| 13417 | |
| 13418 | if ((pHddCtx->scan_reject_cnt >= |
| 13419 | SCAN_REJECT_THRESHOLD) && |
| 13420 | (jiffies_to_msecs(jiffies) - |
| 13421 | pHddCtx->last_scan_reject_timestamp) >= |
| 13422 | SCAN_REJECT_THRESHOLD_TIME) |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13423 | { |
| 13424 | pHddCtx->last_scan_reject_timestamp = 0; |
Abhishek Singh | e4b1256 | 2017-06-20 16:53:39 +0530 | [diff] [blame] | 13425 | pHddCtx->scan_reject_cnt = 0; |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13426 | if (pHddCtx->cfg_ini->enableFatalEvent) |
| 13427 | vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL, |
| 13428 | WLAN_LOG_INDICATOR_HOST_DRIVER, |
| 13429 | WLAN_LOG_REASON_SCAN_NOT_ALLOWED, |
| 13430 | FALSE, FALSE); |
| 13431 | else |
| 13432 | { |
| 13433 | hddLog(LOGE, FL("Triggering SSR")); |
| 13434 | vos_wlanRestart(); |
| 13435 | } |
| 13436 | } |
| 13437 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 13438 | return -EBUSY; |
| 13439 | } |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13440 | pHddCtx->last_scan_reject_timestamp = 0; |
| 13441 | pHddCtx->last_scan_reject_session_id = 0xFF; |
| 13442 | pHddCtx->last_scan_reject_reason = 0; |
Abhishek Singh | e4b1256 | 2017-06-20 16:53:39 +0530 | [diff] [blame] | 13443 | pHddCtx->scan_reject_cnt = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13444 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13445 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 13446 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13447 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 13448 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 13449 | * is not aging out the scan results. |
| 13450 | */ |
| 13451 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13452 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13453 | request->n_ssids = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13454 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13455 | |
| 13456 | if ((request->ssids) && (0 < request->n_ssids)) |
| 13457 | { |
| 13458 | tCsrSSIDInfo *SsidInfo; |
| 13459 | int j; |
| 13460 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 13461 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 13462 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 13463 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 13464 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 13465 | |
| 13466 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 13467 | { |
| 13468 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13469 | "%s: memory alloc failed SSIDInfo buffer", __func__); |
| 13470 | return -ENOMEM; |
| 13471 | } |
| 13472 | |
| 13473 | /* copy all the ssid's and their length */ |
| 13474 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 13475 | { |
| 13476 | /* get the ssid length */ |
| 13477 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 13478 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 13479 | SsidInfo->SSID.length); |
| 13480 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 13481 | hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s", |
| 13482 | j, SsidInfo->SSID.ssId); |
| 13483 | } |
| 13484 | /* set the scan type to active */ |
| 13485 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 13486 | } |
| 13487 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13488 | { |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 13489 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 13490 | TRACE_CODE_HDD_CFG80211_SCAN, |
| 13491 | pAdapter->sessionId, 0)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13492 | /* set the scan type to active */ |
| 13493 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13494 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13495 | else |
| 13496 | { |
| 13497 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 13498 | scanRequest.scanType = pScanInfo->scan_mode; |
| 13499 | } |
| 13500 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
| 13501 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13502 | |
Selvaraj, Sridhar | d2b078a | 2016-06-18 10:44:37 +0530 | [diff] [blame] | 13503 | csr_scan_request_assign_bssid(&scanRequest, request); |
| 13504 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13505 | /* set BSSType to default type */ |
| 13506 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 13507 | |
| 13508 | /*TODO: scan the requested channels only*/ |
| 13509 | |
| 13510 | /*Right now scanning all the channels */ |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13511 | if (MAX_CHANNEL < request->n_channels) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13512 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13513 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 13514 | "No of Scan Channels exceeded limit: %d", request->n_channels); |
| 13515 | request->n_channels = MAX_CHANNEL; |
| 13516 | } |
| 13517 | |
| 13518 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 13519 | "No of Scan Channels: %d", request->n_channels); |
| 13520 | |
| 13521 | |
| 13522 | if( request->n_channels ) |
| 13523 | { |
| 13524 | char chList [(request->n_channels*5)+1]; |
| 13525 | int len; |
| 13526 | channelList = vos_mem_malloc( request->n_channels ); |
| 13527 | if( NULL == channelList ) |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 13528 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13529 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13530 | "%s: memory alloc failed channelList", __func__); |
| 13531 | status = -ENOMEM; |
| 13532 | goto free_mem; |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 13533 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13534 | |
| 13535 | for( i = 0, len = 0; i < request->n_channels ; i++ ) |
| 13536 | { |
| 13537 | channelList[i] = request->channels[i]->hw_value; |
| 13538 | len += snprintf(chList+len, 5, "%d ", channelList[i]); |
| 13539 | } |
| 13540 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13541 | hddLog(VOS_TRACE_LEVEL_INFO, |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13542 | "Channel-List: %s ", chList); |
| 13543 | } |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 13544 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13545 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 13546 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 13547 | |
| 13548 | /* set requestType to full scan */ |
| 13549 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 13550 | |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13551 | /* if there is back to back scan happening in driver with in |
| 13552 | * nDeferScanTimeInterval interval driver should defer new scan request |
| 13553 | * and should provide last cached scan results instead of new channel list. |
| 13554 | * This rule is not applicable if scan is p2p scan. |
| 13555 | * This condition will work only in case when last request no of channels |
| 13556 | * and channels are exactly same as new request. |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13557 | * This should be done only in connected state |
Sushant Kaushik | 8659217 | 2015-04-27 16:35:03 +0530 | [diff] [blame] | 13558 | * Scan shouldn't be defered for WPS scan case. |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13559 | */ |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13560 | |
Sushant Kaushik | 8659217 | 2015-04-27 16:35:03 +0530 | [diff] [blame] | 13561 | pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len); |
| 13562 | /* if wps ie is NULL , then only defer scan */ |
| 13563 | if ( pWpsIe == NULL && |
| 13564 | (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx))) |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13565 | { |
| 13566 | if ( pScanInfo->last_scan_timestamp !=0 && |
| 13567 | ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval)) |
| 13568 | { |
| 13569 | if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 && |
| 13570 | (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) && |
| 13571 | vos_mem_compare(pScanInfo->last_scan_channelList, |
| 13572 | channelList, pScanInfo->last_scan_numChannels)) |
| 13573 | { |
| 13574 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 13575 | " New and old station scan time differ is less then %u", |
| 13576 | pHddCtx->cfg_ini->nDeferScanTimeInterval); |
| 13577 | |
| 13578 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13579 | pAdapter); |
| 13580 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13581 | hddLog(VOS_TRACE_LEVEL_WARN, |
Masti, Narayanraddi | de03eb0 | 2015-02-06 11:23:50 +0530 | [diff] [blame] | 13582 | "Return old cached scan as all channels and no of channels are same"); |
| 13583 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13584 | if (0 > ret) |
| 13585 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13586 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13587 | cfg80211_scan_done(request, eCSR_SCAN_SUCCESS); |
Masti, Narayanraddi | de03eb0 | 2015-02-06 11:23:50 +0530 | [diff] [blame] | 13588 | |
| 13589 | status = eHAL_STATUS_SUCCESS; |
| 13590 | goto free_mem; |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13591 | } |
| 13592 | } |
Agarwal Ashish | bd3e10b | 2014-11-24 19:19:46 +0530 | [diff] [blame] | 13593 | } |
| 13594 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13595 | /* Flush the scan results(only p2p beacons) for STA scan and P2P |
| 13596 | * search (Flush on both full scan and social scan but not on single |
| 13597 | * channel scan).P2P search happens on 3 social channels (1, 6, 11) |
| 13598 | */ |
| 13599 | |
| 13600 | /* Supplicant does single channel scan after 8-way handshake |
| 13601 | * and in that case driver shoudnt flush scan results. If |
| 13602 | * driver flushes the scan results here and unfortunately if |
| 13603 | * the AP doesnt respond to our probe req then association |
| 13604 | * fails which is not desired |
| 13605 | */ |
Deepthi Gowri | d5c5c2b | 2015-06-11 17:00:46 +0530 | [diff] [blame] | 13606 | if ((request->n_ssids == 1) |
| 13607 | && (request->ssids != NULL) |
| 13608 | && vos_mem_compare(&request->ssids[0], "DIRECT-", 7)) |
| 13609 | is_p2p_scan = true; |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13610 | |
Deepthi Gowri | d5c5c2b | 2015-06-11 17:00:46 +0530 | [diff] [blame] | 13611 | if( is_p2p_scan || |
| 13612 | (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) ) |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13613 | { |
| 13614 | hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results"); |
| 13615 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13616 | pAdapter->sessionId ); |
| 13617 | } |
| 13618 | |
| 13619 | if( request->ie_len ) |
| 13620 | { |
| 13621 | /* save this for future association (join requires this) */ |
| 13622 | /*TODO: Array needs to be converted to dynamic allocation, |
| 13623 | * as multiple ie.s can be sent in cfg80211_scan_request structure |
| 13624 | * CR 597966 |
| 13625 | */ |
| 13626 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 13627 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 13628 | pScanInfo->scanAddIE.length = request->ie_len; |
| 13629 | |
| 13630 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 13631 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 13632 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13633 | { |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 13634 | if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13635 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13636 | pwextBuf->roamProfile.nAddIEScanLength = request->ie_len; |
| 13637 | memcpy( pwextBuf->roamProfile.addIEScan, |
| 13638 | request->ie, request->ie_len); |
| 13639 | } |
| 13640 | else |
| 13641 | { |
| 13642 | hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:" |
| 13643 | "%zu", request->ie_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13644 | } |
| 13645 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13646 | } |
| 13647 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 13648 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 13649 | |
| 13650 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 13651 | request->ie_len); |
| 13652 | if (pP2pIe != NULL) |
| 13653 | { |
| 13654 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 13655 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 13656 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 13657 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13658 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13659 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 13660 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 13661 | "Go nego completed to Connection is started"); |
| 13662 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 13663 | "for 8way Handshake"); |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13664 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13665 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 13666 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13667 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13668 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 13669 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 13670 | "Disconnected state to Connection is started"); |
| 13671 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 13672 | "for 4way Handshake"); |
| 13673 | } |
| 13674 | #endif |
| 13675 | |
| 13676 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 13677 | if(TRUE == request->no_cck) |
| 13678 | { |
| 13679 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 13680 | "%s: This is a P2P Search", __func__); |
| 13681 | scanRequest.p2pSearch = 1; |
| 13682 | |
| 13683 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 13684 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13685 | /* set requestType to P2P Discovery */ |
| 13686 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
| 13687 | } |
| 13688 | |
| 13689 | /* |
| 13690 | Skip Dfs Channel in case of P2P Search |
| 13691 | if it is set in ini file |
| 13692 | */ |
| 13693 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 13694 | { |
| 13695 | scanRequest.skipDfsChnlInP2pSearch = 1; |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 13696 | } |
| 13697 | else |
| 13698 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 13699 | scanRequest.skipDfsChnlInP2pSearch = 0; |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 13700 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13701 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 13702 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13703 | } |
| 13704 | } |
| 13705 | |
| 13706 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 13707 | |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 13708 | #ifdef FEATURE_WLAN_TDLS |
| 13709 | /* if tdls disagree scan right now, return immediately. |
| 13710 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 13711 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 13712 | */ |
| 13713 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 13714 | wiphy, |
| 13715 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13716 | dev, |
| 13717 | #endif |
| 13718 | request); |
Abhishek Singh | e2b6395 | 2016-01-05 18:27:29 +0530 | [diff] [blame] | 13719 | if (status <= 0) |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 13720 | { |
Abhishek Singh | e2b6395 | 2016-01-05 18:27:29 +0530 | [diff] [blame] | 13721 | if (!status) |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 13722 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress." |
| 13723 | "scan rejected %d", __func__, status); |
| 13724 | else |
| 13725 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d", |
| 13726 | __func__, status); |
Abhishek Singh | e2b6395 | 2016-01-05 18:27:29 +0530 | [diff] [blame] | 13727 | hdd_wlan_block_scan_by_tdls(); |
Gupta, Kapil | 2ebf3e0 | 2016-03-17 19:45:19 +0530 | [diff] [blame] | 13728 | goto free_mem; |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 13729 | } |
| 13730 | #endif |
| 13731 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 13732 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 13733 | * address the following issues. |
| 13734 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 13735 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 13736 | * for long time, this result in apps running at full power for long time. |
| 13737 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 13738 | * be stuck in full power because of resume BMPS |
| 13739 | */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13740 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13741 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13742 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 13743 | "requestType %d, scanType %d, minChnTime %d, maxChnTime %d," |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13744 | "p2pSearch %d, skipDfsChnlInP2pSearch %d", |
| 13745 | scanRequest.requestType, scanRequest.scanType, |
| 13746 | scanRequest.minChnTime, scanRequest.maxChnTime, |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13747 | scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch); |
| 13748 | |
Hanumantha Reddy Pothula | ca1d1cc | 2015-10-26 15:37:35 +0530 | [diff] [blame] | 13749 | if (pHddCtx->spoofMacAddr.isEnabled && |
| 13750 | pHddCtx->cfg_ini->enableMacSpoofing == 1) |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 13751 | { |
| 13752 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 13753 | "%s: MAC Spoofing enabled for current scan", __func__); |
| 13754 | /* Updating SelfSta Mac Addr in TL which will be used to get staidx |
| 13755 | * to fill TxBds for probe request during current scan |
| 13756 | */ |
Padma, Santhosh Kumar | 7923614 | 2015-02-09 18:19:33 +0530 | [diff] [blame] | 13757 | status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext, |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 13758 | &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent); |
Padma, Santhosh Kumar | 7923614 | 2015-02-09 18:19:33 +0530 | [diff] [blame] | 13759 | |
| 13760 | if(status != VOS_STATUS_SUCCESS) |
| 13761 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13762 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN); |
Padma, Santhosh Kumar | 7923614 | 2015-02-09 18:19:33 +0530 | [diff] [blame] | 13763 | status = -EFAULT; |
Ganesh Kondabattini | 6d3b490 | 2015-05-12 23:19:22 +0530 | [diff] [blame] | 13764 | #ifdef FEATURE_WLAN_TDLS |
| 13765 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 13766 | #endif |
Padma, Santhosh Kumar | 7923614 | 2015-02-09 18:19:33 +0530 | [diff] [blame] | 13767 | goto free_mem; |
| 13768 | } |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 13769 | } |
Mahesh A Saptasagar | 51dc36c | 2015-06-16 12:07:15 +0530 | [diff] [blame] | 13770 | wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13771 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13772 | pAdapter->sessionId, &scanRequest, &scanId, |
| 13773 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13774 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13775 | if (eHAL_STATUS_SUCCESS != status) |
| 13776 | { |
| 13777 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13778 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 13779 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 13780 | if(eHAL_STATUS_RESOURCES == status) |
| 13781 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 13782 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress." |
| 13783 | "So defer the scan by informing busy",__func__); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 13784 | status = -EBUSY; |
| 13785 | } else { |
| 13786 | status = -EIO; |
| 13787 | } |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13788 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN); |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 13789 | |
| 13790 | #ifdef FEATURE_WLAN_TDLS |
| 13791 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 13792 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13793 | goto free_mem; |
| 13794 | } |
| 13795 | |
| 13796 | pScanInfo->mScanPending = TRUE; |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 13797 | pScanInfo->sessionId = pAdapter->sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13798 | pAdapter->request = request; |
| 13799 | pScanInfo->scanId = scanId; |
| 13800 | |
| 13801 | complete(&pScanInfo->scan_req_completion_event); |
| 13802 | |
| 13803 | free_mem: |
| 13804 | if( scanRequest.SSIDs.SSIDList ) |
| 13805 | { |
| 13806 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 13807 | } |
| 13808 | |
| 13809 | if( channelList ) |
| 13810 | vos_mem_free( channelList ); |
| 13811 | |
| 13812 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13813 | return status; |
| 13814 | } |
| 13815 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 13816 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 13817 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13818 | struct net_device *dev, |
| 13819 | #endif |
| 13820 | struct cfg80211_scan_request *request) |
| 13821 | { |
| 13822 | int ret; |
| 13823 | |
| 13824 | vos_ssr_protect(__func__); |
| 13825 | ret = __wlan_hdd_cfg80211_scan(wiphy, |
| 13826 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13827 | dev, |
| 13828 | #endif |
| 13829 | request); |
| 13830 | vos_ssr_unprotect(__func__); |
| 13831 | |
| 13832 | return ret; |
| 13833 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 13834 | |
| 13835 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 13836 | { |
| 13837 | v_U8_t iniDot11Mode = |
| 13838 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 13839 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 13840 | |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 13841 | hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"), |
| 13842 | iniDot11Mode); |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 13843 | switch ( iniDot11Mode ) |
| 13844 | { |
| 13845 | case eHDD_DOT11_MODE_AUTO: |
| 13846 | case eHDD_DOT11_MODE_11ac: |
| 13847 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 13848 | #ifdef WLAN_FEATURE_11AC |
Abhishek Singh | 4b1d235 | 2014-08-01 21:59:28 +0530 | [diff] [blame] | 13849 | if ( sme_IsFeatureSupportedByDriver(DOT11AC) && |
| 13850 | sme_IsFeatureSupportedByFW(DOT11AC) ) |
| 13851 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 13852 | else |
| 13853 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 13854 | #else |
| 13855 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 13856 | #endif |
| 13857 | break; |
| 13858 | case eHDD_DOT11_MODE_11n: |
| 13859 | case eHDD_DOT11_MODE_11n_ONLY: |
| 13860 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 13861 | break; |
| 13862 | default: |
| 13863 | hddDot11Mode = iniDot11Mode; |
| 13864 | break; |
| 13865 | } |
Hardik Kantilal Patel | 086e0a3 | 2014-11-20 14:56:26 +0530 | [diff] [blame] | 13866 | #ifdef WLAN_FEATURE_AP_HT40_24G |
| 13867 | if (operationChannel > SIR_11B_CHANNEL_END) |
| 13868 | #endif |
| 13869 | { |
| 13870 | /* This call decides required channel bonding mode */ |
| 13871 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 13872 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 13873 | operationChannel); |
Hardik Kantilal Patel | 086e0a3 | 2014-11-20 14:56:26 +0530 | [diff] [blame] | 13874 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 13875 | } |
| 13876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13877 | /* |
| 13878 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13879 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13880 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13881 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Hanumantha Reddy Pothula | 64081b7 | 2015-09-11 15:47:32 +0530 | [diff] [blame] | 13882 | const u8 *ssid, size_t ssid_len, const u8 *bssid, |
| 13883 | const u8 *bssid_hint, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13884 | { |
| 13885 | int status = 0; |
| 13886 | hdd_wext_state_t *pWextState; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 13887 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13888 | v_U32_t roamId; |
| 13889 | tCsrRoamProfile *pRoamProfile; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13890 | eCsrAuthType RSNAuthType; |
| 13891 | |
| 13892 | ENTER(); |
| 13893 | |
| 13894 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 13895 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13896 | |
| 13897 | status = wlan_hdd_validate_context(pHddCtx); |
| 13898 | if (status) |
| 13899 | { |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 13900 | return status; |
| 13901 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13902 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13903 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 13904 | { |
| 13905 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 13906 | return -EINVAL; |
| 13907 | } |
| 13908 | |
Nitesh Shah | 9b06628 | 2017-06-06 18:05:52 +0530 | [diff] [blame] | 13909 | wlan_hdd_tdls_disable_offchan_and_teardown_links(pHddCtx); |
| 13910 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13911 | pRoamProfile = &pWextState->roamProfile; |
| 13912 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13913 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13914 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13915 | hdd_station_ctx_t *pHddStaCtx; |
| 13916 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Abhishek Singh | 6782c9e | 2017-06-06 13:37:45 +0530 | [diff] [blame] | 13917 | pHddStaCtx->get_mgmt_log_sent = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13918 | |
Siddharth Bhal | da0d162 | 2015-04-24 15:47:49 +0530 | [diff] [blame] | 13919 | wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR); |
| 13920 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13921 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13922 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 13923 | { |
| 13924 | /*QoS not enabled in cfg file*/ |
| 13925 | pRoamProfile->uapsd_mask = 0; |
| 13926 | } |
| 13927 | else |
| 13928 | { |
| 13929 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13930 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13931 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 13932 | } |
| 13933 | |
| 13934 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 13935 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 13936 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13937 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13938 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 13939 | ssid, ssid_len); |
| 13940 | |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13941 | vos_mem_zero(pRoamProfile->BSSIDs.bssid, WNI_CFG_BSSID_LEN); |
| 13942 | vos_mem_zero(pRoamProfile->bssid_hint, WNI_CFG_BSSID_LEN); |
| 13943 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13944 | if (bssid) |
| 13945 | { |
| 13946 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13947 | vos_mem_copy(pRoamProfile->BSSIDs.bssid, bssid, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13948 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13949 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 13950 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13951 | case of join failure we should send valid BSSID to supplicant |
| 13952 | */ |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13953 | vos_mem_copy(pWextState->req_bssId, bssid, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13954 | WNI_CFG_BSSID_LEN); |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13955 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13956 | } |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13957 | else if (bssid_hint) |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 13958 | { |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13959 | /* Store bssid_hint to use in the scan filter. */ |
| 13960 | vos_mem_copy(pRoamProfile->bssid_hint, bssid_hint, |
| 13961 | WNI_CFG_BSSID_LEN); |
| 13962 | /* |
| 13963 | * Save BSSID in seperate variable as well, as RoamProfile |
| 13964 | * BSSID is getting zeroed out in the association process. And in |
| 13965 | * case of join failure we should send valid BSSID to supplicant |
| 13966 | */ |
| 13967 | vos_mem_copy(pWextState->req_bssId, bssid_hint, |
| 13968 | WNI_CFG_BSSID_LEN); |
| 13969 | hddLog(LOG1, FL(" bssid_hint: "MAC_ADDRESS_STR), |
| 13970 | MAC_ADDR_ARRAY(pRoamProfile->bssid_hint)); |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 13971 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13972 | |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 13973 | |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 13974 | hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"), |
| 13975 | pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13976 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 13977 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13978 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13979 | /*set gen ie*/ |
| 13980 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 13981 | /*set auth*/ |
| 13982 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 13983 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13984 | #ifdef FEATURE_WLAN_WAPI |
| 13985 | if (pAdapter->wapi_info.nWapiMode) |
| 13986 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 13987 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13988 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 13989 | { |
| 13990 | case WAPI_AUTH_MODE_PSK: |
| 13991 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 13992 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13993 | pAdapter->wapi_info.wapiAuthMode); |
| 13994 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 13995 | break; |
| 13996 | } |
| 13997 | case WAPI_AUTH_MODE_CERT: |
| 13998 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 13999 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14000 | pAdapter->wapi_info.wapiAuthMode); |
| 14001 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 14002 | break; |
| 14003 | } |
| 14004 | } // End of switch |
| 14005 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 14006 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 14007 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 14008 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14009 | pRoamProfile->AuthType.numEntries = 1; |
| 14010 | pRoamProfile->EncryptionType.numEntries = 1; |
| 14011 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 14012 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 14013 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 14014 | } |
| 14015 | } |
| 14016 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 14017 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 14018 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 14019 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 14020 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 14021 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 14022 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 14023 | sizeof (tSirGtkOffloadParams)); |
| 14024 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 14025 | } |
| 14026 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14027 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 14028 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14029 | if( operatingChannel ) |
| 14030 | { |
| 14031 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 14032 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 14033 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 14034 | else |
| 14035 | { |
| 14036 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 14037 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 14038 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 14039 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 14040 | { |
| 14041 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 14042 | } |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 14043 | |
Agarwal Ashish | 40f9b87 | 2015-09-01 16:17:35 +0530 | [diff] [blame] | 14044 | /* |
| 14045 | * Change conn_state to connecting before sme_RoamConnect(), |
| 14046 | * because sme_RoamConnect() has a direct path to call |
| 14047 | * hdd_smeRoamCallback(), which will change the conn_state |
| 14048 | * If direct path, conn_state will be accordingly changed |
| 14049 | * to NotConnected or Associated by either |
| 14050 | * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() |
| 14051 | * in sme_RoamCallback() |
| 14052 | * if sme_RomConnect is to be queued, |
| 14053 | * Connecting state will remain until it is completed. |
| 14054 | * If connection state is not changed, |
| 14055 | * connection state will remain in eConnectionState_NotConnected state. |
| 14056 | * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true |
| 14057 | * if conn state is eConnectionState_NotConnected. |
| 14058 | * If "hddDisconInProgress" is set to true then cfg80211 layer is not |
| 14059 | * informed of connect result indication which is an issue. |
| 14060 | */ |
| 14061 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 14062 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 14063 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 14064 | { |
| 14065 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 40f9b87 | 2015-09-01 16:17:35 +0530 | [diff] [blame] | 14066 | FL("Set HDD connState to eConnectionState_Connecting")); |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 14067 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 14068 | eConnectionState_Connecting); |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 14069 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14070 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14071 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 14072 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 14073 | if ((eHAL_STATUS_SUCCESS != status) && |
| 14074 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 14075 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 14076 | |
| 14077 | { |
Agarwal Ashish | 40f9b87 | 2015-09-01 16:17:35 +0530 | [diff] [blame] | 14078 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 14079 | FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"), |
| 14080 | pAdapter->sessionId, status); |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 14081 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 14082 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 14083 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 14084 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 14085 | |
| 14086 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 14087 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 14088 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14089 | } |
| 14090 | else |
| 14091 | { |
| 14092 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 14093 | return -EINVAL; |
| 14094 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 14095 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14096 | return status; |
| 14097 | } |
| 14098 | |
| 14099 | /* |
| 14100 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 14101 | * This function is used to set the authentication type (OPEN/SHARED). |
| 14102 | * |
| 14103 | */ |
| 14104 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 14105 | enum nl80211_auth_type auth_type) |
| 14106 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14107 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14108 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14109 | |
| 14110 | ENTER(); |
| 14111 | |
| 14112 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14113 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14114 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14115 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 14116 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14117 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 14118 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 14119 | break; |
| 14120 | |
| 14121 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 14122 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 14123 | case NL80211_AUTHTYPE_FT: |
| 14124 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14125 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14126 | "%s: set authentication type to OPEN", __func__); |
| 14127 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 14128 | break; |
| 14129 | |
| 14130 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14131 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14132 | "%s: set authentication type to SHARED", __func__); |
| 14133 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 14134 | break; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 14135 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14136 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14137 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14138 | "%s: set authentication type to CCKM WPA", __func__); |
| 14139 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 14140 | break; |
| 14141 | #endif |
| 14142 | |
| 14143 | |
| 14144 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14145 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 14146 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14147 | auth_type); |
| 14148 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 14149 | return -EINVAL; |
| 14150 | } |
| 14151 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14152 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14153 | pHddStaCtx->conn_info.authType; |
| 14154 | return 0; |
| 14155 | } |
| 14156 | |
| 14157 | /* |
| 14158 | * FUNCTION: wlan_hdd_set_akm_suite |
| 14159 | * This function is used to set the key mgmt type(PSK/8021x). |
| 14160 | * |
| 14161 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14162 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14163 | u32 key_mgmt |
| 14164 | ) |
| 14165 | { |
| 14166 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 14167 | ENTER(); |
Abhishek Singh | ae40803 | 2014-09-25 17:22:04 +0530 | [diff] [blame] | 14168 | /* Should be in ieee802_11_defs.h */ |
Vidyullatha Kanchanapally | 0819768 | 2017-04-18 16:30:11 +0530 | [diff] [blame] | 14169 | #ifndef WLAN_AKM_SUITE_8021X_SHA256 |
Abhishek Singh | ae40803 | 2014-09-25 17:22:04 +0530 | [diff] [blame] | 14170 | #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05 |
Vidyullatha Kanchanapally | 0819768 | 2017-04-18 16:30:11 +0530 | [diff] [blame] | 14171 | #endif |
| 14172 | #ifndef WLAN_AKM_SUITE_PSK_SHA256 |
Abhishek Singh | ae40803 | 2014-09-25 17:22:04 +0530 | [diff] [blame] | 14173 | #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06 |
Vidyullatha Kanchanapally | 0819768 | 2017-04-18 16:30:11 +0530 | [diff] [blame] | 14174 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14175 | /*set key mgmt type*/ |
| 14176 | switch(key_mgmt) |
| 14177 | { |
| 14178 | case WLAN_AKM_SUITE_PSK: |
Abhishek Singh | ae40803 | 2014-09-25 17:22:04 +0530 | [diff] [blame] | 14179 | case WLAN_AKM_SUITE_PSK_SHA256: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 14180 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 14181 | case WLAN_AKM_SUITE_FT_PSK: |
| 14182 | #endif |
| 14183 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14184 | __func__); |
| 14185 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 14186 | break; |
| 14187 | |
| 14188 | case WLAN_AKM_SUITE_8021X: |
Abhishek Singh | ae40803 | 2014-09-25 17:22:04 +0530 | [diff] [blame] | 14189 | case WLAN_AKM_SUITE_8021X_SHA256: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 14190 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 14191 | case WLAN_AKM_SUITE_FT_8021X: |
| 14192 | #endif |
| 14193 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14194 | __func__); |
| 14195 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 14196 | break; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 14197 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14198 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 14199 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 14200 | case WLAN_AKM_SUITE_CCKM: |
| 14201 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 14202 | __func__); |
| 14203 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 14204 | break; |
| 14205 | #endif |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 14206 | #ifndef WLAN_AKM_SUITE_OSEN |
| 14207 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 14208 | case WLAN_AKM_SUITE_OSEN: |
| 14209 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN", |
| 14210 | __func__); |
| 14211 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 14212 | break; |
| 14213 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14214 | |
| 14215 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14216 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14217 | __func__, key_mgmt); |
| 14218 | return -EINVAL; |
| 14219 | |
| 14220 | } |
| 14221 | return 0; |
| 14222 | } |
| 14223 | |
| 14224 | /* |
| 14225 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14226 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14227 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 14228 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14229 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 14230 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14231 | bool ucast |
| 14232 | ) |
| 14233 | { |
| 14234 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14235 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14236 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14237 | |
| 14238 | ENTER(); |
| 14239 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14240 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14241 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 14242 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14243 | __func__, cipher); |
| 14244 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 14245 | } |
| 14246 | else |
| 14247 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14248 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14249 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14250 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14251 | { |
| 14252 | case IW_AUTH_CIPHER_NONE: |
| 14253 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 14254 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14255 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14256 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 14257 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14258 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14259 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14260 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 14261 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14262 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14263 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14264 | case WLAN_CIPHER_SUITE_TKIP: |
| 14265 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 14266 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14268 | case WLAN_CIPHER_SUITE_CCMP: |
| 14269 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 14270 | break; |
| 14271 | #ifdef FEATURE_WLAN_WAPI |
| 14272 | case WLAN_CIPHER_SUITE_SMS4: |
| 14273 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 14274 | break; |
| 14275 | #endif |
| 14276 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 14277 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14278 | case WLAN_CIPHER_SUITE_KRK: |
| 14279 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 14280 | break; |
| 14281 | #endif |
| 14282 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14283 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14284 | __func__, cipher); |
| 14285 | return -EOPNOTSUPP; |
| 14286 | } |
| 14287 | } |
| 14288 | |
| 14289 | if (ucast) |
| 14290 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14291 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14292 | __func__, encryptionType); |
| 14293 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 14294 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14295 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14296 | encryptionType; |
| 14297 | } |
| 14298 | else |
| 14299 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14300 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14301 | __func__, encryptionType); |
| 14302 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 14303 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 14304 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 14305 | } |
| 14306 | |
| 14307 | return 0; |
| 14308 | } |
| 14309 | |
| 14310 | |
| 14311 | /* |
| 14312 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 14313 | * This function is used to parse WPA/RSN IE's. |
| 14314 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14315 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14316 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 14317 | const u8 *ie, |
| 14318 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14319 | u8 *ie, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14320 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14321 | size_t ie_len |
| 14322 | ) |
| 14323 | { |
| 14324 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14325 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 14326 | const u8 *genie = ie; |
| 14327 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14328 | u8 *genie = ie; |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14329 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14330 | v_U16_t remLen = ie_len; |
| 14331 | #ifdef FEATURE_WLAN_WAPI |
| 14332 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 14333 | u16 *tmp; |
| 14334 | v_U16_t akmsuiteCount; |
| 14335 | int *akmlist; |
| 14336 | #endif |
| 14337 | ENTER(); |
| 14338 | |
| 14339 | /* clear previous assocAddIE */ |
| 14340 | pWextState->assocAddIE.length = 0; |
| 14341 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 14342 | pWextState->roamProfile.bOSENAssociation = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14343 | |
| 14344 | while (remLen >= 2) |
| 14345 | { |
| 14346 | v_U16_t eLen = 0; |
| 14347 | v_U8_t elementId; |
| 14348 | elementId = *genie++; |
| 14349 | eLen = *genie++; |
| 14350 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14351 | |
Nachiket Kukade | 4aba5f0 | 2017-06-09 15:43:48 +0530 | [diff] [blame] | 14352 | /* Sanity check on eLen */ |
| 14353 | if (eLen > remLen) { |
| 14354 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid IE length[%d] for IE[0x%X]", |
| 14355 | __func__, eLen, elementId); |
| 14356 | VOS_ASSERT(0); |
| 14357 | return -EINVAL; |
| 14358 | } |
| 14359 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 14360 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14361 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14362 | |
| 14363 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14364 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14365 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14366 | if (4 > eLen) /* should have at least OUI which is 4 bytes so extra 2 bytes not needed */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14367 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14368 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14369 | "%s: Invalid WPA IE", __func__); |
| 14370 | return -EINVAL; |
| 14371 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14372 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14373 | { |
| 14374 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14375 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14376 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14377 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 14378 | if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14379 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 14380 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 14381 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14382 | VOS_ASSERT(0); |
| 14383 | return -ENOMEM; |
| 14384 | } |
| 14385 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 14386 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 14387 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14388 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14389 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 14390 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 14391 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 14392 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14393 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 14394 | { |
Nachiket Kukade | 3d72b7e | 2017-06-09 16:58:24 +0530 | [diff] [blame] | 14395 | if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) { |
| 14396 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid WPA RSN IE length[%d]", |
| 14397 | __func__, eLen); |
| 14398 | VOS_ASSERT(0); |
| 14399 | return -EINVAL; |
| 14400 | } |
| 14401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14402 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 14403 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 14404 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 14405 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 14406 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 14407 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14408 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
Kiet Lam | 8da9899 | 2013-11-21 15:59:07 +0530 | [diff] [blame] | 14409 | P2P_OUI_TYPE_SIZE))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14410 | { |
| 14411 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14412 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14413 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14414 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 14415 | if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14416 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 14417 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 14418 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14419 | VOS_ASSERT(0); |
| 14420 | return -ENOMEM; |
| 14421 | } |
| 14422 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 14423 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 14424 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14425 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14426 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 14427 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 14428 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14429 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14430 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 14431 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14432 | /*Consider WFD IE, only for P2P Client */ |
| 14433 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 14434 | { |
| 14435 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14436 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14437 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14438 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 14439 | if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14440 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 14441 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 14442 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14443 | VOS_ASSERT(0); |
| 14444 | return -ENOMEM; |
| 14445 | } |
| 14446 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 14447 | // WPS IE + P2P IE + WFD IE |
| 14448 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 14449 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14450 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14451 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 14452 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 14453 | } |
| 14454 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14455 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14456 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 14457 | HS20_OUI_TYPE_SIZE)) ) |
| 14458 | { |
| 14459 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14460 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 14461 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14462 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 14463 | if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 14464 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 14465 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 14466 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 14467 | VOS_ASSERT(0); |
| 14468 | return -ENOMEM; |
| 14469 | } |
| 14470 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 14471 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14472 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 14473 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 14474 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 14475 | } |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 14476 | /* Appending OSEN Information Element in Assiciation Request */ |
| 14477 | else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 14478 | OSEN_OUI_TYPE_SIZE)) ) |
| 14479 | { |
| 14480 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
| 14481 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)", |
| 14482 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14483 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 14484 | if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 14485 | { |
| 14486 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 14487 | "Need bigger buffer space"); |
| 14488 | VOS_ASSERT(0); |
| 14489 | return -ENOMEM; |
| 14490 | } |
| 14491 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 14492 | pWextState->assocAddIE.length += eLen + 2; |
| 14493 | |
| 14494 | pWextState->roamProfile.bOSENAssociation = VOS_TRUE; |
| 14495 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 14496 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 14497 | } |
| 14498 | |
Abhishek Singh | 4322e62 | 2015-06-10 15:42:54 +0530 | [diff] [blame] | 14499 | /* Update only for WPA IE */ |
| 14500 | if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) && |
| 14501 | (WLAN_HDD_IBSS == pAdapter->device_mode)) { |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 14502 | |
| 14503 | /* populating as ADDIE in beacon frames */ |
| 14504 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14505 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2, |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 14506 | NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS) |
| 14507 | { |
| 14508 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14509 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 14510 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 14511 | { |
| 14512 | hddLog(LOGE, |
| 14513 | "Coldn't pass " |
| 14514 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
| 14515 | } |
| 14516 | }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/ |
| 14517 | else |
| 14518 | hddLog(LOGE, |
| 14519 | "Could not pass on " |
| 14520 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
| 14521 | |
| 14522 | /* IBSS mode doesn't contain params->proberesp_ies still |
| 14523 | beaconIE's need to be populated in probe response frames */ |
| 14524 | if ( (NULL != (genie - 2)) && (0 != eLen + 2) ) |
| 14525 | { |
| 14526 | u16 rem_probe_resp_ie_len = eLen + 2; |
| 14527 | u8 probe_rsp_ie_len[3] = {0}; |
| 14528 | u8 counter = 0; |
| 14529 | |
| 14530 | /* Check Probe Resp Length if it is greater then 255 then |
| 14531 | Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 |
| 14532 | & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are |
| 14533 | not able Store More then 255 bytes into One Variable */ |
| 14534 | |
| 14535 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 14536 | { |
| 14537 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 14538 | { |
| 14539 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 14540 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 14541 | } |
| 14542 | else |
| 14543 | { |
| 14544 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 14545 | rem_probe_resp_ie_len = 0; |
| 14546 | } |
| 14547 | } |
| 14548 | |
| 14549 | rem_probe_resp_ie_len = 0; |
| 14550 | |
| 14551 | if (probe_rsp_ie_len[0] > 0) |
| 14552 | { |
| 14553 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14554 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 14555 | (tANI_U8*)(genie - 2), |
| 14556 | probe_rsp_ie_len[0], NULL, |
| 14557 | eANI_BOOLEAN_FALSE) |
| 14558 | == eHAL_STATUS_FAILURE) |
| 14559 | { |
| 14560 | hddLog(LOGE, |
| 14561 | "Could not pass" |
| 14562 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
| 14563 | } |
| 14564 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 14565 | } |
| 14566 | |
| 14567 | if (probe_rsp_ie_len[1] > 0) |
| 14568 | { |
| 14569 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14570 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 14571 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 14572 | probe_rsp_ie_len[1], NULL, |
| 14573 | eANI_BOOLEAN_FALSE) |
| 14574 | == eHAL_STATUS_FAILURE) |
| 14575 | { |
| 14576 | hddLog(LOGE, |
| 14577 | "Could not pass" |
| 14578 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
| 14579 | } |
| 14580 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 14581 | } |
| 14582 | |
| 14583 | if (probe_rsp_ie_len[2] > 0) |
| 14584 | { |
| 14585 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14586 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 14587 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 14588 | probe_rsp_ie_len[2], NULL, |
| 14589 | eANI_BOOLEAN_FALSE) |
| 14590 | == eHAL_STATUS_FAILURE) |
| 14591 | { |
| 14592 | hddLog(LOGE, |
| 14593 | "Could not pass" |
| 14594 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
| 14595 | } |
| 14596 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 14597 | } |
| 14598 | |
| 14599 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14600 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 14601 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 14602 | { |
| 14603 | hddLog(LOGE, |
| 14604 | "Could not pass" |
| 14605 | "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
| 14606 | } |
| 14607 | } |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 14608 | } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14609 | break; |
| 14610 | case DOT11F_EID_RSN: |
| 14611 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 14612 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 14613 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 14614 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 14615 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 14616 | break; |
Abhishek Singh | 15d9560 | 2015-03-24 15:52:57 +0530 | [diff] [blame] | 14617 | |
Abhishek Singh | b16f356 | 2016-01-20 11:08:32 +0530 | [diff] [blame] | 14618 | /* Appending extended capabilities with Interworking or |
| 14619 | * bsstransition bit set in Assoc Req. |
Abhishek Singh | 15d9560 | 2015-03-24 15:52:57 +0530 | [diff] [blame] | 14620 | * |
| 14621 | * In assoc req this EXT Cap will only be taken into account if |
Abhishek Singh | b16f356 | 2016-01-20 11:08:32 +0530 | [diff] [blame] | 14622 | * interworkingService or bsstransition bit is set to 1. |
| 14623 | * Driver is only interested in interworkingService and |
| 14624 | * bsstransition capability from supplicant. |
| 14625 | * If in future any other EXT Cap info is |
Abhishek Singh | 15d9560 | 2015-03-24 15:52:57 +0530 | [diff] [blame] | 14626 | * required from supplicat, it needs to be handled while |
| 14627 | * sending Assoc Req in LIM. |
| 14628 | */ |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14629 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14630 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14631 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14632 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)", |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14633 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14634 | |
Ganesh Kondabattini | 7500fb3 | 2015-04-10 14:50:32 +0530 | [diff] [blame] | 14635 | if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14636 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 14637 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 14638 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14639 | VOS_ASSERT(0); |
| 14640 | return -ENOMEM; |
| 14641 | } |
| 14642 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 14643 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14644 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14645 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 14646 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 14647 | break; |
| 14648 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14649 | #ifdef FEATURE_WLAN_WAPI |
| 14650 | case WLAN_EID_WAPI: |
| 14651 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 14652 | hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14653 | pAdapter->wapi_info.nWapiMode); |
| 14654 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14655 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14656 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 14657 | tmp = tmp + 1; |
| 14658 | akmlist = (int *)(tmp); |
| 14659 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 14660 | { |
| 14661 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 14662 | } |
| 14663 | else |
| 14664 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 14665 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14666 | VOS_ASSERT(0); |
| 14667 | return -EINVAL; |
| 14668 | } |
| 14669 | |
| 14670 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 14671 | { |
| 14672 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 14673 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14674 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14675 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14676 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14677 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14678 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 14679 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14680 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 14681 | } |
| 14682 | break; |
| 14683 | #endif |
| 14684 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14685 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14686 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 14687 | /* when Unknown IE is received we should break and continue |
| 14688 | * to the next IE in the buffer instead we were returning |
| 14689 | * so changing this to break */ |
| 14690 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14691 | } |
| 14692 | genie += eLen; |
| 14693 | remLen -= eLen; |
| 14694 | } |
| 14695 | EXIT(); |
| 14696 | return 0; |
| 14697 | } |
| 14698 | |
| 14699 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 14700 | * FUNCTION: hdd_isWPAIEPresent |
| 14701 | * Parse the received IE to find the WPA IE |
| 14702 | * |
| 14703 | */ |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14704 | static bool hdd_isWPAIEPresent( |
| 14705 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) |
| 14706 | const u8 *ie, |
| 14707 | #else |
| 14708 | u8 *ie, |
| 14709 | #endif |
| 14710 | u8 ie_len) |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 14711 | { |
| 14712 | v_U8_t eLen = 0; |
| 14713 | v_U16_t remLen = ie_len; |
| 14714 | v_U8_t elementId = 0; |
| 14715 | |
| 14716 | while (remLen >= 2) |
| 14717 | { |
| 14718 | elementId = *ie++; |
| 14719 | eLen = *ie++; |
| 14720 | remLen -= 2; |
| 14721 | if (eLen > remLen) |
| 14722 | { |
| 14723 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 14724 | "%s: IE length is wrong %d", __func__, eLen); |
| 14725 | return FALSE; |
| 14726 | } |
| 14727 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 14728 | { |
| 14729 | /* OUI - 0x00 0X50 0XF2 |
| 14730 | WPA Information Element - 0x01 |
| 14731 | WPA version - 0x01*/ |
| 14732 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 14733 | return TRUE; |
| 14734 | } |
| 14735 | ie += eLen; |
| 14736 | remLen -= eLen; |
| 14737 | } |
| 14738 | return FALSE; |
| 14739 | } |
| 14740 | |
| 14741 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14742 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14743 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14744 | * parameters during connect operation. |
| 14745 | */ |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14746 | int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14747 | struct cfg80211_connect_params *req |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 14748 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14749 | { |
| 14750 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14751 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14752 | ENTER(); |
| 14753 | |
| 14754 | /*set wpa version*/ |
| 14755 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 14756 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14757 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14758 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 14759 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14760 | { |
| 14761 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 14762 | } |
| 14763 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 14764 | { |
| 14765 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 14766 | } |
| 14767 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14768 | |
| 14769 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14770 | pWextState->wpaVersion); |
| 14771 | |
| 14772 | /*set authentication type*/ |
| 14773 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 14774 | |
| 14775 | if (0 > status) |
| 14776 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14777 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14778 | "%s: failed to set authentication type ", __func__); |
| 14779 | return status; |
| 14780 | } |
| 14781 | |
| 14782 | /*set key mgmt type*/ |
| 14783 | if (req->crypto.n_akm_suites) |
| 14784 | { |
| 14785 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 14786 | if (0 > status) |
| 14787 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14788 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14789 | __func__); |
| 14790 | return status; |
| 14791 | } |
| 14792 | } |
| 14793 | |
| 14794 | /*set pairwise cipher type*/ |
| 14795 | if (req->crypto.n_ciphers_pairwise) |
| 14796 | { |
| 14797 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 14798 | req->crypto.ciphers_pairwise[0], true); |
| 14799 | if (0 > status) |
| 14800 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14801 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14802 | "%s: failed to set unicast cipher type", __func__); |
| 14803 | return status; |
| 14804 | } |
| 14805 | } |
| 14806 | else |
| 14807 | { |
| 14808 | /*Reset previous cipher suite to none*/ |
| 14809 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 14810 | if (0 > status) |
| 14811 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14812 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14813 | "%s: failed to set unicast cipher type", __func__); |
| 14814 | return status; |
| 14815 | } |
| 14816 | } |
| 14817 | |
| 14818 | /*set group cipher type*/ |
| 14819 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 14820 | false); |
| 14821 | |
| 14822 | if (0 > status) |
| 14823 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14824 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14825 | __func__); |
| 14826 | return status; |
| 14827 | } |
| 14828 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 14829 | #ifdef WLAN_FEATURE_11W |
| 14830 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 14831 | #endif |
| 14832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14833 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 14834 | if (req->ie_len) |
| 14835 | { |
| 14836 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 14837 | if ( 0 > status) |
| 14838 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14839 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14840 | __func__); |
| 14841 | return status; |
| 14842 | } |
| 14843 | } |
| 14844 | |
| 14845 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14846 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14847 | { |
| 14848 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 14849 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 14850 | ) |
| 14851 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14852 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14853 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 14854 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14855 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14856 | __func__); |
| 14857 | return -EOPNOTSUPP; |
| 14858 | } |
| 14859 | else |
| 14860 | { |
| 14861 | u8 key_len = req->key_len; |
| 14862 | u8 key_idx = req->key_idx; |
| 14863 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14864 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14865 | && (CSR_MAX_NUM_KEY > key_idx) |
| 14866 | ) |
| 14867 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14868 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14869 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14870 | __func__, key_idx, key_len); |
| 14871 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14872 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14873 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14874 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14875 | (u8)key_len; |
| 14876 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 14877 | } |
| 14878 | } |
| 14879 | } |
| 14880 | } |
| 14881 | |
| 14882 | return status; |
| 14883 | } |
| 14884 | |
| 14885 | /* |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14886 | * FUNCTION: wlan_hdd_try_disconnect |
| 14887 | * This function is used to disconnect from previous |
| 14888 | * connection |
| 14889 | */ |
Agrawal Ashish | c407f19 | 2017-01-23 17:18:35 +0530 | [diff] [blame] | 14890 | int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter ) |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14891 | { |
| 14892 | long ret = 0; |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14893 | int status, result = 0; |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14894 | hdd_station_ctx_t *pHddStaCtx; |
| 14895 | eMib_dot11DesiredBssType connectedBssType; |
Abhishek Singh | 19a7dd9 | 2015-12-30 16:31:51 +0530 | [diff] [blame] | 14896 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14897 | |
Abhishek Singh | 19a7dd9 | 2015-12-30 16:31:51 +0530 | [diff] [blame] | 14898 | ret = wlan_hdd_validate_context(pHddCtx); |
| 14899 | if (0 != ret) |
| 14900 | { |
| 14901 | return ret; |
| 14902 | } |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14903 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14904 | |
| 14905 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 14906 | |
| 14907 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 14908 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
Abhishek Singh | 630ff59 | 2016-01-07 18:15:53 +0530 | [diff] [blame] | 14909 | (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) || |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14910 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
| 14911 | { |
Abhishek Singh | 9f4df78 | 2017-03-15 17:29:10 +0530 | [diff] [blame] | 14912 | /* Indicate disconnect to SME so that in-progress connection or preauth |
| 14913 | * can be aborted |
| 14914 | */ |
| 14915 | sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14916 | pAdapter->sessionId); |
Abhishek Singh | 19a7dd9 | 2015-12-30 16:31:51 +0530 | [diff] [blame] | 14917 | spin_lock_bh(&pAdapter->lock_for_active_session); |
| 14918 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 14919 | { |
| 14920 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 14921 | } |
| 14922 | spin_unlock_bh(&pAdapter->lock_for_active_session); |
Abhishek Singh | f796258 | 2015-10-23 10:54:06 +0530 | [diff] [blame] | 14923 | hdd_connSetConnectionState(pHddStaCtx, |
| 14924 | eConnectionState_Disconnecting); |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14925 | /* Issue disconnect to CSR */ |
| 14926 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14927 | status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14928 | pAdapter->sessionId, |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14929 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 14930 | if(eHAL_STATUS_CMD_NOT_QUEUED == status) { |
| 14931 | hddLog(LOG1, |
| 14932 | FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect")); |
| 14933 | } else if ( 0 != status ) { |
| 14934 | hddLog(LOGE, |
| 14935 | FL("csrRoamDisconnect failure, returned %d"), |
| 14936 | (int)status ); |
| 14937 | result = -EINVAL; |
| 14938 | goto disconnected; |
| 14939 | } |
| 14940 | ret = wait_for_completion_timeout( |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14941 | &pAdapter->disconnect_comp_var, |
| 14942 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14943 | if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status)) { |
| 14944 | hddLog(LOGE, |
| 14945 | "%s: Failed to disconnect, timed out", __func__); |
| 14946 | result = -ETIMEDOUT; |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14947 | } |
| 14948 | } |
| 14949 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 14950 | { |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14951 | ret = wait_for_completion_timeout( |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14952 | &pAdapter->disconnect_comp_var, |
| 14953 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14954 | if (!ret) |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14955 | { |
| 14956 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14957 | result = -ETIMEDOUT; |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14958 | } |
| 14959 | } |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 14960 | disconnected: |
| 14961 | hddLog(LOG1, |
| 14962 | FL("Set HDD connState to eConnectionState_NotConnected")); |
| 14963 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 14964 | return result; |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 14965 | } |
| 14966 | |
Selvaraj, Sridhar | 95e226f | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 14967 | /** |
| 14968 | * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present |
| 14969 | * @adapter: Pointer to the HDD adapter |
| 14970 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
| 14971 | * |
| 14972 | * This function will start reassociation if bssid hint, channel hint and |
| 14973 | * previous bssid parameters are present in the connect request |
| 14974 | * |
| 14975 | * Return: success if reassociation is happening |
| 14976 | * Error code if reassociation is not permitted or not happening |
| 14977 | */ |
| 14978 | #ifdef CFG80211_CONNECT_PREV_BSSID |
| 14979 | static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter, |
| 14980 | struct cfg80211_connect_params *req) |
| 14981 | { |
| 14982 | int status = -EPERM; |
| 14983 | if (req->bssid_hint && req->channel_hint && req->prev_bssid) { |
| 14984 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14985 | FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR), |
| 14986 | req->channel_hint->hw_value, |
| 14987 | MAC_ADDR_ARRAY(req->bssid_hint)); |
| 14988 | status = hdd_reassoc(adapter, req->bssid_hint, |
| 14989 | req->channel_hint->hw_value, |
| 14990 | CONNECT_CMD_USERSPACE); |
| 14991 | } |
| 14992 | return status; |
| 14993 | } |
| 14994 | #else |
| 14995 | static int wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter, |
| 14996 | struct cfg80211_connect_params *req) |
| 14997 | { |
| 14998 | return -EPERM; |
| 14999 | } |
| 15000 | #endif |
| 15001 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 15002 | /* |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15003 | * FUNCTION: __wlan_hdd_cfg80211_connect |
| 15004 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15005 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 15006 | static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15007 | struct net_device *ndev, |
| 15008 | struct cfg80211_connect_params *req |
| 15009 | ) |
| 15010 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15011 | int status; |
Sreelakshmi Konamki | e652174 | 2016-03-18 12:44:27 +0530 | [diff] [blame] | 15012 | u16 channel; |
Edhar, Mahesh Kumar | 496c7f7 | 2016-03-18 12:47:44 +0530 | [diff] [blame] | 15013 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || \ |
| 15014 | defined(CFG80211_BSSID_HINT_BACKPORT) |
Sreelakshmi Konamki | e652174 | 2016-03-18 12:44:27 +0530 | [diff] [blame] | 15015 | const u8 *bssid_hint = req->bssid_hint; |
| 15016 | #else |
| 15017 | const u8 *bssid_hint = NULL; |
| 15018 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15019 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15020 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
Sushant Kaushik | ba6764e | 2014-06-30 19:52:09 +0530 | [diff] [blame] | 15021 | hdd_context_t *pHddCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15022 | |
| 15023 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 15024 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 15025 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 15026 | TRACE_CODE_HDD_CFG80211_CONNECT, |
| 15027 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15028 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 15029 | "%s: device_mode = %s (%d)", __func__, |
| 15030 | hdd_device_modetoString(pAdapter->device_mode), |
| 15031 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15032 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15033 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 15034 | if (!pHddCtx) |
| 15035 | { |
| 15036 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15037 | "%s: HDD context is null", __func__); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15038 | return -EINVAL; |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 15039 | } |
| 15040 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15041 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15042 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15043 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15044 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15045 | } |
| 15046 | |
Selvaraj, Sridhar | 95e226f | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 15047 | status = wlan_hdd_reassoc_bssid_hint(pAdapter, req); |
| 15048 | if (0 == status) |
| 15049 | return status; |
| 15050 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15051 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15052 | #ifdef WLAN_BTAMP_FEATURE |
| 15053 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15054 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15055 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15056 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15057 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 15058 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15059 | } |
| 15060 | #endif |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 15061 | |
| 15062 | //If Device Mode is Station Concurrent Sessions Exit BMps |
| 15063 | //P2P Mode will be taken care in Open/close adapter |
| 15064 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15065 | (vos_concurrent_open_sessions_running())) { |
| 15066 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, |
| 15067 | WLAN_HDD_INFRA_STATION); |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 15068 | } |
| 15069 | |
| 15070 | /*Try disconnecting if already in connected state*/ |
| 15071 | status = wlan_hdd_try_disconnect(pAdapter); |
| 15072 | if ( 0 > status) |
| 15073 | { |
| 15074 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 15075 | " connection")); |
| 15076 | return -EALREADY; |
| 15077 | } |
Agrawal Ashish | 559530c | 2015-12-01 18:04:20 +0530 | [diff] [blame] | 15078 | /* Check for max concurrent connections after doing disconnect if any*/ |
| 15079 | if (vos_max_concurrent_connections_reached()) { |
| 15080 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 15081 | return -ECONNREFUSED; |
| 15082 | } |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 15083 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15084 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15085 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15086 | |
| 15087 | if ( 0 > status) |
| 15088 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15089 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15090 | __func__); |
| 15091 | return status; |
| 15092 | } |
Sravan Kumar Kairam | 589c572 | 2016-01-27 20:28:53 +0530 | [diff] [blame] | 15093 | |
| 15094 | if (pHddCtx->spoofMacAddr.isEnabled) |
| 15095 | { |
| 15096 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 15097 | "%s: MAC Spoofing enabled ", __func__); |
| 15098 | /* Updating SelfSta Mac Addr in TL which will be used to get staidx |
| 15099 | * to fill TxBds for probe request during SSID scan which may happen |
| 15100 | * as part of connect command |
| 15101 | */ |
| 15102 | status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext, |
| 15103 | &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent); |
| 15104 | if (status != VOS_STATUS_SUCCESS) |
| 15105 | return -ECONNREFUSED; |
| 15106 | } |
| 15107 | |
Sreelakshmi Konamki | e652174 | 2016-03-18 12:44:27 +0530 | [diff] [blame] | 15108 | if (req->channel) |
| 15109 | channel = req->channel->hw_value; |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 15110 | else |
Sreelakshmi Konamki | e652174 | 2016-03-18 12:44:27 +0530 | [diff] [blame] | 15111 | channel = 0; |
Kapil Gupta | 312028a | 2016-10-25 14:15:20 +0530 | [diff] [blame] | 15112 | |
| 15113 | /* Abort if any scan is going on */ |
| 15114 | status = wlan_hdd_scan_abort(pAdapter); |
| 15115 | if (0 != status) |
| 15116 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("scan abort failed")); |
| 15117 | |
Sreelakshmi Konamki | e652174 | 2016-03-18 12:44:27 +0530 | [diff] [blame] | 15118 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 15119 | req->ssid_len, req->bssid, |
| 15120 | bssid_hint, channel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15121 | |
Sushant Kaushik | d708398 | 2015-03-18 14:33:24 +0530 | [diff] [blame] | 15122 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15123 | { |
| 15124 | //ReEnable BMPS if disabled |
| 15125 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 15126 | (NULL != pHddCtx)) |
| 15127 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 15128 | if (pHddCtx->hdd_wlan_suspended) |
| 15129 | { |
| 15130 | hdd_set_pwrparams(pHddCtx); |
| 15131 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15132 | //ReEnable Bmps and Imps back |
| 15133 | hdd_enable_bmps_imps(pHddCtx); |
| 15134 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15135 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15136 | return status; |
| 15137 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15138 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15139 | EXIT(); |
| 15140 | return status; |
| 15141 | } |
| 15142 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 15143 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
| 15144 | struct net_device *ndev, |
| 15145 | struct cfg80211_connect_params *req) |
| 15146 | { |
| 15147 | int ret; |
| 15148 | vos_ssr_protect(__func__); |
| 15149 | ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
| 15150 | vos_ssr_unprotect(__func__); |
| 15151 | |
| 15152 | return ret; |
| 15153 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15154 | |
| 15155 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15156 | * FUNCTION: wlan_hdd_disconnect |
| 15157 | * This function is used to issue a disconnect request to SME |
| 15158 | */ |
| 15159 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 15160 | { |
Abhishek Singh | 6ab864d | 2014-11-27 12:10:10 +0530 | [diff] [blame] | 15161 | int status, result = 0; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15162 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15163 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 15164 | long ret; |
Padma, Santhosh Kumar | 5f7d10e | 2016-12-05 18:55:06 +0530 | [diff] [blame] | 15165 | eConnectionState prev_conn_state; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15166 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15167 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15168 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15169 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15170 | if (0 != status) |
| 15171 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15172 | return status; |
| 15173 | } |
Abhishek Singh | 07e4a89 | 2015-11-23 11:29:57 +0530 | [diff] [blame] | 15174 | /* Indicate sme of disconnect so that in progress connection or preauth |
| 15175 | * can be aborted |
| 15176 | */ |
| 15177 | sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Sushant Kaushik | b4834d2 | 2015-07-15 15:29:05 +0530 | [diff] [blame] | 15178 | pAdapter->sessionId); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15179 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 15180 | |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 15181 | /* Need to apply spin lock before decreasing active sessions |
| 15182 | * as there can be chance for double decrement if context switch |
| 15183 | * Calls hdd_DisConnectHandler. |
| 15184 | */ |
| 15185 | |
Padma, Santhosh Kumar | 5f7d10e | 2016-12-05 18:55:06 +0530 | [diff] [blame] | 15186 | prev_conn_state = pHddStaCtx->conn_info.connState; |
| 15187 | |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 15188 | spin_lock_bh(&pAdapter->lock_for_active_session); |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 15189 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 15190 | { |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 15191 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 15192 | } |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 15193 | hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting ); |
| 15194 | spin_unlock_bh(&pAdapter->lock_for_active_session); |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 15195 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 15196 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 15197 | FL( "Set HDD connState to eConnectionState_Disconnecting" )); |
| 15198 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15199 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15200 | |
Mihir Shete | 182a0b2 | 2014-08-18 16:08:48 +0530 | [diff] [blame] | 15201 | /* |
| 15202 | * stop tx queues before deleting STA/BSS context from the firmware. |
| 15203 | * tx has to be disabled because the firmware can get busy dropping |
| 15204 | * the tx frames after BSS/STA has been deleted and will not send |
| 15205 | * back a response resulting in WDI timeout |
| 15206 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 15207 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Mihir Shete | 182a0b2 | 2014-08-18 16:08:48 +0530 | [diff] [blame] | 15208 | netif_tx_disable(pAdapter->dev); |
| 15209 | netif_carrier_off(pAdapter->dev); |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 15210 | |
Mihir Shete | 182a0b2 | 2014-08-18 16:08:48 +0530 | [diff] [blame] | 15211 | /*issue disconnect*/ |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15212 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 15213 | pAdapter->sessionId, reason); |
Padma, Santhosh Kumar | 5f7d10e | 2016-12-05 18:55:06 +0530 | [diff] [blame] | 15214 | if((eHAL_STATUS_CMD_NOT_QUEUED == status) && |
| 15215 | prev_conn_state != eConnectionState_Connecting) |
| 15216 | { |
| 15217 | hddLog(LOG1, |
| 15218 | FL("status = %d, already disconnected"), status); |
| 15219 | result = 0; |
| 15220 | goto disconnected; |
| 15221 | } |
| 15222 | /* |
| 15223 | * Wait here instead of returning directly, this will block the next |
| 15224 | * connect command and allow processing of the scan for ssid and |
| 15225 | * the previous connect command in CSR. Else we might hit some |
| 15226 | * race conditions leading to SME and HDD out of sync. |
| 15227 | */ |
| 15228 | else if(eHAL_STATUS_CMD_NOT_QUEUED == status) |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 15229 | { |
| 15230 | hddLog(LOG1, |
| 15231 | FL("Already disconnected or connect was in sme/roam pending list and removed by disconnect")); |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 15232 | } |
| 15233 | else if ( 0 != status ) |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15234 | { |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 15235 | hddLog(LOGE, |
| 15236 | FL("csrRoamDisconnect failure, returned %d"), |
| 15237 | (int)status); |
Abhishek Singh | 6ab864d | 2014-11-27 12:10:10 +0530 | [diff] [blame] | 15238 | result = -EINVAL; |
| 15239 | goto disconnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15240 | } |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 15241 | ret = wait_for_completion_timeout( |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15242 | &pAdapter->disconnect_comp_var, |
| 15243 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 15244 | if (!ret && (eHAL_STATUS_CMD_NOT_QUEUED != status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 15245 | { |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 15246 | hddLog(LOGE, |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 15247 | "%s: Failed to disconnect, timed out", __func__); |
Abhishek Singh | 6ab864d | 2014-11-27 12:10:10 +0530 | [diff] [blame] | 15248 | result = -ETIMEDOUT; |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 15249 | } |
Abhishek Singh | 6ab864d | 2014-11-27 12:10:10 +0530 | [diff] [blame] | 15250 | disconnected: |
Abhishek Singh | f1b048a | 2016-01-13 13:57:27 +0530 | [diff] [blame] | 15251 | hddLog(LOG1, |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 15252 | FL("Set HDD connState to eConnectionState_NotConnected")); |
| 15253 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Mahesh A Saptasagar | 936ffc3 | 2016-05-25 11:27:43 +0530 | [diff] [blame] | 15254 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) |
| 15255 | /* Sending disconnect event to userspace for kernel version < 3.11 |
| 15256 | * is handled by __cfg80211_disconnect call to __cfg80211_disconnected |
| 15257 | */ |
| 15258 | hddLog(LOG1, FL("Send disconnected event to userspace")); |
| 15259 | |
Mahesh A Saptasagar | f5859b1 | 2016-06-01 17:17:50 +0530 | [diff] [blame] | 15260 | wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true, |
Mahesh A Saptasagar | 936ffc3 | 2016-05-25 11:27:43 +0530 | [diff] [blame] | 15261 | WLAN_REASON_UNSPECIFIED); |
| 15262 | #endif |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 15263 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15264 | EXIT(); |
Abhishek Singh | 6ab864d | 2014-11-27 12:10:10 +0530 | [diff] [blame] | 15265 | return result; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15266 | } |
| 15267 | |
| 15268 | |
| 15269 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 15270 | * FUNCTION: __wlan_hdd_cfg80211_disconnect |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15271 | * This function is used to issue a disconnect request to SME |
| 15272 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 15273 | static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15274 | struct net_device *dev, |
| 15275 | u16 reason |
| 15276 | ) |
| 15277 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15278 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15279 | int status; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 15280 | tCsrRoamProfile *pRoamProfile; |
| 15281 | hdd_station_ctx_t *pHddStaCtx; |
| 15282 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 15283 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 15284 | tANI_U8 staIdx; |
| 15285 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15286 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15287 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 15288 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 15289 | if (!pAdapter) { |
| 15290 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 15291 | return -EINVAL; |
| 15292 | } |
| 15293 | |
| 15294 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 15295 | if (!pHddStaCtx) { |
| 15296 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL")); |
| 15297 | return -EINVAL; |
| 15298 | } |
| 15299 | |
| 15300 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 15301 | status = wlan_hdd_validate_context(pHddCtx); |
| 15302 | if (0 != status) |
| 15303 | { |
| 15304 | return status; |
| 15305 | } |
| 15306 | |
| 15307 | pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
| 15308 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 15309 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 15310 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
| 15311 | pAdapter->sessionId, reason)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 15312 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)", |
| 15313 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 15314 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15315 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15316 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 15317 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15318 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15319 | if (NULL != pRoamProfile) |
| 15320 | { |
| 15321 | /*issue disconnect request to SME, if station is in connected state*/ |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 15322 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 15323 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15324 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15325 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15326 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 15327 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15328 | switch(reason) |
| 15329 | { |
| 15330 | case WLAN_REASON_MIC_FAILURE: |
| 15331 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 15332 | break; |
| 15333 | |
| 15334 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 15335 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 15336 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 15337 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 15338 | break; |
| 15339 | |
| 15340 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 15341 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
Abhishek Singh | c3269a5 | 2014-05-21 17:22:24 +0530 | [diff] [blame] | 15342 | case WLAN_REASON_DEAUTH_LEAVING: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15343 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 15344 | break; |
| 15345 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15346 | default: |
| 15347 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 15348 | break; |
| 15349 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 15350 | pScanInfo = &pHddCtx->scan_info; |
| 15351 | if (pScanInfo->mScanPending) |
| 15352 | { |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 15353 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 15354 | "Aborting Scan"); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 15355 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 15356 | eCSR_SCAN_ABORT_DEFAULT); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 15357 | } |
Agarwal Ashish | c089cec | 2015-08-10 13:10:04 +0530 | [diff] [blame] | 15358 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 15359 | #ifdef FEATURE_WLAN_TDLS |
| 15360 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 15361 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 15362 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 15363 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 15364 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 15365 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 15366 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 15367 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 15368 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 15369 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 15370 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 15371 | MAC_ADDR_ARRAY(mac)); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 15372 | status = sme_DeleteTdlsPeerSta( |
| 15373 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 15374 | pAdapter->sessionId, |
| 15375 | mac); |
| 15376 | if (status != eHAL_STATUS_SUCCESS) { |
| 15377 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA")); |
| 15378 | return -EPERM; |
| 15379 | } |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 15380 | } |
| 15381 | } |
| 15382 | #endif |
Padma, Santhosh Kumar | 5f7d10e | 2016-12-05 18:55:06 +0530 | [diff] [blame] | 15383 | |
| 15384 | hddLog(LOG1, FL("Disconnecting with reasoncode:%u connState %d"), |
| 15385 | reasonCode, |
| 15386 | pHddStaCtx->conn_info.connState); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15387 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 15388 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15389 | { |
| 15390 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 15391 | "%s wlan_hdd_disconnect failure, returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15392 | __func__, (int)status ); |
| 15393 | return -EINVAL; |
| 15394 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15395 | } |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 15396 | else |
| 15397 | { |
| 15398 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API" |
| 15399 | "called while in %d state", __func__, |
| 15400 | pHddStaCtx->conn_info.connState); |
| 15401 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15402 | } |
| 15403 | else |
| 15404 | { |
| 15405 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 15406 | } |
| 15407 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15408 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15409 | return status; |
| 15410 | } |
| 15411 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 15412 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
| 15413 | struct net_device *dev, |
| 15414 | u16 reason |
| 15415 | ) |
| 15416 | { |
| 15417 | int ret; |
| 15418 | vos_ssr_protect(__func__); |
| 15419 | ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
| 15420 | vos_ssr_unprotect(__func__); |
| 15421 | |
| 15422 | return ret; |
| 15423 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 15424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15425 | /* |
| 15426 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15427 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15428 | * settings in IBSS mode. |
| 15429 | */ |
| 15430 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15431 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15432 | struct cfg80211_ibss_params *params |
| 15433 | ) |
| 15434 | { |
| 15435 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15436 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15437 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 15438 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15439 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15440 | ENTER(); |
| 15441 | |
| 15442 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Ravi Joshi | b58ca0d | 2013-10-29 09:50:23 -0700 | [diff] [blame] | 15443 | vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15444 | |
| 15445 | if (params->ie_len && ( NULL != params->ie) ) |
| 15446 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 15447 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 15448 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15449 | { |
| 15450 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 15451 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 15452 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 15453 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15454 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 15455 | tDot11fIEWPA dot11WPAIE; |
| 15456 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 15457 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 15458 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 15459 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 15460 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 15461 | params->ie_len, DOT11F_EID_WPA); |
| 15462 | if ( NULL != ie ) |
| 15463 | { |
| 15464 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 15465 | // Unpack the WPA IE |
| 15466 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 15467 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 15468 | &ie[2+4], |
| 15469 | ie[1] - 4, |
| 15470 | &dot11WPAIE); |
| 15471 | /*Extract the multicast cipher, the encType for unicast |
| 15472 | cipher for wpa-none is none*/ |
| 15473 | encryptionType = |
| 15474 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 15475 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15476 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 15477 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15478 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 15479 | |
| 15480 | if (0 > status) |
| 15481 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15482 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15483 | __func__); |
| 15484 | return status; |
| 15485 | } |
| 15486 | } |
| 15487 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15488 | pWextState->roamProfile.AuthType.authType[0] = |
| 15489 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15490 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 15491 | |
| 15492 | if (params->privacy) |
| 15493 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15494 | /* Security enabled IBSS, At this time there is no information available |
| 15495 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15496 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15497 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15498 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15499 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15500 | *enable privacy bit in beacons */ |
| 15501 | |
| 15502 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 15503 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 15504 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 15505 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15506 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 15507 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 15508 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15509 | return status; |
| 15510 | } |
| 15511 | |
| 15512 | /* |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 15513 | * FUNCTION: __wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15514 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15515 | */ |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 15516 | static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15517 | struct net_device *dev, |
| 15518 | struct cfg80211_ibss_params *params |
| 15519 | ) |
| 15520 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15521 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15522 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 15523 | tCsrRoamProfile *pRoamProfile; |
| 15524 | int status; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 15525 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 15526 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 15527 | tSirMacAddr bssid; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15528 | |
| 15529 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 15530 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 15531 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 15532 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
| 15533 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15534 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 15535 | "%s: device_mode = %s (%d)", __func__, |
| 15536 | hdd_device_modetoString(pAdapter->device_mode), |
| 15537 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15538 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15539 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15540 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15541 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15542 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15543 | } |
| 15544 | |
| 15545 | if (NULL == pWextState) |
| 15546 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 15547 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15548 | __func__); |
| 15549 | return -EIO; |
| 15550 | } |
| 15551 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15552 | if (vos_max_concurrent_connections_reached()) { |
| 15553 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 15554 | return -ECONNREFUSED; |
| 15555 | } |
| 15556 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 15557 | /*Try disconnecting if already in connected state*/ |
| 15558 | status = wlan_hdd_try_disconnect(pAdapter); |
| 15559 | if ( 0 > status) |
| 15560 | { |
| 15561 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 15562 | " IBSS connection")); |
| 15563 | return -EALREADY; |
| 15564 | } |
| 15565 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15566 | pRoamProfile = &pWextState->roamProfile; |
| 15567 | |
| 15568 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 15569 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15570 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 15571 | "%s Interface type is not set to IBSS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15572 | return -EINVAL; |
| 15573 | } |
| 15574 | |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 15575 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 15576 | if (NULL != params->bssid) { |
| 15577 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 15578 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) { |
| 15579 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 15580 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 15581 | return -EIO; |
| 15582 | } |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 15583 | vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid)); |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 15584 | } |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 15585 | else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0) |
| 15586 | { |
| 15587 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 15588 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 15589 | { |
| 15590 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 15591 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 15592 | return -EIO; |
| 15593 | } |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 15594 | |
| 15595 | vos_mem_copy((v_U8_t *)bssid, |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 15596 | (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0], |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 15597 | sizeof(bssid)); |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 15598 | } |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 15599 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15600 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 15601 | if (NULL != |
| 15602 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 15603 | params->chandef.chan) |
| 15604 | #else |
| 15605 | params->channel) |
| 15606 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15607 | { |
| 15608 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15609 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 15610 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 15611 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 15612 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15613 | |
| 15614 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15615 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 15616 | ieee80211_frequency_to_channel( |
| 15617 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 15618 | params->chandef.chan->center_freq); |
| 15619 | #else |
| 15620 | params->channel->center_freq); |
| 15621 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15622 | |
| 15623 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 15624 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15625 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15626 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 15627 | __func__); |
| 15628 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15629 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15630 | |
| 15631 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15632 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15633 | if (channelNum == validChan[indx]) |
| 15634 | { |
| 15635 | break; |
| 15636 | } |
| 15637 | } |
| 15638 | if (indx >= numChans) |
| 15639 | { |
| 15640 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15641 | __func__, channelNum); |
| 15642 | return -EINVAL; |
| 15643 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15644 | /* Set the Operational Channel */ |
| 15645 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 15646 | channelNum); |
| 15647 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 15648 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 15649 | pRoamProfile->ChannelInfo.ChannelList = |
| 15650 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15651 | } |
| 15652 | |
| 15653 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15654 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15655 | if (status < 0) |
| 15656 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15657 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15658 | __func__); |
| 15659 | return status; |
| 15660 | } |
| 15661 | |
| 15662 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15663 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Abhishek Singh | 4d92468 | 2015-11-17 15:23:06 +0530 | [diff] [blame] | 15664 | params->ssid_len, (const u8 *)&bssid, NULL, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 15665 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15666 | |
| 15667 | if (0 > status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15668 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15669 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15670 | EXIT(); |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 15671 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15672 | } |
| 15673 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 15674 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
| 15675 | struct net_device *dev, |
| 15676 | struct cfg80211_ibss_params *params |
| 15677 | ) |
| 15678 | { |
| 15679 | int ret = 0; |
| 15680 | |
| 15681 | vos_ssr_protect(__func__); |
| 15682 | ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params); |
| 15683 | vos_ssr_unprotect(__func__); |
| 15684 | |
| 15685 | return ret; |
| 15686 | } |
| 15687 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15688 | /* |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 15689 | * FUNCTION: __wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15690 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15691 | */ |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 15692 | static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15693 | struct net_device *dev |
| 15694 | ) |
| 15695 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15696 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 15697 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 15698 | tCsrRoamProfile *pRoamProfile; |
| 15699 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15700 | int status; |
Abhishek Singh | 69de330 | 2016-11-11 16:44:32 +0530 | [diff] [blame] | 15701 | eHalStatus hal_status; |
Abhishek Singh | 7cd040e | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 15702 | #ifdef WLAN_FEATURE_RMC |
| 15703 | tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN] = {0}; |
| 15704 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15705 | |
| 15706 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 15707 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 15708 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 15709 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
| 15710 | pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15711 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15712 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 15713 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15714 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 15715 | } |
| 15716 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 15717 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__, |
| 15718 | hdd_device_modetoString(pAdapter->device_mode), |
| 15719 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15720 | if (NULL == pWextState) |
| 15721 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 15722 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15723 | __func__); |
| 15724 | return -EIO; |
| 15725 | } |
| 15726 | |
| 15727 | pRoamProfile = &pWextState->roamProfile; |
| 15728 | |
| 15729 | /* Issue disconnect only if interface type is set to IBSS */ |
| 15730 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 15731 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15732 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15733 | __func__); |
| 15734 | return -EINVAL; |
| 15735 | } |
| 15736 | |
Abhishek Singh | 7cd040e | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 15737 | #ifdef WLAN_FEATURE_RMC |
| 15738 | /* Clearing add IE of beacon */ |
| 15739 | if (ccmCfgSetStr(pHddCtx->hHal, |
| 15740 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0], |
| 15741 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN, |
| 15742 | NULL, eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 15743 | { |
| 15744 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 15745 | "%s: unable to clear PROBE_RSP_BCN_ADDNIE_DATA", __func__); |
| 15746 | return -EINVAL; |
| 15747 | } |
| 15748 | if (ccmCfgSetInt(pHddCtx->hHal, |
| 15749 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0, NULL, |
| 15750 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 15751 | { |
| 15752 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 15753 | "%s: unable to clear WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
| 15754 | __func__); |
| 15755 | return -EINVAL; |
| 15756 | } |
| 15757 | |
| 15758 | // Reset WNI_CFG_PROBE_RSP Flags |
| 15759 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 15760 | |
| 15761 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 15762 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 0,NULL, |
| 15763 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 15764 | { |
| 15765 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 15766 | "%s: unable to clear WNI_CFG_PROBE_RSP_ADDNIE_FLAG", |
| 15767 | __func__); |
| 15768 | return -EINVAL; |
| 15769 | } |
| 15770 | #endif |
| 15771 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15772 | /* Issue Disconnect request */ |
| 15773 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Abhishek Singh | 69de330 | 2016-11-11 16:44:32 +0530 | [diff] [blame] | 15774 | hal_status = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 15775 | pAdapter->sessionId, |
| 15776 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 15777 | if (!HAL_STATUS_SUCCESS(hal_status)) { |
| 15778 | hddLog(LOGE, |
| 15779 | FL("sme_RoamDisconnect failed hal_status(%d)"), |
| 15780 | hal_status); |
| 15781 | return -EAGAIN; |
| 15782 | } |
| 15783 | status = wait_for_completion_timeout( |
| 15784 | &pAdapter->disconnect_comp_var, |
| 15785 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 15786 | if (!status) { |
| 15787 | hddLog(LOGE, |
| 15788 | FL("wait on disconnect_comp_var failed")); |
| 15789 | return -ETIMEDOUT; |
| 15790 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15791 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15792 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15793 | return 0; |
| 15794 | } |
| 15795 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 15796 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
| 15797 | struct net_device *dev |
| 15798 | ) |
| 15799 | { |
| 15800 | int ret = 0; |
| 15801 | |
| 15802 | vos_ssr_protect(__func__); |
| 15803 | ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev); |
| 15804 | vos_ssr_unprotect(__func__); |
| 15805 | |
| 15806 | return ret; |
| 15807 | } |
| 15808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15809 | /* |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 15810 | * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15811 | * This function is used to set the phy parameters |
| 15812 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 15813 | */ |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 15814 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15815 | u32 changed) |
| 15816 | { |
| 15817 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 15818 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15819 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15820 | |
| 15821 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15822 | |
| 15823 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 15824 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 15825 | NO_SESSION, wiphy->rts_threshold)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15826 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15827 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15828 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 15829 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15830 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 15831 | } |
| 15832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15833 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 15834 | { |
| 15835 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 15836 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 15837 | wiphy->rts_threshold; |
| 15838 | |
| 15839 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15840 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15841 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15842 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15843 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15844 | __func__, rts_threshold); |
| 15845 | return -EINVAL; |
| 15846 | } |
| 15847 | |
| 15848 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 15849 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15850 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15851 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15852 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15853 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15854 | __func__, rts_threshold); |
| 15855 | return -EIO; |
| 15856 | } |
| 15857 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15858 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15859 | rts_threshold); |
| 15860 | } |
| 15861 | |
| 15862 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 15863 | { |
| 15864 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 15865 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 15866 | wiphy->frag_threshold; |
| 15867 | |
| 15868 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15869 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15870 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15871 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15872 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15873 | frag_threshold); |
| 15874 | return -EINVAL; |
| 15875 | } |
| 15876 | |
| 15877 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 15878 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15879 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15880 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15881 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15882 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15883 | __func__, frag_threshold); |
| 15884 | return -EIO; |
| 15885 | } |
| 15886 | |
| 15887 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 15888 | frag_threshold); |
| 15889 | } |
| 15890 | |
| 15891 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 15892 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 15893 | { |
| 15894 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 15895 | wiphy->retry_short : |
| 15896 | wiphy->retry_long; |
| 15897 | |
| 15898 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 15899 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 15900 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15901 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15902 | __func__, retry_value); |
| 15903 | return -EINVAL; |
| 15904 | } |
| 15905 | |
| 15906 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 15907 | { |
| 15908 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 15909 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15910 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15911 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15912 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15913 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15914 | __func__, retry_value); |
| 15915 | return -EIO; |
| 15916 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15917 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15918 | __func__, retry_value); |
| 15919 | } |
| 15920 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 15921 | { |
| 15922 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 15923 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15924 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15925 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15926 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15927 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15928 | __func__, retry_value); |
| 15929 | return -EIO; |
| 15930 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15931 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15932 | __func__, retry_value); |
| 15933 | } |
| 15934 | } |
| 15935 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15936 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15937 | return 0; |
| 15938 | } |
| 15939 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 15940 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 15941 | u32 changed) |
| 15942 | { |
| 15943 | int ret; |
| 15944 | |
| 15945 | vos_ssr_protect(__func__); |
| 15946 | ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
| 15947 | vos_ssr_unprotect(__func__); |
| 15948 | |
| 15949 | return ret; |
| 15950 | } |
| 15951 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15952 | /* |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 15953 | * FUNCTION: __wlan_hdd_cfg80211_set_txpower |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15954 | * This function is used to set the txpower |
| 15955 | */ |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 15956 | static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 15957 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 15958 | struct wireless_dev *wdev, |
| 15959 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15960 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15961 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15962 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15963 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15964 | #endif |
| 15965 | int dbm) |
| 15966 | { |
| 15967 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15968 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15969 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 15970 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15971 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15972 | |
| 15973 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 15974 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 15975 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 15976 | TRACE_CODE_HDD_CFG80211_SET_TXPOWER, |
| 15977 | NO_SESSION, type )); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15978 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15979 | if (0 != status) |
| 15980 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 15981 | return status; |
| 15982 | } |
| 15983 | |
| 15984 | hHal = pHddCtx->hHal; |
| 15985 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15986 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 15987 | dbm, ccmCfgSetCallback, |
| 15988 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15989 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 15990 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15991 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 15992 | return -EIO; |
| 15993 | } |
| 15994 | |
| 15995 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 15996 | dbm); |
| 15997 | |
| 15998 | switch(type) |
| 15999 | { |
| 16000 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 16001 | /* Fall through */ |
| 16002 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 16003 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 16004 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16005 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 16006 | __func__); |
| 16007 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16008 | } |
| 16009 | break; |
| 16010 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16011 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16012 | __func__); |
| 16013 | return -EOPNOTSUPP; |
| 16014 | break; |
| 16015 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16016 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 16017 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16018 | return -EIO; |
| 16019 | } |
| 16020 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 16021 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16022 | return 0; |
| 16023 | } |
| 16024 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 16025 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 16026 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 16027 | struct wireless_dev *wdev, |
| 16028 | #endif |
| 16029 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
| 16030 | enum tx_power_setting type, |
| 16031 | #else |
| 16032 | enum nl80211_tx_power_setting type, |
| 16033 | #endif |
| 16034 | int dbm) |
| 16035 | { |
| 16036 | int ret; |
| 16037 | vos_ssr_protect(__func__); |
| 16038 | ret = __wlan_hdd_cfg80211_set_txpower(wiphy, |
| 16039 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 16040 | wdev, |
| 16041 | #endif |
| 16042 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
| 16043 | type, |
| 16044 | #else |
| 16045 | type, |
| 16046 | #endif |
| 16047 | dbm); |
| 16048 | vos_ssr_unprotect(__func__); |
| 16049 | |
| 16050 | return ret; |
| 16051 | } |
| 16052 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16053 | /* |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16054 | * FUNCTION: __wlan_hdd_cfg80211_get_txpower |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16055 | * This function is used to read the txpower |
| 16056 | */ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16057 | static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 16058 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 16059 | struct wireless_dev *wdev, |
| 16060 | #endif |
| 16061 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16062 | { |
| 16063 | |
| 16064 | hdd_adapter_t *pAdapter; |
| 16065 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16066 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16067 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16068 | ENTER(); |
| 16069 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16070 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16071 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16072 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16073 | *dbm = 0; |
| 16074 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16075 | } |
| 16076 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16077 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 16078 | if (NULL == pAdapter) |
| 16079 | { |
| 16080 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 16081 | return -ENOENT; |
| 16082 | } |
| 16083 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 16084 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 16085 | TRACE_CODE_HDD_CFG80211_GET_TXPOWER, |
| 16086 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16087 | wlan_hdd_get_classAstats(pAdapter); |
| 16088 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 16089 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16090 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16091 | return 0; |
| 16092 | } |
| 16093 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16094 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 16095 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 16096 | struct wireless_dev *wdev, |
| 16097 | #endif |
| 16098 | int *dbm) |
| 16099 | { |
| 16100 | int ret; |
| 16101 | |
| 16102 | vos_ssr_protect(__func__); |
| 16103 | ret = __wlan_hdd_cfg80211_get_txpower(wiphy, |
| 16104 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 16105 | wdev, |
| 16106 | #endif |
| 16107 | dbm); |
| 16108 | vos_ssr_unprotect(__func__); |
| 16109 | |
| 16110 | return ret; |
| 16111 | } |
| 16112 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16113 | static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16114 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 16115 | const u8* mac, |
| 16116 | #else |
| 16117 | u8* mac, |
| 16118 | #endif |
| 16119 | struct station_info *sinfo) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16120 | { |
| 16121 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 16122 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 16123 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 16124 | tANI_U32 rate_flags; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16125 | |
| 16126 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 16127 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16128 | |
| 16129 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 16130 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 16131 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 16132 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 16133 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 16134 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 16135 | tANI_U16 maxRate = 0; |
| 16136 | tANI_U16 myRate; |
| 16137 | tANI_U16 currentRate = 0; |
| 16138 | tANI_U8 maxSpeedMCS = 0; |
| 16139 | tANI_U8 maxMCSIdx = 0; |
| 16140 | tANI_U8 rateFlag = 1; |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16141 | tANI_U8 i, j, rssidx, mode=0; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 16142 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16143 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16144 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16145 | #ifdef WLAN_FEATURE_11AC |
| 16146 | tANI_U32 vht_mcs_map; |
| 16147 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 16148 | #endif /* WLAN_FEATURE_11AC */ |
| 16149 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16150 | ENTER(); |
| 16151 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16152 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 16153 | (0 == ssidlen)) |
| 16154 | { |
| 16155 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 16156 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 16157 | /*To keep GUI happy*/ |
| 16158 | return 0; |
| 16159 | } |
| 16160 | |
Mukul Sharma | 811205f | 2014-07-09 21:07:30 +0530 | [diff] [blame] | 16161 | if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) |
| 16162 | { |
| 16163 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 16164 | "%s: Roaming in progress, so unable to proceed this request", __func__); |
Sachin Ahuja | 81ab181 | 2016-08-19 21:35:58 +0530 | [diff] [blame] | 16165 | /* return a cached value */ |
| 16166 | sinfo->signal = pAdapter->rssi; |
Mukul Sharma | 811205f | 2014-07-09 21:07:30 +0530 | [diff] [blame] | 16167 | return 0; |
| 16168 | } |
| 16169 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16170 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16171 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16172 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16173 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16174 | } |
| 16175 | |
Hanumantha Reddy Pothula | dce6674 | 2015-08-25 18:08:44 +0530 | [diff] [blame] | 16176 | wlan_hdd_get_station_stats(pAdapter); |
| 16177 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16178 | |
Kiet Lam | 3b17fc8 | 2013-09-27 05:24:08 +0530 | [diff] [blame] | 16179 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 16180 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 16181 | |
c_hpothu | 09f1954 | 2014-05-30 21:53:31 +0530 | [diff] [blame] | 16182 | /*overwrite rate_flags if MAX link-speed need to be reported*/ |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 16183 | if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) || |
| 16184 | (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed && |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16185 | sinfo->signal >= pCfg->linkSpeedRssiLow)) |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 16186 | { |
| 16187 | rate_flags = pAdapter->maxRateFlags; |
| 16188 | } |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 16189 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16190 | //convert to the UI units of 100kbps |
| 16191 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 16192 | |
| 16193 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16194 | pr_info("RSSI %d, RLMS %u, rate %d, rssi high %d, rssi mid %d, rssi low %d, rate_flags 0x%x, MCS %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16195 | sinfo->signal, |
| 16196 | pCfg->reportMaxLinkSpeed, |
| 16197 | myRate, |
| 16198 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 16199 | (int) pCfg->linkSpeedRssiMid, |
| 16200 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16201 | (int) rate_flags, |
| 16202 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16203 | #endif //LINKSPEED_DEBUG_ENABLED |
| 16204 | |
| 16205 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 16206 | { |
| 16207 | // we do not want to necessarily report the current speed |
| 16208 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 16209 | { |
| 16210 | // report the max possible speed |
| 16211 | rssidx = 0; |
| 16212 | } |
| 16213 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 16214 | { |
| 16215 | // report the max possible speed with RSSI scaling |
| 16216 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 16217 | { |
| 16218 | // report the max possible speed |
| 16219 | rssidx = 0; |
| 16220 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 16221 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16222 | { |
| 16223 | // report middle speed |
| 16224 | rssidx = 1; |
| 16225 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 16226 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 16227 | { |
| 16228 | // report middle speed |
| 16229 | rssidx = 2; |
| 16230 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16231 | else |
| 16232 | { |
| 16233 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 16234 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16235 | } |
| 16236 | } |
| 16237 | else |
| 16238 | { |
| 16239 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 16240 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16241 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 16242 | __func__, pCfg->reportMaxLinkSpeed); |
| 16243 | rssidx = 0; |
| 16244 | } |
| 16245 | |
| 16246 | maxRate = 0; |
| 16247 | |
| 16248 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 16249 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 16250 | OperationalRates, &ORLeng)) |
| 16251 | { |
| 16252 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 16253 | /*To keep GUI happy*/ |
| 16254 | return 0; |
| 16255 | } |
| 16256 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16257 | for (i = 0; i < ORLeng; i++) |
| 16258 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16259 | for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16260 | { |
| 16261 | /* Validate Rate Set */ |
| 16262 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 16263 | { |
| 16264 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 16265 | break; |
| 16266 | } |
| 16267 | } |
| 16268 | /* Update MAX rate */ |
| 16269 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 16270 | } |
| 16271 | |
| 16272 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 16273 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 16274 | ExtendedRates, &ERLeng)) |
| 16275 | { |
| 16276 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 16277 | /*To keep GUI happy*/ |
| 16278 | return 0; |
| 16279 | } |
| 16280 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16281 | for (i = 0; i < ERLeng; i++) |
| 16282 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16283 | for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16284 | { |
| 16285 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 16286 | { |
| 16287 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 16288 | break; |
| 16289 | } |
| 16290 | } |
| 16291 | /* Update MAX rate */ |
| 16292 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 16293 | } |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16294 | |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 16295 | /* Get MCS Rate Set -- |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 16296 | Only if we are always reporting max speed (or) |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 16297 | if we have good rssi */ |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16298 | if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16299 | { |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16300 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 16301 | mode = 2; |
| 16302 | else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40)) |
| 16303 | mode = 1; |
| 16304 | else |
| 16305 | mode = 0; |
| 16306 | |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 16307 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 16308 | MCSRates, &MCSLeng)) |
| 16309 | { |
| 16310 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 16311 | /*To keep GUI happy*/ |
| 16312 | return 0; |
| 16313 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16314 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16315 | #ifdef WLAN_FEATURE_11AC |
| 16316 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16317 | if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16318 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16319 | ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map); |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16320 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16321 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16322 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16323 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16324 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16325 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16326 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16327 | maxMCSIdx = 7; |
| 16328 | } |
| 16329 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 16330 | { |
| 16331 | maxMCSIdx = 8; |
| 16332 | } |
| 16333 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 16334 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16335 | //VHT20 is supporting 0~8 |
| 16336 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 16337 | maxMCSIdx = 8; |
| 16338 | else |
| 16339 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16340 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16341 | |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16342 | if (0 != rssidx)/*check for scaled */ |
| 16343 | { |
| 16344 | //get middle rate MCS index if rssi=1/2 |
| 16345 | for (i=0; i <= maxMCSIdx; i++) |
| 16346 | { |
| 16347 | if (sinfo->signal <= rssiMcsTbl[mode][i]) |
| 16348 | { |
| 16349 | maxMCSIdx = i; |
| 16350 | break; |
| 16351 | } |
| 16352 | } |
| 16353 | } |
| 16354 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16355 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 16356 | { |
| 16357 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 16358 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 16359 | } |
| 16360 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 16361 | { |
| 16362 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 16363 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 16364 | } |
| 16365 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 16366 | { |
| 16367 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 16368 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 16369 | } |
| 16370 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16371 | maxSpeedMCS = 1; |
| 16372 | if (currentRate > maxRate) |
| 16373 | { |
| 16374 | maxRate = currentRate; |
| 16375 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16376 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16377 | } |
| 16378 | else |
| 16379 | #endif /* WLAN_FEATURE_11AC */ |
| 16380 | { |
| 16381 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 16382 | { |
| 16383 | rateFlag |= 1; |
| 16384 | } |
| 16385 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 16386 | { |
| 16387 | rateFlag |= 2; |
| 16388 | } |
| 16389 | |
Girish Gowli | 01abcee | 2014-07-31 20:18:55 +0530 | [diff] [blame] | 16390 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16391 | if (rssidx == 1 || rssidx == 2) |
| 16392 | { |
| 16393 | //get middle rate MCS index if rssi=1/2 |
| 16394 | for (i=0; i <= 7; i++) |
| 16395 | { |
| 16396 | if (sinfo->signal <= rssiMcsTbl[mode][i]) |
| 16397 | { |
| 16398 | temp = i+1; |
| 16399 | break; |
| 16400 | } |
| 16401 | } |
| 16402 | } |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16403 | |
| 16404 | for (i = 0; i < MCSLeng; i++) |
| 16405 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16406 | for (j = 0; j < temp; j++) |
| 16407 | { |
| 16408 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 16409 | { |
| 16410 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
Hanumantha Reddy Pothula | fa62374 | 2015-06-16 14:08:24 +0530 | [diff] [blame] | 16411 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16412 | break; |
| 16413 | } |
| 16414 | } |
| 16415 | if ((j < temp) && (currentRate > maxRate)) |
| 16416 | { |
| 16417 | maxRate = currentRate; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16418 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16419 | } |
Hanumantha Reddy Pothula | fa62374 | 2015-06-16 14:08:24 +0530 | [diff] [blame] | 16420 | maxSpeedMCS = 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16421 | } |
| 16422 | } |
| 16423 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16424 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 16425 | { |
| 16426 | maxRate = myRate; |
| 16427 | maxSpeedMCS = 1; |
| 16428 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 16429 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16430 | // make sure we report a value at least as big as our current rate |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 16431 | if ((maxRate < myRate) || (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16432 | { |
| 16433 | maxRate = myRate; |
| 16434 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 16435 | { |
| 16436 | maxSpeedMCS = 0; |
| 16437 | } |
| 16438 | else |
| 16439 | { |
| 16440 | maxSpeedMCS = 1; |
| 16441 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 16442 | } |
| 16443 | } |
| 16444 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16445 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16446 | { |
| 16447 | sinfo->txrate.legacy = maxRate; |
| 16448 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 16449 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 16450 | #endif //LINKSPEED_DEBUG_ENABLED |
| 16451 | } |
| 16452 | else |
| 16453 | { |
| 16454 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16455 | #ifdef WLAN_FEATURE_11AC |
| 16456 | sinfo->txrate.nss = 1; |
| 16457 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 16458 | { |
| 16459 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16460 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16461 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16462 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16463 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16464 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 16465 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 16466 | } |
| 16467 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 16468 | { |
| 16469 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 16470 | } |
| 16471 | #endif /* WLAN_FEATURE_11AC */ |
| 16472 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 16473 | { |
| 16474 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 16475 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 16476 | { |
| 16477 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 16478 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16479 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16480 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 16481 | { |
| 16482 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 16483 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 16484 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16485 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 16486 | pr_info("Reporting MCS rate %d flags %x\n", |
| 16487 | sinfo->txrate.mcs, |
| 16488 | sinfo->txrate.flags ); |
| 16489 | #endif //LINKSPEED_DEBUG_ENABLED |
| 16490 | } |
| 16491 | } |
| 16492 | else |
| 16493 | { |
| 16494 | // report current rate instead of max rate |
| 16495 | |
| 16496 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 16497 | { |
| 16498 | //provide to the UI in units of 100kbps |
| 16499 | sinfo->txrate.legacy = myRate; |
| 16500 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 16501 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 16502 | #endif //LINKSPEED_DEBUG_ENABLED |
| 16503 | } |
| 16504 | else |
| 16505 | { |
| 16506 | //must be MCS |
| 16507 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16508 | #ifdef WLAN_FEATURE_11AC |
| 16509 | sinfo->txrate.nss = 1; |
| 16510 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 16511 | { |
| 16512 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 16513 | } |
| 16514 | else |
| 16515 | #endif /* WLAN_FEATURE_11AC */ |
| 16516 | { |
| 16517 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 16518 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16519 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 16520 | { |
| 16521 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 16522 | } |
| 16523 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 16524 | { |
| 16525 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 16526 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 16527 | #ifdef WLAN_FEATURE_11AC |
| 16528 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 16529 | { |
| 16530 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 16531 | } |
| 16532 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16533 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 16534 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 16535 | sinfo->txrate.mcs, |
| 16536 | sinfo->txrate.flags ); |
| 16537 | #endif //LINKSPEED_DEBUG_ENABLED |
| 16538 | } |
| 16539 | } |
| 16540 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 16541 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 16542 | sinfo->tx_packets = |
| 16543 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 16544 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 16545 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 16546 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 16547 | |
| 16548 | sinfo->tx_retries = |
| 16549 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 16550 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 16551 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 16552 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 16553 | |
| 16554 | sinfo->tx_failed = |
| 16555 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 16556 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 16557 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 16558 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 16559 | |
| 16560 | sinfo->filled |= |
| 16561 | STATION_INFO_TX_PACKETS | |
| 16562 | STATION_INFO_TX_RETRIES | |
| 16563 | STATION_INFO_TX_FAILED; |
| 16564 | |
Edhar, Mahesh Kumar | 3cc9f23 | 2015-12-29 14:41:01 +0530 | [diff] [blame] | 16565 | sinfo->rx_packets = pAdapter->hdd_stats.summary_stat.rx_frm_cnt; |
| 16566 | sinfo->filled |= STATION_INFO_RX_PACKETS; |
| 16567 | |
| 16568 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 16569 | hddLog(LOG1, FL("Reporting RSSI:%d legacy rate %d pkt cnt tx %d rx %d"), |
| 16570 | sinfo->signal, sinfo->txrate.legacy, sinfo->tx_packets, |
| 16571 | sinfo->rx_packets); |
| 16572 | else |
| 16573 | hddLog(LOG1, |
| 16574 | FL("Reporting RSSI:%d MCS rate %d flags 0x%x pkt cnt tx %d rx %d"), |
| 16575 | sinfo->signal, sinfo->txrate.mcs, sinfo->txrate.flags, |
| 16576 | sinfo->tx_packets, sinfo->rx_packets); |
| 16577 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 16578 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 16579 | TRACE_CODE_HDD_CFG80211_GET_STA, |
| 16580 | pAdapter->sessionId, maxRate)); |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 16581 | EXIT(); |
| 16582 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16583 | } |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16584 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
| 16585 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 16586 | const u8* mac, struct station_info *sinfo) |
| 16587 | #else |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16588 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 16589 | u8* mac, struct station_info *sinfo) |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16590 | #endif |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16591 | { |
| 16592 | int ret; |
| 16593 | |
| 16594 | vos_ssr_protect(__func__); |
| 16595 | ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo); |
| 16596 | vos_ssr_unprotect(__func__); |
| 16597 | |
| 16598 | return ret; |
| 16599 | } |
| 16600 | |
| 16601 | static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 16602 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16603 | { |
| 16604 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 16605 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16606 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16607 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16608 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16609 | ENTER(); |
| 16610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16611 | if (NULL == pAdapter) |
| 16612 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 16613 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16614 | return -ENODEV; |
| 16615 | } |
| 16616 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 16617 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 16618 | TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT, |
| 16619 | pAdapter->sessionId, timeout)); |
| 16620 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 16621 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16622 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16623 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16624 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16625 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16626 | } |
| 16627 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 16628 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 16629 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 16630 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 16631 | (eConnectionState_Associated == |
| 16632 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 16633 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 16634 | |
| 16635 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 16636 | "offload: in cfg80211_set_power_mgmt, calling arp offload"); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 16637 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 16638 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 16639 | { |
| 16640 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 16641 | "%s:Failed to enable ARPOFFLOAD Feature %d", |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 16642 | __func__, vos_status); |
| 16643 | } |
| 16644 | } |
| 16645 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16646 | /**The get power cmd from the supplicant gets updated by the nl only |
| 16647 | *on successful execution of the function call |
| 16648 | *we are oppositely mapped w.r.t mode in the driver |
| 16649 | **/ |
| 16650 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 16651 | |
| 16652 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 16653 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 16654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16655 | "%s: failed to enter bmps mode", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16656 | return -EINVAL; |
| 16657 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 16658 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16659 | return 0; |
| 16660 | } |
| 16661 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16662 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 16663 | struct net_device *dev, bool mode, int timeout) |
| 16664 | { |
| 16665 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16666 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16667 | vos_ssr_protect(__func__); |
| 16668 | ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout); |
| 16669 | vos_ssr_unprotect(__func__); |
| 16670 | |
| 16671 | return ret; |
| 16672 | } |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 16673 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16674 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16675 | static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 16676 | struct net_device *netdev, |
| 16677 | u8 key_index) |
| 16678 | { |
| 16679 | ENTER(); |
| 16680 | return 0; |
| 16681 | } |
| 16682 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16683 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16684 | struct net_device *netdev, |
| 16685 | u8 key_index) |
| 16686 | { |
| 16687 | int ret; |
| 16688 | vos_ssr_protect(__func__); |
| 16689 | ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index); |
| 16690 | vos_ssr_unprotect(__func__); |
| 16691 | return ret; |
| 16692 | } |
| 16693 | #endif //LINUX_VERSION_CODE |
| 16694 | |
| 16695 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 16696 | static int __wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 16697 | struct net_device *dev, |
| 16698 | struct ieee80211_txq_params *params) |
| 16699 | { |
| 16700 | ENTER(); |
| 16701 | return 0; |
| 16702 | } |
| 16703 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 16704 | static int __wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 16705 | struct ieee80211_txq_params *params) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16706 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16707 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16708 | return 0; |
| 16709 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16710 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16711 | |
| 16712 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 16713 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16714 | struct net_device *dev, |
| 16715 | struct ieee80211_txq_params *params) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16716 | { |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16717 | int ret; |
| 16718 | |
| 16719 | vos_ssr_protect(__func__); |
| 16720 | ret = __wlan_hdd_set_txq_params(wiphy, dev, params); |
| 16721 | vos_ssr_unprotect(__func__); |
| 16722 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16723 | } |
| 16724 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 16725 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 16726 | struct ieee80211_txq_params *params) |
| 16727 | { |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16728 | int ret; |
| 16729 | |
| 16730 | vos_ssr_protect(__func__); |
| 16731 | ret = __wlan_hdd_set_txq_params(wiphy, params); |
| 16732 | vos_ssr_unprotect(__func__); |
| 16733 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16734 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16735 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16736 | |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16737 | static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16738 | struct net_device *dev, |
| 16739 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16740 | { |
| 16741 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16742 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16743 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16744 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16745 | v_U8_t staId; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16746 | v_CONTEXT_t pVosContext = NULL; |
| 16747 | ptSapContext pSapCtx = NULL; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 16748 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16749 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 16750 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16751 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16752 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16753 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16754 | return -EINVAL; |
| 16755 | } |
| 16756 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 16757 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 16758 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
| 16759 | pAdapter->sessionId, pAdapter->device_mode)); |
| 16760 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16761 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 16762 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16763 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16764 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16765 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16766 | } |
| 16767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16768 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16769 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16770 | ) |
| 16771 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16772 | pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 16773 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 16774 | if(pSapCtx == NULL){ |
| 16775 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16776 | FL("psapCtx is NULL")); |
| 16777 | return -ENOENT; |
| 16778 | } |
Agrawal Ashish | 306b75f | 2017-01-11 19:16:25 +0530 | [diff] [blame] | 16779 | if (pHddCtx->cfg_ini->enable_sap_auth_offload) |
| 16780 | { |
| 16781 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 16782 | "Change reason code to eSIR_MAC_DISASSOC_LEAVING_BSS_REASON in sap auth offload"); |
| 16783 | pDelStaParams->reason_code = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON; |
| 16784 | } |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16785 | if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16786 | { |
| 16787 | v_U16_t i; |
| 16788 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 16789 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16790 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 16791 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16792 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16793 | vos_mem_copy(pDelStaParams->peerMacAddr, |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16794 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16795 | ETHER_ADDR_LEN); |
| 16796 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16797 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 16798 | "%s: Delete STA with MAC::" |
| 16799 | MAC_ADDRESS_STR, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16800 | __func__, |
| 16801 | MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr)); |
| 16802 | vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 16803 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16804 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16805 | } |
| 16806 | } |
| 16807 | } |
| 16808 | else |
| 16809 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16810 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16811 | vos_status = hdd_softap_GetStaId(pAdapter, |
| 16812 | (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16813 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 16814 | { |
| 16815 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 16816 | "%s: Skip this DEL STA as this is not used::" |
| 16817 | MAC_ADDRESS_STR, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16818 | __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16819 | return -ENOENT; |
| 16820 | } |
| 16821 | |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16822 | if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16823 | { |
| 16824 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 16825 | "%s: Skip this DEL STA as deauth is in progress::" |
| 16826 | MAC_ADDRESS_STR, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16827 | __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16828 | return -ENOENT; |
| 16829 | } |
| 16830 | |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16831 | pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16833 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 16834 | "%s: Delete STA with MAC::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 16835 | MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16836 | __func__, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16837 | MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16838 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16839 | vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16840 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 16841 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 16842 | pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16843 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 16844 | "%s: STA removal failed for ::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 16845 | MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16846 | __func__, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16847 | MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 16848 | return -ENOENT; |
| 16849 | } |
| 16850 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16851 | } |
| 16852 | } |
| 16853 | |
| 16854 | EXIT(); |
| 16855 | |
| 16856 | return 0; |
| 16857 | } |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16858 | |
| 16859 | #ifdef CFG80211_DEL_STA_V2 |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 16860 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16861 | struct net_device *dev, |
| 16862 | struct station_del_parameters *param) |
| 16863 | #else |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16864 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 16865 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16866 | struct net_device *dev, const u8 *mac) |
| 16867 | #else |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 16868 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16869 | struct net_device *dev, u8 *mac) |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16870 | #endif |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16871 | #endif |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16872 | { |
| 16873 | int ret; |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16874 | struct tagCsrDelStaParams delStaParams; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16875 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16876 | vos_ssr_protect(__func__); |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16877 | |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16878 | #ifdef CFG80211_DEL_STA_V2 |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16879 | if (NULL == param) { |
| 16880 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__); |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 16881 | vos_ssr_unprotect(__func__); |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16882 | return -EINVAL; |
| 16883 | } |
| 16884 | |
| 16885 | WLANSAP_PopulateDelStaParams(param->mac, param->reason_code, |
| 16886 | param->subtype, &delStaParams); |
| 16887 | |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16888 | #else |
Sushant Kaushik | 4cd28f6 | 2014-12-26 14:23:50 +0530 | [diff] [blame] | 16889 | WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16890 | (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams); |
Naresh Jayaram | 69e3f28 | 2014-10-14 12:29:12 +0530 | [diff] [blame] | 16891 | #endif |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 16892 | ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams); |
| 16893 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16894 | vos_ssr_unprotect(__func__); |
| 16895 | |
| 16896 | return ret; |
| 16897 | } |
| 16898 | |
| 16899 | static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16900 | struct net_device *dev, |
| 16901 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 16902 | const u8 *mac, |
| 16903 | #else |
| 16904 | u8 *mac, |
| 16905 | #endif |
| 16906 | struct station_parameters *params) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 16907 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 16908 | hdd_adapter_t *pAdapter; |
| 16909 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 16910 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 16911 | #ifdef FEATURE_WLAN_TDLS |
| 16912 | u32 mask, set; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 16913 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 16914 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 16915 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 16916 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 16917 | if (NULL == pAdapter) |
| 16918 | { |
| 16919 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16920 | "%s: Adapter is NULL",__func__); |
| 16921 | return -EINVAL; |
| 16922 | } |
| 16923 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 16924 | status = wlan_hdd_validate_context(pHddCtx); |
| 16925 | if (0 != status) |
| 16926 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 16927 | return status; |
| 16928 | } |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 16929 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 16930 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 16931 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
| 16932 | pAdapter->sessionId, params->listen_interval)); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 16933 | mask = params->sta_flags_mask; |
| 16934 | |
| 16935 | set = params->sta_flags_set; |
| 16936 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 16937 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 16938 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 16939 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 16940 | |
| 16941 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 16942 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 16943 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 16944 | } |
| 16945 | } |
| 16946 | #endif |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 16947 | EXIT(); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 16948 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 16949 | } |
| 16950 | |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16951 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
| 16952 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 16953 | struct net_device *dev, const u8 *mac, |
| 16954 | struct station_parameters *params) |
| 16955 | #else |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16956 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 16957 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame] | 16958 | #endif |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16959 | { |
| 16960 | int ret; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16961 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 16962 | vos_ssr_protect(__func__); |
| 16963 | ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params); |
| 16964 | vos_ssr_unprotect(__func__); |
| 16965 | |
| 16966 | return ret; |
| 16967 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16968 | #ifdef FEATURE_WLAN_LFR |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 16969 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 16970 | static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 16971 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16972 | { |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16973 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 16974 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16975 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16976 | int status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16977 | hdd_context_t *pHddCtx; |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 16978 | tPmkidCacheInfo pmk_id; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 16979 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 16980 | ENTER(); |
| 16981 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 16982 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16983 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16984 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 16985 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 16986 | return -EINVAL; |
| 16987 | } |
| 16988 | |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 16989 | if (!pmksa) { |
| 16990 | hddLog(LOGE, FL("pmksa is NULL")); |
| 16991 | return -EINVAL; |
| 16992 | } |
| 16993 | |
| 16994 | if (!pmksa->bssid || !pmksa->pmkid) { |
| 16995 | hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"), |
| 16996 | pmksa->bssid, pmksa->pmkid); |
| 16997 | return -EINVAL; |
| 16998 | } |
| 16999 | |
| 17000 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR, |
| 17001 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
| 17002 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 17003 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17004 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 17005 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17006 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 17007 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17008 | } |
| 17009 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 17010 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17011 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 17012 | |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17013 | vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN); |
| 17014 | vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17015 | |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17016 | /* Add to the PMKSA ID Cache in CSR */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 17017 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17018 | &pmk_id, 1, FALSE); |
| 17019 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 17020 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 17021 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
| 17022 | pAdapter->sessionId, result)); |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17023 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17024 | EXIT(); |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17025 | return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17026 | } |
| 17027 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 17028 | static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, |
| 17029 | struct cfg80211_pmksa *pmksa) |
| 17030 | { |
| 17031 | int ret; |
| 17032 | |
| 17033 | vos_ssr_protect(__func__); |
| 17034 | ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa); |
| 17035 | vos_ssr_unprotect(__func__); |
| 17036 | |
| 17037 | return ret; |
| 17038 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17039 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17040 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 17041 | static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17042 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17043 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17044 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 17045 | tHalHandle halHandle; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17046 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 17047 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17048 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17049 | ENTER(); |
| 17050 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17051 | /* Validate pAdapter */ |
| 17052 | if (NULL == pAdapter) |
| 17053 | { |
| 17054 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
| 17055 | return -EINVAL; |
| 17056 | } |
| 17057 | |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17058 | if (!pmksa) { |
| 17059 | hddLog(LOGE, FL("pmksa is NULL")); |
| 17060 | return -EINVAL; |
| 17061 | } |
| 17062 | |
| 17063 | if (!pmksa->bssid) { |
| 17064 | hddLog(LOGE, FL("pmksa->bssid is NULL")); |
| 17065 | return -EINVAL; |
| 17066 | } |
| 17067 | |
Kiet Lam | 98c46a1 | 2014-10-31 15:34:57 -0700 | [diff] [blame] | 17068 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR, |
| 17069 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
| 17070 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17071 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17072 | status = wlan_hdd_validate_context(pHddCtx); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17073 | if (0 != status) |
| 17074 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17075 | return status; |
| 17076 | } |
| 17077 | |
| 17078 | /*Retrieve halHandle*/ |
| 17079 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 17080 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 17081 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 17082 | TRACE_CODE_HDD_CFG80211_DEL_PMKSA, |
| 17083 | pAdapter->sessionId, 0)); |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17084 | /* Delete the PMKID CSR cache */ |
| 17085 | if (eHAL_STATUS_SUCCESS != |
| 17086 | sme_RoamDelPMKIDfromCache(halHandle, |
| 17087 | pAdapter->sessionId, pmksa->bssid, FALSE)) { |
| 17088 | hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR), |
| 17089 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 17090 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17091 | } |
| 17092 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17093 | EXIT(); |
| 17094 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17095 | } |
| 17096 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17097 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 17098 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, |
| 17099 | struct cfg80211_pmksa *pmksa) |
| 17100 | { |
| 17101 | int ret; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17102 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 17103 | vos_ssr_protect(__func__); |
| 17104 | ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa); |
| 17105 | vos_ssr_unprotect(__func__); |
| 17106 | |
| 17107 | return ret; |
| 17108 | |
| 17109 | } |
| 17110 | |
| 17111 | static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17112 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17113 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 17114 | tHalHandle halHandle; |
| 17115 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 17116 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17117 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17118 | ENTER(); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17119 | |
| 17120 | /* Validate pAdapter */ |
| 17121 | if (NULL == pAdapter) |
| 17122 | { |
| 17123 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17124 | "%s: Invalid Adapter" ,__func__); |
| 17125 | return -EINVAL; |
| 17126 | } |
| 17127 | |
| 17128 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17129 | status = wlan_hdd_validate_context(pHddCtx); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17130 | if (0 != status) |
| 17131 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17132 | return status; |
| 17133 | } |
| 17134 | |
| 17135 | /*Retrieve halHandle*/ |
| 17136 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 17137 | |
Kanchanapally, Vidyullatha | 2633ace | 2014-09-25 15:16:50 +0530 | [diff] [blame] | 17138 | /* Flush the PMKID cache in CSR */ |
| 17139 | if (eHAL_STATUS_SUCCESS != |
| 17140 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) { |
| 17141 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache")); |
| 17142 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 17143 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17144 | EXIT(); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 17145 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17146 | } |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 17147 | |
| 17148 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 17149 | { |
| 17150 | int ret; |
| 17151 | |
| 17152 | vos_ssr_protect(__func__); |
| 17153 | ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev); |
| 17154 | vos_ssr_unprotect(__func__); |
| 17155 | |
| 17156 | return ret; |
| 17157 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17158 | #endif |
| 17159 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17160 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 17161 | static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 17162 | struct net_device *dev, |
| 17163 | struct cfg80211_update_ft_ies_params *ftie) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17164 | { |
| 17165 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 17166 | hdd_station_ctx_t *pHddStaCtx; |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 17167 | hdd_context_t *pHddCtx; |
| 17168 | int ret = 0; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17169 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17170 | ENTER(); |
| 17171 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17172 | if (NULL == pAdapter) |
| 17173 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 17174 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17175 | return -ENODEV; |
| 17176 | } |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 17177 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17178 | ret = wlan_hdd_validate_context(pHddCtx); |
| 17179 | if (0 != ret) |
| 17180 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 17181 | return ret; |
| 17182 | } |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17183 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 17184 | if (NULL == pHddStaCtx) |
| 17185 | { |
| 17186 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__); |
| 17187 | return -EINVAL; |
| 17188 | } |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17189 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 17190 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 17191 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
| 17192 | pAdapter->sessionId, pHddStaCtx->conn_info.connState)); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17193 | // Added for debug on reception of Re-assoc Req. |
| 17194 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 17195 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 17196 | hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"), |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17197 | ftie->ie_len); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 17198 | hddLog(LOGE, FL("Should be Re-assoc Req IEs")); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17199 | } |
| 17200 | |
| 17201 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 17202 | hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17203 | ftie->ie_len); |
| 17204 | #endif |
| 17205 | |
| 17206 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 17207 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 17208 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17209 | ftie->ie_len); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17210 | |
| 17211 | EXIT(); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17212 | return 0; |
| 17213 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 17214 | |
| 17215 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 17216 | struct net_device *dev, |
| 17217 | struct cfg80211_update_ft_ies_params *ftie) |
| 17218 | { |
| 17219 | int ret; |
| 17220 | |
| 17221 | vos_ssr_protect(__func__); |
| 17222 | ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie); |
| 17223 | vos_ssr_unprotect(__func__); |
| 17224 | |
| 17225 | return ret; |
| 17226 | } |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 17227 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 17228 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17229 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 17230 | |
| 17231 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 17232 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 17233 | { |
| 17234 | int ret; |
| 17235 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 17236 | hdd_context_t *pHddCtx; |
| 17237 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17238 | ENTER(); |
| 17239 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17240 | if (NULL == pAdapter) |
| 17241 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 17242 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17243 | "%s: HDD adapter is Null", __func__); |
| 17244 | return ; |
| 17245 | } |
| 17246 | |
| 17247 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17248 | if (NULL == pHddCtx) |
| 17249 | { |
| 17250 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17251 | "%s: HDD context is Null!!!", __func__); |
| 17252 | return ; |
| 17253 | } |
| 17254 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17255 | spin_lock(&pHddCtx->schedScan_lock); |
| 17256 | if (TRUE == pHddCtx->isWiphySuspended) |
| 17257 | { |
| 17258 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 17259 | spin_unlock(&pHddCtx->schedScan_lock); |
| 17260 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17261 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 17262 | return ; |
| 17263 | } |
| 17264 | spin_unlock(&pHddCtx->schedScan_lock); |
| 17265 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17266 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 17267 | |
| 17268 | if (0 > ret) |
| 17269 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | fb49cdd | 2015-10-16 18:41:59 +0530 | [diff] [blame] | 17270 | else |
| 17271 | { |
| 17272 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 17273 | * immediatly after the driver gets connect request(i.e after pno) |
| 17274 | * from supplicant, this result in app's is suspending and not able |
| 17275 | * to process the connect request to AP */ |
| 17276 | hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN); |
| 17277 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17278 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17279 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17280 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17281 | } |
| 17282 | |
| 17283 | /* |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17284 | * FUNCTION: wlan_hdd_is_pno_allowed |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 17285 | * Disallow pno if any session is active |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17286 | */ |
| 17287 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter) |
| 17288 | { |
| 17289 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 17290 | hdd_adapter_t *pTempAdapter = NULL; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17291 | hdd_station_ctx_t *pStaCtx; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17292 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17293 | int status = 0; |
Agrawal Ashish | cff3169 | 2016-12-16 17:17:50 +0530 | [diff] [blame] | 17294 | |
| 17295 | if (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 17296 | { |
| 17297 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17298 | "%s: PNO is allowed only in STA interface", __func__); |
| 17299 | return eHAL_STATUS_FAILURE; |
| 17300 | } |
| 17301 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17302 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 17303 | |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 17304 | /* The current firmware design does not allow PNO during any |
Agrawal Ashish | cff3169 | 2016-12-16 17:17:50 +0530 | [diff] [blame] | 17305 | * active sessions. PNO is allowed only in case when sap session |
| 17306 | * is present and sapo auth offload feature enabled in firmare. |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 17307 | */ |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17308 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)) |
| 17309 | { |
| 17310 | pTempAdapter = pAdapterNode->pAdapter; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17311 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17312 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17313 | if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode) |
| 17314 | && (eConnectionState_NotConnected != pStaCtx->conn_info.connState)) |
| 17315 | || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode) |
| 17316 | || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode) |
Agrawal Ashish | cff3169 | 2016-12-16 17:17:50 +0530 | [diff] [blame] | 17317 | || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode && |
| 17318 | !pHddCtx->cfg_ini->enable_sap_auth_offload) |
Siddharth Bhal | 63a19a7 | 2014-11-07 14:31:56 +0530 | [diff] [blame] | 17319 | || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel) |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17320 | ) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17321 | { |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17322 | return eHAL_STATUS_FAILURE; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17323 | } |
| 17324 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 17325 | pAdapterNode = pNext; |
| 17326 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17327 | return eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17328 | } |
| 17329 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17330 | void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status) |
| 17331 | { |
| 17332 | hdd_adapter_t *pAdapter = callbackContext; |
| 17333 | hdd_context_t *pHddCtx; |
| 17334 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17335 | ENTER(); |
| 17336 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17337 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 17338 | { |
| 17339 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17340 | FL("Invalid adapter or adapter has invalid magic")); |
| 17341 | return; |
| 17342 | } |
| 17343 | |
| 17344 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 17345 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
| 17346 | { |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17347 | return; |
| 17348 | } |
| 17349 | |
c_hpothu | b53c45d | 2014-08-18 16:53:14 +0530 | [diff] [blame] | 17350 | if (VOS_STATUS_SUCCESS != status) |
| 17351 | { |
| 17352 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17353 | FL("PNO enable response status = %d"), status); |
c_hpothu | b53c45d | 2014-08-18 16:53:14 +0530 | [diff] [blame] | 17354 | pHddCtx->isPnoEnable = FALSE; |
| 17355 | } |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17356 | |
| 17357 | pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 17358 | complete(&pAdapter->pno_comp_var); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17359 | EXIT(); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17360 | } |
| 17361 | |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17362 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) || \ |
| 17363 | defined (CFG80211_MULTI_SCAN_PLAN_BACKPORT) |
| 17364 | /** |
| 17365 | * hdd_config_sched_scan_plan() - configures the sched scan plans |
| 17366 | * from the framework. |
| 17367 | * @pno_req: pointer to PNO scan request |
| 17368 | * @request: pointer to scan request from framework |
| 17369 | * |
| 17370 | * Return: None |
| 17371 | */ |
| 17372 | static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req, |
| 17373 | struct cfg80211_sched_scan_request *request, |
| 17374 | hdd_context_t *hdd_ctx) |
| 17375 | { |
| 17376 | v_U32_t i = 0; |
| 17377 | |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17378 | pno_req->scanTimers.ucScanTimersCount = request->n_scan_plans; |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17379 | for (i = 0; i < request->n_scan_plans; i++) |
| 17380 | { |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17381 | pno_req->scanTimers.aTimerValues[i].uTimerRepeat = |
| 17382 | request->scan_plans[i].iterations; |
| 17383 | pno_req->scanTimers.aTimerValues[i].uTimerValue = |
| 17384 | request->scan_plans[i].interval; |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17385 | } |
| 17386 | } |
| 17387 | #else |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17388 | static void hdd_config_sched_scan_plan(tpSirPNOScanReq pno_req, |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17389 | struct cfg80211_sched_scan_request *request, |
| 17390 | hdd_context_t *hdd_ctx) |
| 17391 | { |
| 17392 | v_U32_t i, temp_int; |
| 17393 | /* Driver gets only one time interval which is hardcoded in |
| 17394 | * supplicant for 10000ms. Taking power consumption into account 6 |
| 17395 | * timers will be used, Timervalue is increased exponentially |
| 17396 | * i.e 10,20,40, 80,160,320 secs. And number of scan cycle for each |
| 17397 | * timer is configurable through INI param gPNOScanTimerRepeatValue. |
| 17398 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 17399 | * will be repeated after each interval specified by supplicant |
| 17400 | * till PNO is disabled. |
| 17401 | */ |
| 17402 | if (0 == hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue) |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17403 | pno_req->scanTimers.ucScanTimersCount = |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17404 | HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 17405 | else |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17406 | pno_req->scanTimers.ucScanTimersCount = |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17407 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 17408 | |
| 17409 | temp_int = (request->interval)/1000; |
| 17410 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17411 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 17412 | temp_int, hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue); |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17413 | for ( i = 0; i < pno_req->scanTimers.ucScanTimersCount; i++) |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17414 | { |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17415 | pno_req->scanTimers.aTimerValues[i].uTimerRepeat = |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17416 | hdd_ctx->cfg_ini->configPNOScanTimerRepeatValue; |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17417 | pno_req->scanTimers.aTimerValues[i].uTimerValue = temp_int; |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17418 | temp_int *= 2; |
| 17419 | } |
| 17420 | //Repeat last timer until pno disabled. |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17421 | pno_req->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17422 | } |
| 17423 | #endif |
| 17424 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17425 | /* |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 17426 | * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start |
| 17427 | * Function to enable PNO |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17428 | */ |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 17429 | static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17430 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 17431 | { |
| 17432 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17433 | tSirPNOScanReq pnoRequest = {0}; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17434 | hdd_context_t *pHddCtx; |
| 17435 | tHalHandle hHal; |
Anurag Chouhan | 343af7e | 2016-12-16 13:11:19 +0530 | [diff] [blame] | 17436 | v_U32_t i, indx, num_ch, j; |
Sushant Kaushik | d62d978 | 2014-02-19 15:39:40 +0530 | [diff] [blame] | 17437 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 17438 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17439 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 17440 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17441 | int ret = 0; |
Sachin Ahuja | 697ba3f | 2014-11-12 18:57:11 +0530 | [diff] [blame] | 17442 | hdd_config_t *pConfig = NULL; |
| 17443 | v_U32_t num_ignore_dfs_ch = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17444 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17445 | ENTER(); |
| 17446 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17447 | if (NULL == pAdapter) |
| 17448 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 17449 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17450 | "%s: HDD adapter is Null", __func__); |
| 17451 | return -ENODEV; |
| 17452 | } |
| 17453 | |
| 17454 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17455 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17456 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17457 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17458 | { |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17459 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17460 | } |
| 17461 | |
Sachin Ahuja | 697ba3f | 2014-11-12 18:57:11 +0530 | [diff] [blame] | 17462 | pConfig = pHddCtx->cfg_ini; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17463 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 17464 | if (NULL == hHal) |
| 17465 | { |
| 17466 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17467 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17468 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17469 | } |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 17470 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 17471 | TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START, |
| 17472 | pAdapter->sessionId, pAdapter->device_mode)); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 17473 | ret = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 17474 | if (ret < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 17475 | { |
| 17476 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17477 | "%s: aborting the existing scan is unsuccessfull", __func__); |
| 17478 | return -EBUSY; |
| 17479 | } |
| 17480 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17481 | if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter)) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17482 | { |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 17483 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 17484 | FL("Cannot handle sched_scan")); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 17485 | return -EBUSY; |
| 17486 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17487 | |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 17488 | if (TRUE == pHddCtx->isPnoEnable) |
| 17489 | { |
| 17490 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 17491 | FL("already PNO is enabled")); |
| 17492 | return -EBUSY; |
| 17493 | } |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 17494 | |
| 17495 | if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx)) |
| 17496 | { |
| 17497 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17498 | "%s: abort ROC failed ", __func__); |
| 17499 | return -EBUSY; |
| 17500 | } |
| 17501 | |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 17502 | pHddCtx->isPnoEnable = TRUE; |
| 17503 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17504 | pnoRequest.enable = 1; /*Enable PNO */ |
| 17505 | pnoRequest.ucNetworksCount = request->n_match_sets; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17506 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17507 | if (( !pnoRequest.ucNetworksCount ) || |
| 17508 | ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17509 | { |
| 17510 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 17511 | "%s: Network input is not correct %d Max Network supported is %d", |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17512 | __func__, pnoRequest.ucNetworksCount, |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 17513 | SIR_PNO_MAX_SUPP_NETWORKS); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17514 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17515 | goto error; |
| 17516 | } |
| 17517 | |
| 17518 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 17519 | { |
| 17520 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17521 | "%s: Incorrect number of channels %d", |
| 17522 | __func__, request->n_channels); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17523 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17524 | goto error; |
| 17525 | } |
| 17526 | |
| 17527 | /* Framework provides one set of channels(all) |
| 17528 | * common for all saved profile */ |
| 17529 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 17530 | channels_allowed, &num_channels_allowed)) |
| 17531 | { |
| 17532 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17533 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17534 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17535 | goto error; |
| 17536 | } |
| 17537 | /* Checking each channel against allowed channel list */ |
| 17538 | num_ch = 0; |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17539 | if (request->n_channels) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17540 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17541 | char chList [(request->n_channels*5)+1]; |
| 17542 | int len; |
| 17543 | for (i = 0, len = 0; i < request->n_channels; i++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17544 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17545 | for (indx = 0; indx < num_channels_allowed; indx++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17546 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17547 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 17548 | { |
Sachin Ahuja | 697ba3f | 2014-11-12 18:57:11 +0530 | [diff] [blame] | 17549 | if ((!pConfig->enableDFSPnoChnlScan) && |
| 17550 | (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx]))) |
| 17551 | { |
| 17552 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17553 | "%s : Dropping DFS channel : %d", |
| 17554 | __func__,channels_allowed[indx]); |
| 17555 | num_ignore_dfs_ch++; |
| 17556 | break; |
| 17557 | } |
| 17558 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17559 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 17560 | len += snprintf(chList+len, 5, "%d ", |
| 17561 | request->channels[i]->hw_value); |
| 17562 | break ; |
| 17563 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17564 | } |
| 17565 | } |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17566 | hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17567 | |
Sachin Ahuja | 697ba3f | 2014-11-12 18:57:11 +0530 | [diff] [blame] | 17568 | /*If all channels are DFS and dropped, then ignore the PNO request*/ |
| 17569 | if (num_ignore_dfs_ch == request->n_channels) |
| 17570 | { |
| 17571 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17572 | "%s : All requested channels are DFS channels", __func__); |
| 17573 | ret = -EINVAL; |
| 17574 | goto error; |
| 17575 | } |
| 17576 | } |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17577 | |
| 17578 | pnoRequest.aNetworks = |
| 17579 | vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount); |
| 17580 | if (pnoRequest.aNetworks == NULL) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17581 | { |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17582 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 17583 | FL("failed to allocate memory aNetworks %u"), |
| 17584 | (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount); |
| 17585 | goto error; |
| 17586 | } |
| 17587 | vos_mem_zero(pnoRequest.aNetworks, |
| 17588 | sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount); |
| 17589 | |
| 17590 | /* Filling per profile params */ |
| 17591 | for (i = 0; i < pnoRequest.ucNetworksCount; i++) |
| 17592 | { |
| 17593 | pnoRequest.aNetworks[i].ssId.length = |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17594 | request->match_sets[i].ssid.ssid_len; |
| 17595 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17596 | if (( 0 == pnoRequest.aNetworks[i].ssId.length ) || |
| 17597 | ( pnoRequest.aNetworks[i].ssId.length > 32 ) ) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17598 | { |
| 17599 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17600 | "%s: SSID Len %d is not correct for network %d", |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17601 | __func__, pnoRequest.aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17602 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17603 | goto error; |
| 17604 | } |
| 17605 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17606 | memcpy(pnoRequest.aNetworks[i].ssId.ssId, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17607 | request->match_sets[i].ssid.ssid, |
| 17608 | request->match_sets[i].ssid.ssid_len); |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 17609 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17610 | "%s: SSID of network %d is %s ", __func__, |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17611 | i, pnoRequest.aNetworks[i].ssId.ssId); |
| 17612 | pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 17613 | pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 17614 | pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17615 | |
| 17616 | /*Copying list of valid channel into request */ |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17617 | memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch); |
| 17618 | pnoRequest.aNetworks[i].ucChannelCount = num_ch; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17619 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17620 | pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17621 | } |
| 17622 | |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 17623 | for (i = 0; i < request->n_ssids; i++) |
| 17624 | { |
| 17625 | j = 0; |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17626 | while (j < pnoRequest.ucNetworksCount) |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 17627 | { |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17628 | if ((pnoRequest.aNetworks[j].ssId.length == |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 17629 | request->ssids[i].ssid_len) && |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17630 | (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId, |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 17631 | request->ssids[i].ssid, |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17632 | pnoRequest.aNetworks[j].ssId.length))) |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 17633 | { |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17634 | pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN; |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 17635 | break; |
| 17636 | } |
| 17637 | j++; |
| 17638 | } |
| 17639 | } |
| 17640 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17641 | "Number of hidden networks being Configured = %d", |
| 17642 | request->n_ssids); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 17643 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 17644 | "request->ie_len = %zu", request->ie_len); |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17645 | |
| 17646 | pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE); |
| 17647 | if (pnoRequest.p24GProbeTemplate == NULL) |
| 17648 | { |
| 17649 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 17650 | FL("failed to allocate memory p24GProbeTemplate %u"), |
| 17651 | SIR_PNO_MAX_PB_REQ_SIZE); |
| 17652 | goto error; |
| 17653 | } |
| 17654 | |
| 17655 | pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE); |
| 17656 | if (pnoRequest.p5GProbeTemplate == NULL) |
| 17657 | { |
| 17658 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 17659 | FL("failed to allocate memory p5GProbeTemplate %u"), |
| 17660 | SIR_PNO_MAX_PB_REQ_SIZE); |
| 17661 | goto error; |
| 17662 | } |
| 17663 | |
| 17664 | vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE); |
| 17665 | vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE); |
| 17666 | |
Hanumantha Reddy Pothula | 06e87b2 | 2015-03-02 18:02:23 +0530 | [diff] [blame] | 17667 | if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) && |
| 17668 | (NULL != request->ie)) |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 17669 | { |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17670 | pnoRequest.us24GProbeTemplateLen = request->ie_len; |
| 17671 | memcpy(pnoRequest.p24GProbeTemplate, request->ie, |
| 17672 | pnoRequest.us24GProbeTemplateLen); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 17673 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17674 | pnoRequest.us5GProbeTemplateLen = request->ie_len; |
| 17675 | memcpy(pnoRequest.p5GProbeTemplate, request->ie, |
| 17676 | pnoRequest.us5GProbeTemplateLen); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 17677 | } |
| 17678 | |
Anurag Chouhan | f3e52b7 | 2016-12-21 11:33:37 +0530 | [diff] [blame] | 17679 | hdd_config_sched_scan_plan(&pnoRequest, request, pHddCtx); |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 17680 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17681 | pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17682 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17683 | INIT_COMPLETION(pAdapter->pno_comp_var); |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17684 | pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb; |
| 17685 | pnoRequest.callbackContext = pAdapter; |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17686 | pAdapter->pno_req_status = 0; |
| 17687 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17688 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17689 | "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d", |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17690 | pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO, |
| 17691 | pnoRequest.scanTimers.ucScanTimersCount); |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17692 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17693 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17694 | &pnoRequest, pAdapter->sessionId, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17695 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 17696 | if (eHAL_STATUS_SUCCESS != status) |
| 17697 | { |
| 17698 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 17699 | "%s: Failed to enable PNO", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17700 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17701 | goto error; |
| 17702 | } |
| 17703 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17704 | ret = wait_for_completion_timeout( |
| 17705 | &pAdapter->pno_comp_var, |
| 17706 | msecs_to_jiffies(WLAN_WAIT_TIME_PNO)); |
| 17707 | if (0 >= ret) |
| 17708 | { |
| 17709 | // Did not receive the response for PNO enable in time. |
| 17710 | // Assuming the PNO enable was success. |
| 17711 | // Returning error from here, because we timeout, results |
| 17712 | // in side effect of Wifi (Wifi Setting) not to work. |
| 17713 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17714 | FL("Timed out waiting for PNO to be Enabled")); |
| 17715 | ret = 0; |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17716 | } |
| 17717 | |
| 17718 | ret = pAdapter->pno_req_status; |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 17719 | return ret; |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17720 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17721 | error: |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17722 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 17723 | FL("PNO scanRequest offloaded ret = %d"), ret); |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 17724 | pHddCtx->isPnoEnable = FALSE; |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17725 | if (pnoRequest.aNetworks) |
| 17726 | vos_mem_free(pnoRequest.aNetworks); |
| 17727 | if (pnoRequest.p24GProbeTemplate) |
| 17728 | vos_mem_free(pnoRequest.p24GProbeTemplate); |
| 17729 | if (pnoRequest.p5GProbeTemplate) |
| 17730 | vos_mem_free(pnoRequest.p5GProbeTemplate); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 17731 | |
| 17732 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17733 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17734 | } |
| 17735 | |
| 17736 | /* |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 17737 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 17738 | * NL interface to enable PNO |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17739 | */ |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 17740 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 17741 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 17742 | { |
| 17743 | int ret; |
| 17744 | |
| 17745 | vos_ssr_protect(__func__); |
| 17746 | ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request); |
| 17747 | vos_ssr_unprotect(__func__); |
| 17748 | |
| 17749 | return ret; |
| 17750 | } |
| 17751 | |
| 17752 | /* |
| 17753 | * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop |
| 17754 | * Function to disable PNO |
| 17755 | */ |
| 17756 | static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17757 | struct net_device *dev) |
| 17758 | { |
| 17759 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 17760 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 17761 | hdd_context_t *pHddCtx; |
| 17762 | tHalHandle hHal; |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17763 | tSirPNOScanReq pnoRequest = {0}; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17764 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17765 | |
| 17766 | ENTER(); |
| 17767 | |
| 17768 | if (NULL == pAdapter) |
| 17769 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 17770 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17771 | "%s: HDD adapter is Null", __func__); |
| 17772 | return -ENODEV; |
| 17773 | } |
| 17774 | |
| 17775 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17776 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17777 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17778 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 17779 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17780 | "%s: HDD context is Null", __func__); |
| 17781 | return -ENODEV; |
| 17782 | } |
| 17783 | |
| 17784 | /* The return 0 is intentional when isLogpInProgress and |
| 17785 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 17786 | * failure in sched_scan_stop , especially for a case where the unload |
| 17787 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 17788 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 17789 | * success. If it returns a failure , then its next invocation due to the |
| 17790 | * clean up of the second interface will have the dev pointer corresponding |
| 17791 | * to the first one leading to a crash. |
| 17792 | */ |
| 17793 | if (pHddCtx->isLogpInProgress) |
| 17794 | { |
| 17795 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17796 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Mahesh A Saptasagar | 0c11d82 | 2015-10-08 19:54:08 +0530 | [diff] [blame] | 17797 | pHddCtx->isPnoEnable = FALSE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17798 | return ret; |
| 17799 | } |
| 17800 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 17801 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17802 | { |
| 17803 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17804 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 17805 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17806 | } |
| 17807 | |
| 17808 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 17809 | if (NULL == hHal) |
| 17810 | { |
| 17811 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17812 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17813 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17814 | } |
| 17815 | |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17816 | pnoRequest.enable = 0; /* Disable PNO */ |
| 17817 | pnoRequest.ucNetworksCount = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17818 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 17819 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 17820 | TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP, |
| 17821 | pAdapter->sessionId, pAdapter->device_mode)); |
Hanumantha Reddy Pothula | 0e408dc | 2015-11-23 12:04:53 +0530 | [diff] [blame] | 17822 | |
| 17823 | INIT_COMPLETION(pAdapter->pno_comp_var); |
| 17824 | pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb; |
| 17825 | pnoRequest.callbackContext = pAdapter; |
| 17826 | pAdapter->pno_req_status = 0; |
Hanumantha Reddy Pothula | d769f3e | 2015-02-19 17:00:02 +0530 | [diff] [blame] | 17827 | status = sme_SetPreferredNetworkList(hHal, &pnoRequest, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17828 | pAdapter->sessionId, |
| 17829 | NULL, pAdapter); |
| 17830 | if (eHAL_STATUS_SUCCESS != status) |
| 17831 | { |
| 17832 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17833 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17834 | ret = -EINVAL; |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17835 | goto error; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17836 | } |
Hanumantha Reddy Pothula | 0e408dc | 2015-11-23 12:04:53 +0530 | [diff] [blame] | 17837 | ret = wait_for_completion_timeout( |
| 17838 | &pAdapter->pno_comp_var, |
| 17839 | msecs_to_jiffies(WLAN_WAIT_TIME_PNO)); |
| 17840 | if (0 >= ret) |
| 17841 | { |
| 17842 | // Did not receive the response for PNO disable in time. |
| 17843 | // Assuming the PNO disable was success. |
| 17844 | // Returning error from here, because we timeout, results |
| 17845 | // in side effect of Wifi (Wifi Setting) not to work. |
Anurag Chouhan | 96b41cb | 2016-09-28 18:54:47 +0530 | [diff] [blame] | 17846 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hanumantha Reddy Pothula | 0e408dc | 2015-11-23 12:04:53 +0530 | [diff] [blame] | 17847 | FL("Timed out waiting for PNO to be disabled")); |
| 17848 | ret = 0; |
| 17849 | } |
| 17850 | |
| 17851 | ret = pAdapter->pno_req_status; |
| 17852 | pHddCtx->isPnoEnable = (ret == 0) ? FALSE : TRUE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17853 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17854 | error: |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 17855 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 17856 | FL("PNO scan disabled ret = %d"), ret); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17857 | |
| 17858 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 17859 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17860 | } |
| 17861 | |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 17862 | /* |
| 17863 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 17864 | * NL interface to disable PNO |
| 17865 | */ |
| 17866 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 17867 | struct net_device *dev) |
| 17868 | { |
| 17869 | int ret; |
| 17870 | |
| 17871 | vos_ssr_protect(__func__); |
| 17872 | ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev); |
| 17873 | vos_ssr_unprotect(__func__); |
| 17874 | |
| 17875 | return ret; |
| 17876 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 17877 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 17878 | |
| 17879 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17880 | #ifdef FEATURE_WLAN_TDLS |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 17881 | #if TDLS_MGMT_VERSION2 |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 17882 | static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 17883 | struct net_device *dev, |
| 17884 | u8 *peer, u8 action_code, |
| 17885 | u8 dialog_token, |
| 17886 | u16 status_code, u32 peer_capability, |
| 17887 | const u8 *buf, size_t len) |
| 17888 | #else /* TDLS_MGMT_VERSION2 */ |
| 17889 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 17890 | static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 17891 | struct net_device *dev, |
| 17892 | const u8 *peer, u8 action_code, |
| 17893 | u8 dialog_token, u16 status_code, |
| 17894 | u32 peer_capability, bool initiator, |
| 17895 | const u8 *buf, size_t len) |
| 17896 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 17897 | static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 17898 | struct net_device *dev, |
| 17899 | const u8 *peer, u8 action_code, |
| 17900 | u8 dialog_token, u16 status_code, |
| 17901 | u32 peer_capability, const u8 *buf, |
| 17902 | size_t len) |
| 17903 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) |
| 17904 | static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 17905 | struct net_device *dev, |
| 17906 | u8 *peer, u8 action_code, |
| 17907 | u8 dialog_token, |
| 17908 | u16 status_code, u32 peer_capability, |
| 17909 | const u8 *buf, size_t len) |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 17910 | #else |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 17911 | static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 17912 | struct net_device *dev, |
| 17913 | u8 *peer, u8 action_code, |
| 17914 | u8 dialog_token, |
| 17915 | u16 status_code, const u8 *buf, |
| 17916 | size_t len) |
| 17917 | #endif |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 17918 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17919 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 17920 | hdd_adapter_t *pAdapter; |
| 17921 | hdd_context_t *pHddCtx; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17922 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 17923 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 17924 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 17925 | long rc; |
Ganesh Kondabattini | 862aec9 | 2015-01-22 20:58:46 +0530 | [diff] [blame] | 17926 | int ret; |
Masti, Narayanraddi | 3b68193 | 2015-10-08 19:22:25 +0530 | [diff] [blame] | 17927 | hddTdlsPeer_t *pTdlsPeer; |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 17928 | #if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)) |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 17929 | u32 peer_capability = 0; |
| 17930 | #endif |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 17931 | tANI_U16 numCurrTdlsPeers; |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 17932 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Ganesh Kondabattini | 17e6066 | 2017-05-25 12:36:07 +0530 | [diff] [blame] | 17933 | tdlsCtx_t *pHddTdlsCtx; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 17934 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 17935 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 17936 | if (NULL == pAdapter) |
| 17937 | { |
| 17938 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17939 | "%s: Adapter is NULL",__func__); |
| 17940 | return -EINVAL; |
| 17941 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 17942 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 17943 | TRACE_CODE_HDD_CFG80211_TDLS_MGMT, |
| 17944 | pAdapter->sessionId, action_code)); |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 17945 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 17946 | pHddCtx = wiphy_priv(wiphy); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 17947 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17948 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 17949 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17950 | "Invalid arguments"); |
| 17951 | return -EINVAL; |
| 17952 | } |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 17953 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 17954 | if (pHddCtx->isLogpInProgress) |
| 17955 | { |
| 17956 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17957 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 17958 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 17959 | peer, |
| 17960 | eTDLS_LINK_IDLE, |
| 17961 | eTDLS_LINK_UNSPECIFIED); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 17962 | return -EBUSY; |
| 17963 | } |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 17964 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 17965 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 17966 | { |
| 17967 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17968 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 17969 | return -EAGAIN; |
| 17970 | } |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 17971 | |
Ganesh Kondabattini | 17e6066 | 2017-05-25 12:36:07 +0530 | [diff] [blame] | 17972 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 17973 | if (!pHddTdlsCtx) { |
| 17974 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17975 | "%s: pHddTdlsCtx not valid.", __func__); |
| 17976 | } |
| 17977 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 17978 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17979 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 17980 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 17981 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 17982 | MAC_ADDRESS_STR " action %d declined.", |
| 17983 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 17984 | return -ENOTSUPP; |
| 17985 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 17986 | |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 17987 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 17988 | |
| 17989 | if( NULL == pHddStaCtx ) |
| 17990 | { |
| 17991 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17992 | "%s: HDD station context NULL ",__func__); |
| 17993 | return -EINVAL; |
| 17994 | } |
| 17995 | |
| 17996 | /* STA should be connected and authenticated |
| 17997 | * before sending any TDLS frames |
| 17998 | */ |
| 17999 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 18000 | (FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 18001 | { |
| 18002 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18003 | "STA is not connected or unauthenticated. " |
| 18004 | "connState %u, uIsAuthenticated %u", |
| 18005 | pHddStaCtx->conn_info.connState, |
| 18006 | pHddStaCtx->conn_info.uIsAuthenticated); |
| 18007 | return -EAGAIN; |
| 18008 | } |
| 18009 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 18010 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 18011 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 18012 | { |
| 18013 | /* if tdls_mode is disabled to respond to peer's request */ |
| 18014 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 18015 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 18016 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 18017 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 18018 | " TDLS mode is disabled. action %d declined.", |
| 18019 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 18020 | |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 18021 | return -ENOTSUPP; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 18022 | } |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 18023 | |
| 18024 | if (vos_max_concurrent_connections_reached()) |
| 18025 | { |
| 18026 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 18027 | return -EINVAL; |
| 18028 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 18029 | } |
| 18030 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18031 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 18032 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 18033 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18034 | { |
| 18035 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18036 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 18037 | " TDLS setup is ongoing. action %d declined.", |
| 18038 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 18039 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18040 | } |
| 18041 | } |
| 18042 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18043 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 18044 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18045 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 18046 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 18047 | if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18048 | { |
| 18049 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 18050 | we return error code at 'add_station()'. Hence we have this |
| 18051 | check again in addtion to add_station(). |
| 18052 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18053 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18054 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18055 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18056 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 18057 | " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).", |
| 18058 | __func__, MAC_ADDR_ARRAY(peer), action_code, |
| 18059 | numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 18060 | return -EINVAL; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18061 | } |
| 18062 | else |
| 18063 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18064 | /* maximum reached. tweak to send error code to peer and return |
| 18065 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18066 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18067 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18068 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 18069 | " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).", |
| 18070 | __func__, MAC_ADDR_ARRAY(peer), status_code, |
| 18071 | numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 18072 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18073 | /* fall through to send setup resp with failure status |
| 18074 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18075 | } |
| 18076 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18077 | else |
| 18078 | { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18079 | mutex_lock(&pHddCtx->tdls_lock); |
| 18080 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 18081 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18082 | { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18083 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18084 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 18085 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 18086 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18087 | return -EPERM; |
| 18088 | } |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18089 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18090 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18091 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18092 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 18093 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | 9fb625e | 2014-03-17 16:07:40 +0530 | [diff] [blame] | 18094 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu", |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18095 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 18096 | action_code, dialog_token, status_code, len); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18097 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18098 | /*Except teardown responder will not be used so just make 0*/ |
| 18099 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 18100 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18101 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 18102 | |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18103 | mutex_lock(&pHddCtx->tdls_lock); |
| 18104 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 18105 | |
| 18106 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 18107 | responder = pTdlsPeer->is_responder; |
| 18108 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18109 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 18110 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Kumar Khandavalli | 9fb625e | 2014-03-17 16:07:40 +0530 | [diff] [blame] | 18111 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %zu", |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 18112 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 18113 | dialog_token, status_code, len); |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18114 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 18115 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18116 | } |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18117 | mutex_unlock(&pHddCtx->tdls_lock); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18118 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18119 | |
Masti, Narayanraddi | 3b68193 | 2015-10-08 19:22:25 +0530 | [diff] [blame] | 18120 | /* Discard TDLS setup if peer is removed by user app */ |
| 18121 | if ((pHddCtx->cfg_ini->fTDLSExternalControl) && |
| 18122 | ((SIR_MAC_TDLS_SETUP_REQ == action_code) || |
| 18123 | (SIR_MAC_TDLS_SETUP_CNF == action_code) || |
| 18124 | (SIR_MAC_TDLS_DIS_REQ == action_code))) { |
| 18125 | |
| 18126 | mutex_lock(&pHddCtx->tdls_lock); |
| 18127 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
| 18128 | if (pTdlsPeer && (FALSE == pTdlsPeer->isForcedPeer)) { |
| 18129 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18130 | hddLog(LOGE, FL("TDLS External Control enabled, but peer " |
| 18131 | MAC_ADDRESS_STR " is not forced, so reject the action code %d"), |
| 18132 | MAC_ADDR_ARRAY(peer), action_code); |
| 18133 | return -EINVAL; |
| 18134 | } |
| 18135 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18136 | } |
| 18137 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 18138 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 18139 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18140 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Deepthi Gowri | f78f1f7 | 2016-03-21 13:13:28 +0530 | [diff] [blame] | 18141 | (SIR_MAC_TDLS_SETUP_CNF== action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 18142 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 18143 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18144 | { |
Ganesh Kondabattini | 17e6066 | 2017-05-25 12:36:07 +0530 | [diff] [blame] | 18145 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 18146 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Ganesh Kondabattini | 17e6066 | 2017-05-25 12:36:07 +0530 | [diff] [blame] | 18147 | "%s: Sending frame action_code %u.Disable BMPS", __func__, |
| 18148 | action_code); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18149 | status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 18150 | if (status != VOS_STATUS_SUCCESS) { |
| 18151 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS")); |
Ganesh Kondabattini | 17e6066 | 2017-05-25 12:36:07 +0530 | [diff] [blame] | 18152 | } else { |
| 18153 | pHddTdlsCtx->is_tdls_disabled_bmps = true; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18154 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18155 | } |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18156 | if (SIR_MAC_TDLS_DIS_REQ != action_code) { |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18157 | if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18158 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities")); |
| 18159 | } |
| 18160 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18161 | } |
| 18162 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18163 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 18164 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 18165 | { |
| 18166 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 18167 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY", |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18168 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Ganesh Kondabattini | 862aec9 | 2015-01-22 20:58:46 +0530 | [diff] [blame] | 18169 | ret = -EBUSY; |
| 18170 | goto tx_failed; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18171 | } |
| 18172 | |
| 18173 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18174 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 18175 | |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 18176 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 18177 | pAdapter->sessionId, peer, action_code, dialog_token, |
| 18178 | status_code, peer_capability, (tANI_U8 *)buf, len, |
| 18179 | responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18180 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18181 | if (VOS_STATUS_SUCCESS != status) |
| 18182 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18183 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18184 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18185 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Ganesh Kondabattini | 862aec9 | 2015-01-22 20:58:46 +0530 | [diff] [blame] | 18186 | ret = -EINVAL; |
| 18187 | goto tx_failed; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18188 | } |
| 18189 | |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 18190 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18191 | "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__, |
| 18192 | WAIT_TIME_TDLS_MGMT); |
| 18193 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 18194 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 18195 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 18196 | |
| 18197 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18198 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 18199 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 18200 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %u", |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 18201 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18202 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 18203 | |
| 18204 | if (pHddCtx->isLogpInProgress) |
| 18205 | { |
| 18206 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18207 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 18208 | return -EAGAIN; |
| 18209 | } |
Abhishek Singh | 837adf2 | 2015-10-01 17:37:37 +0530 | [diff] [blame] | 18210 | if (rc <= 0) |
| 18211 | vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL, |
| 18212 | WLAN_LOG_INDICATOR_HOST_DRIVER, |
| 18213 | WLAN_LOG_REASON_HDD_TIME_OUT, |
| 18214 | TRUE, TRUE); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 18215 | |
Ganesh Kondabattini | 862aec9 | 2015-01-22 20:58:46 +0530 | [diff] [blame] | 18216 | ret = -EINVAL; |
| 18217 | goto tx_failed; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18218 | } |
Ganesh Kondabattini | 8d0d35b | 2015-08-20 15:39:09 +0530 | [diff] [blame] | 18219 | else |
| 18220 | { |
| 18221 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18222 | "%s: Mgmt Tx Completion status %ld TxCompletion %u", |
| 18223 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
| 18224 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18225 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 18226 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18227 | { |
Ganesh Kondabattini | 862aec9 | 2015-01-22 20:58:46 +0530 | [diff] [blame] | 18228 | ret = max_sta_failed; |
| 18229 | goto tx_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18230 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18231 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18232 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 18233 | { |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18234 | if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18235 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response")); |
| 18236 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18237 | } |
| 18238 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 18239 | { |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18240 | if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18241 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response")); |
| 18242 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 18243 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18244 | |
| 18245 | return 0; |
Ganesh Kondabattini | 862aec9 | 2015-01-22 20:58:46 +0530 | [diff] [blame] | 18246 | |
| 18247 | tx_failed: |
| 18248 | /* add_station will be called before sending TDLS_SETUP_REQ and |
| 18249 | * TDLS_SETUP_RSP and as part of add_station driver will enable |
| 18250 | * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of |
| 18251 | * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled |
| 18252 | * as part of processing NL80211_TDLS_DISABLE_LINK. So need to |
| 18253 | * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails. |
| 18254 | */ |
| 18255 | |
| 18256 | if ((SIR_MAC_TDLS_SETUP_REQ == action_code) || |
| 18257 | (SIR_MAC_TDLS_SETUP_RSP == action_code)) |
| 18258 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 18259 | return ret; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18260 | } |
| 18261 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18262 | #if TDLS_MGMT_VERSION2 |
| 18263 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 18264 | u8 *peer, u8 action_code, u8 dialog_token, |
| 18265 | u16 status_code, u32 peer_capability, |
| 18266 | const u8 *buf, size_t len) |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18267 | #else /* TDLS_MGMT_VERSION2 */ |
| 18268 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) |
| 18269 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 18270 | struct net_device *dev, |
| 18271 | const u8 *peer, u8 action_code, |
| 18272 | u8 dialog_token, u16 status_code, |
| 18273 | u32 peer_capability, bool initiator, |
| 18274 | const u8 *buf, size_t len) |
| 18275 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
| 18276 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 18277 | struct net_device *dev, |
| 18278 | const u8 *peer, u8 action_code, |
| 18279 | u8 dialog_token, u16 status_code, |
| 18280 | u32 peer_capability, const u8 *buf, |
| 18281 | size_t len) |
| 18282 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) |
| 18283 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, |
| 18284 | struct net_device *dev, |
| 18285 | u8 *peer, u8 action_code, |
| 18286 | u8 dialog_token, |
| 18287 | u16 status_code, u32 peer_capability, |
| 18288 | const u8 *buf, size_t len) |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18289 | #else |
| 18290 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 18291 | u8 *peer, u8 action_code, u8 dialog_token, |
| 18292 | u16 status_code, const u8 *buf, size_t len) |
| 18293 | #endif |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18294 | #endif |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18295 | { |
| 18296 | int ret; |
| 18297 | |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 18298 | vos_ssr_protect(__func__); |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18299 | #if TDLS_MGMT_VERSION2 |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 18300 | ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, |
| 18301 | dialog_token, status_code, |
| 18302 | peer_capability, buf, len); |
| 18303 | #else /* TDLS_MGMT_VERSION2 */ |
| 18304 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 18305 | ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, |
| 18306 | dialog_token, status_code, |
| 18307 | peer_capability, initiator, |
| 18308 | buf, len); |
| 18309 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 18310 | ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, |
| 18311 | dialog_token, status_code, |
| 18312 | peer_capability, buf, len); |
| 18313 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) |
| 18314 | ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, |
| 18315 | dialog_token, status_code, |
| 18316 | peer_capability, buf, len); |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18317 | #else |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 18318 | ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, |
| 18319 | dialog_token, status_code, buf, len); |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18320 | #endif |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 18321 | #endif |
| 18322 | vos_ssr_unprotect(__func__); |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18323 | |
Anand N Sunkad | 9f80b74 | 2015-07-30 20:05:51 +0530 | [diff] [blame] | 18324 | return ret; |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 18325 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18326 | |
| 18327 | int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter, |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18328 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 18329 | const u8 *peer, |
| 18330 | #else |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18331 | u8 *peer, |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18332 | #endif |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18333 | tdls_req_params_t *tdls_peer_params, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18334 | cfg80211_exttdls_callback callback) |
| 18335 | { |
| 18336 | |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18337 | hddTdlsPeer_t *pTdlsPeer = NULL; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18338 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Pradeep Reddy POTTETI | e30ed25 | 2015-02-18 14:27:55 +0530 | [diff] [blame] | 18339 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18340 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18341 | " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR, |
| 18342 | __func__, MAC_ADDR_ARRAY(peer)); |
| 18343 | |
| 18344 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 18345 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 18346 | |
| 18347 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18348 | " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ", |
| 18349 | __func__, pHddCtx->cfg_ini->fTDLSExternalControl, |
| 18350 | pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18351 | return -ENOTSUPP; |
| 18352 | } |
| 18353 | |
| 18354 | /* To cater the requirement of establishing the TDLS link |
| 18355 | * irrespective of the data traffic , get an entry of TDLS peer. |
| 18356 | */ |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 18357 | mutex_lock(&pHddCtx->tdls_lock); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18358 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer); |
| 18359 | if (pTdlsPeer == NULL) { |
| 18360 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18361 | "%s: peer " MAC_ADDRESS_STR " not existing", |
| 18362 | __func__, MAC_ADDR_ARRAY(peer)); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 18363 | mutex_unlock(&pHddCtx->tdls_lock); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18364 | return -EINVAL; |
| 18365 | } |
| 18366 | |
Pradeep Reddy POTTETI | 60ad240 | 2015-02-26 16:48:21 +0530 | [diff] [blame] | 18367 | /* check FW TDLS Off Channel capability */ |
| 18368 | if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) && |
Pradeep Reddy POTTETI | 0cb99bc | 2015-06-08 12:59:09 +0530 | [diff] [blame] | 18369 | (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) && |
Pradeep Reddy POTTETI | 60ad240 | 2015-02-26 16:48:21 +0530 | [diff] [blame] | 18370 | (NULL != tdls_peer_params)) |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18371 | { |
| 18372 | pTdlsPeer->peerParams.channel = tdls_peer_params->channel; |
| 18373 | pTdlsPeer->peerParams.global_operating_class = |
| 18374 | tdls_peer_params->global_operating_class; |
| 18375 | pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms; |
| 18376 | pTdlsPeer->peerParams.min_bandwidth_kbps = |
| 18377 | tdls_peer_params->min_bandwidth_kbps; |
Pradeep Reddy POTTETI | e30ed25 | 2015-02-18 14:27:55 +0530 | [diff] [blame] | 18378 | /* check configured channel is valid, non dfs and |
| 18379 | * not current operating channel */ |
| 18380 | if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 18381 | tdls_peer_params->channel)) && |
| 18382 | (pHddStaCtx) && |
| 18383 | (tdls_peer_params->channel != |
| 18384 | pHddStaCtx->conn_info.operationChannel)) |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18385 | { |
| 18386 | pTdlsPeer->isOffChannelConfigured = TRUE; |
| 18387 | } |
| 18388 | else |
| 18389 | { |
| 18390 | pTdlsPeer->isOffChannelConfigured = FALSE; |
| 18391 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18392 | "%s: Configured Tdls Off Channel is not valid", __func__); |
| 18393 | |
| 18394 | } |
| 18395 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | e30ed25 | 2015-02-18 14:27:55 +0530 | [diff] [blame] | 18396 | "%s: tdls_off_channel %d isOffChannelConfigured %d " |
| 18397 | "current operating channel %d", |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18398 | __func__, pTdlsPeer->peerParams.channel, |
Pradeep Reddy POTTETI | e30ed25 | 2015-02-18 14:27:55 +0530 | [diff] [blame] | 18399 | pTdlsPeer->isOffChannelConfigured, |
| 18400 | (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0)); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18401 | } |
| 18402 | else |
| 18403 | { |
| 18404 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pradeep Reddy POTTETI | 0cb99bc | 2015-06-08 12:59:09 +0530 | [diff] [blame] | 18405 | "%s: TDLS off channel FW capability %d, " |
| 18406 | "host capab %d or Invalid TDLS Peer Params", __func__, |
| 18407 | sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL), |
| 18408 | pHddCtx->cfg_ini->fEnableTDLSOffChannel); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18409 | } |
| 18410 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18411 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) { |
| 18412 | |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18413 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18414 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18415 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18416 | " %s TDLS Add Force Peer Failed", |
| 18417 | __func__); |
| 18418 | return -EINVAL; |
| 18419 | } |
| 18420 | /*EXT TDLS*/ |
| 18421 | |
| 18422 | if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18423 | mutex_unlock(&pHddCtx->tdls_lock); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18424 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18425 | " %s TDLS set callback Failed", |
| 18426 | __func__); |
| 18427 | return -EINVAL; |
| 18428 | } |
| 18429 | |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18430 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18431 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18432 | return(0); |
| 18433 | |
| 18434 | } |
| 18435 | |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18436 | int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, |
| 18437 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 18438 | const u8 *peer |
| 18439 | #else |
| 18440 | u8 *peer |
| 18441 | #endif |
| 18442 | ) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18443 | { |
| 18444 | |
| 18445 | hddTdlsPeer_t *pTdlsPeer; |
| 18446 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Abhishek Singh | ff7c2f9 | 2016-01-05 15:28:12 +0530 | [diff] [blame] | 18447 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18448 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18449 | " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR, |
| 18450 | __func__, MAC_ADDR_ARRAY(peer)); |
| 18451 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 18452 | if (0 != wlan_hdd_validate_context(pHddCtx)) { |
| 18453 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL")); |
| 18454 | return -EINVAL; |
| 18455 | } |
| 18456 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18457 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 18458 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 18459 | |
| 18460 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18461 | " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ", |
| 18462 | __func__, pHddCtx->cfg_ini->fTDLSExternalControl, |
| 18463 | pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18464 | return -ENOTSUPP; |
| 18465 | } |
| 18466 | |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18467 | mutex_lock(&pHddCtx->tdls_lock); |
| 18468 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18469 | |
| 18470 | if ( NULL == pTdlsPeer ) { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18471 | mutex_unlock(&pHddCtx->tdls_lock); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18472 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 18473 | " peer not existing", |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18474 | __func__, MAC_ADDR_ARRAY(peer)); |
| 18475 | return -EINVAL; |
| 18476 | } |
| 18477 | else { |
| 18478 | wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, |
| 18479 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
Abhishek Singh | ff7c2f9 | 2016-01-05 15:28:12 +0530 | [diff] [blame] | 18480 | hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_EXT_CTRL, |
| 18481 | pTdlsPeer->peerMac); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18482 | /* if channel switch is configured, reset |
| 18483 | the channel for this peer */ |
| 18484 | if (TRUE == pTdlsPeer->isOffChannelConfigured) |
| 18485 | { |
| 18486 | pTdlsPeer->peerParams.channel = 0; |
| 18487 | pTdlsPeer->isOffChannelConfigured = FALSE; |
| 18488 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18489 | } |
| 18490 | |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18491 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18492 | mutex_unlock(&pHddCtx->tdls_lock); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18493 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18494 | return -EINVAL; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18495 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18496 | |
| 18497 | /*EXT TDLS*/ |
| 18498 | |
| 18499 | if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) { |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18500 | mutex_unlock(&pHddCtx->tdls_lock); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18501 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18502 | " %s TDLS set callback Failed", |
| 18503 | __func__); |
| 18504 | return -EINVAL; |
| 18505 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18506 | |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18507 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18508 | |
| 18509 | return(0); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18510 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 18511 | static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 18512 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 18513 | const u8 *peer, |
| 18514 | #else |
| 18515 | u8 *peer, |
| 18516 | #endif |
| 18517 | enum nl80211_tdls_operation oper) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18518 | { |
| 18519 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 18520 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 18521 | int status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18522 | hddTdlsPeer_t *pTdlsPeer; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 18523 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 18524 | ENTER(); |
| 18525 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 18526 | if (!pAdapter) { |
| 18527 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 18528 | return -EINVAL; |
| 18529 | } |
| 18530 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 18531 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 18532 | TRACE_CODE_HDD_CFG80211_TDLS_OPER, |
| 18533 | pAdapter->sessionId, oper)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 18534 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18535 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 18536 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 18537 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18538 | return -EINVAL; |
| 18539 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 18540 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 18541 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 18542 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 18543 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 18544 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 18545 | } |
| 18546 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18547 | |
| 18548 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 18549 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18550 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 18551 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18552 | "TDLS Disabled in INI (%d) OR not enabled in FW (%d) " |
| 18553 | "Cannot process TDLS commands", |
| 18554 | pHddCtx->cfg_ini->fEnableTDLSSupport, |
| 18555 | sme_IsFeatureSupportedByFW(TDLS)); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18556 | return -ENOTSUPP; |
| 18557 | } |
| 18558 | |
| 18559 | switch (oper) { |
| 18560 | case NL80211_TDLS_ENABLE_LINK: |
| 18561 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18562 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 18563 | long ret; |
Hanumantha Reddy Pothula | da38949 | 2016-02-11 17:29:27 +0530 | [diff] [blame] | 18564 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams = { {0}, 0, |
| 18565 | 0, 0, 0, 0, 0, 0, {0}, 0, {0} }; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 18566 | WLAN_STADescType staDesc; |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18567 | tANI_U16 numCurrTdlsPeers = 0; |
| 18568 | hddTdlsPeer_t *connPeer = NULL; |
Pradeep Reddy POTTETI | fcac790 | 2015-04-16 12:25:17 +0530 | [diff] [blame] | 18569 | tANI_U8 suppChannelLen = 0; |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18570 | tSirMacAddr peerMac; |
| 18571 | int channel; |
| 18572 | tTDLSLinkStatus peer_status = eTDLS_LINK_IDLE; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18573 | |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 18574 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18575 | " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR, |
| 18576 | __func__, MAC_ADDR_ARRAY(peer)); |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18577 | |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18578 | mutex_lock(&pHddCtx->tdls_lock); |
| 18579 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 18580 | memset(&staDesc, 0, sizeof(staDesc)); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 18581 | if ( NULL == pTdlsPeer ) { |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18582 | mutex_unlock(&pHddCtx->tdls_lock); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 18583 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 18584 | " (oper %d) not exsting. ignored", |
| 18585 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 18586 | return -EINVAL; |
| 18587 | } |
| 18588 | |
| 18589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18590 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 18591 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 18592 | "NL80211_TDLS_ENABLE_LINK"); |
| 18593 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 18594 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 18595 | { |
| 18596 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 18597 | MAC_ADDRESS_STR " failed", |
| 18598 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18599 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 18600 | return -EINVAL; |
| 18601 | } |
| 18602 | |
Pradeep Reddy POTTETI | f3148e8 | 2015-04-16 12:10:33 +0530 | [diff] [blame] | 18603 | /* before starting tdls connection, set tdls |
| 18604 | * off channel established status to default value */ |
| 18605 | pTdlsPeer->isOffChannelEstablished = FALSE; |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18606 | |
| 18607 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18608 | |
Deepthi Gowri | 2d85bbf | 2016-07-25 15:43:31 +0530 | [diff] [blame] | 18609 | wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18610 | /* TDLS Off Channel, Disable tdls channel switch, |
| 18611 | when there are more than one tdls link */ |
| 18612 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
Pradeep Reddy POTTETI | a9991b6 | 2015-03-26 18:03:19 +0530 | [diff] [blame] | 18613 | if (numCurrTdlsPeers == 2) |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18614 | { |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18615 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18616 | /* get connected peer and send disable tdls off chan */ |
| 18617 | connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter); |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18618 | if ((connPeer) && |
| 18619 | (connPeer->isOffChannelSupported == TRUE) && |
| 18620 | (connPeer->isOffChannelConfigured == TRUE)) |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18621 | { |
| 18622 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18623 | "%s: More then one peer connected, Disable " |
| 18624 | "TDLS channel switch", __func__); |
| 18625 | |
Pradeep Reddy POTTETI | 16d8333 | 2015-03-26 18:28:13 +0530 | [diff] [blame] | 18626 | connPeer->isOffChannelEstablished = FALSE; |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18627 | vos_mem_copy(peerMac, connPeer->peerMac, sizeof (tSirMacAddr)); |
| 18628 | channel = connPeer->peerParams.channel; |
| 18629 | |
| 18630 | mutex_unlock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18631 | |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18632 | ret = sme_SendTdlsChanSwitchReq( |
| 18633 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18634 | pAdapter->sessionId, |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18635 | peerMac, |
| 18636 | channel, |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18637 | TDLS_OFF_CHANNEL_BW_OFFSET, |
| 18638 | TDLS_CHANNEL_SWITCH_DISABLE); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18639 | if (ret != VOS_STATUS_SUCCESS) { |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 18640 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 18641 | FL("Failed to send TDLS switch channel request")); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18642 | } |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18643 | } |
| 18644 | else |
| 18645 | { |
| 18646 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18647 | "%s: No TDLS Connected Peer or " |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18648 | "isOffChannelSupported %d " |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18649 | "isOffChannelConfigured %d", |
| 18650 | __func__, |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18651 | (connPeer ? (connPeer->isOffChannelSupported) |
| 18652 | : -1), |
| 18653 | (connPeer ? (connPeer->isOffChannelConfigured) |
| 18654 | : -1)); |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18655 | mutex_unlock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18656 | } |
| 18657 | } |
| 18658 | |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18659 | mutex_lock(&pHddCtx->tdls_lock); |
| 18660 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
| 18661 | if ( NULL == pTdlsPeer ) { |
| 18662 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18663 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18664 | "%s: " MAC_ADDRESS_STR |
| 18665 | " (oper %d) peer got freed in other context. ignored", |
| 18666 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 18667 | return -EINVAL; |
| 18668 | } |
| 18669 | peer_status = pTdlsPeer->link_status; |
| 18670 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18671 | |
| 18672 | if (eTDLS_LINK_CONNECTED != peer_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18673 | { |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 18674 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 18675 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 18676 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 18677 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18678 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params")); |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 18679 | return -EINVAL; |
| 18680 | } |
| 18681 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 18682 | |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18683 | ret = sme_SendTdlsLinkEstablishParams( |
| 18684 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 18685 | pAdapter->sessionId, peer, |
| 18686 | &tdlsLinkEstablishParams); |
| 18687 | if (ret != VOS_STATUS_SUCCESS) { |
| 18688 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params")); |
| 18689 | } |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 18690 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 18691 | * register with the TL on after the response for this operation |
| 18692 | * is received . |
| 18693 | */ |
| 18694 | ret = wait_for_completion_interruptible_timeout( |
| 18695 | &pAdapter->tdls_link_establish_req_comp, |
| 18696 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
Masti, Narayanraddi | e1892a5 | 2015-12-15 15:01:01 +0530 | [diff] [blame] | 18697 | |
| 18698 | mutex_lock(&pHddCtx->tdls_lock); |
| 18699 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
| 18700 | if ( NULL == pTdlsPeer ) { |
| 18701 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18702 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18703 | "%s %d: " MAC_ADDRESS_STR |
| 18704 | " (oper %d) peer got freed in other context. ignored", |
| 18705 | __func__, __LINE__, MAC_ADDR_ARRAY(peer), |
| 18706 | (int)oper); |
| 18707 | return -EINVAL; |
| 18708 | } |
| 18709 | peer_status = pTdlsPeer->link_status; |
| 18710 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18711 | |
| 18712 | if (ret <= 0 || (peer_status == eTDLS_LINK_TEARING)) |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 18713 | { |
| 18714 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 18715 | FL("Link Establish Request Failed Status %ld"), |
| 18716 | ret); |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 18717 | return -EINVAL; |
| 18718 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 18719 | } |
Masti, Narayanraddi | 6b93b47 | 2015-09-04 17:48:11 +0530 | [diff] [blame] | 18720 | |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18721 | mutex_lock(&pHddCtx->tdls_lock); |
| 18722 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
| 18723 | if ( NULL == pTdlsPeer ) { |
| 18724 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18725 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18726 | "%s: " MAC_ADDRESS_STR |
| 18727 | " (oper %d) peer got freed in other context. ignored", |
| 18728 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 18729 | return -EINVAL; |
| 18730 | } |
| 18731 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 18732 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, |
| 18733 | eTDLS_LINK_CONNECTED, |
| 18734 | eTDLS_LINK_SUCCESS); |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 18735 | staDesc.ucSTAId = pTdlsPeer->staId; |
| 18736 | staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos; |
Masti, Narayanraddi | 3d79902 | 2015-12-24 18:22:36 +0530 | [diff] [blame] | 18737 | |
| 18738 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18739 | "%s: tdlsLinkEstablishParams of peer " |
| 18740 | MAC_ADDRESS_STR "uapsdQueues: %d" |
| 18741 | "qos: %d maxSp: %d isBufSta: %d isOffChannelSupported: %d" |
| 18742 | "isResponder: %d peerstaId: %d", |
| 18743 | __func__, |
| 18744 | MAC_ADDR_ARRAY(tdlsLinkEstablishParams.peerMac), |
| 18745 | tdlsLinkEstablishParams.uapsdQueues, |
| 18746 | tdlsLinkEstablishParams.qos, |
| 18747 | tdlsLinkEstablishParams.maxSp, |
| 18748 | tdlsLinkEstablishParams.isBufSta, |
| 18749 | tdlsLinkEstablishParams.isOffChannelSupported, |
| 18750 | tdlsLinkEstablishParams.isResponder, |
| 18751 | pTdlsPeer->staId); |
| 18752 | |
| 18753 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18754 | "%s: StaDesc ucSTAId: %d ucQosEnabled: %d", |
| 18755 | __func__, |
| 18756 | staDesc.ucSTAId, |
| 18757 | staDesc.ucQosEnabled); |
| 18758 | |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18759 | ret = WLANTL_UpdateTdlsSTAClient( |
| 18760 | pHddCtx->pvosContext, |
| 18761 | &staDesc); |
| 18762 | if (ret != VOS_STATUS_SUCCESS) { |
| 18763 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params")); |
| 18764 | } |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 18765 | |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 18766 | /* Mark TDLS client Authenticated .*/ |
| 18767 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 18768 | pTdlsPeer->staId, |
| 18769 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 18770 | if (VOS_STATUS_SUCCESS == status) |
| 18771 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18772 | if (pTdlsPeer->is_responder == 0) |
| 18773 | { |
| 18774 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
Ganesh Kondabattini | cbfdc39 | 2015-09-11 19:12:59 +0530 | [diff] [blame] | 18775 | tdlsConnInfo_t *tdlsInfo; |
| 18776 | |
| 18777 | tdlsInfo = wlan_hdd_get_conn_info(pHddCtx, staId); |
| 18778 | |
Hanumantha Reddy Pothula | c823840 | 2016-03-24 18:02:23 +0530 | [diff] [blame] | 18779 | if (!vos_timer_is_initialized( |
| 18780 | &pTdlsPeer->initiatorWaitTimeoutTimer)) |
| 18781 | { |
| 18782 | /* Initialize initiator wait callback */ |
| 18783 | vos_timer_init( |
Ganesh Kondabattini | cbfdc39 | 2015-09-11 19:12:59 +0530 | [diff] [blame] | 18784 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 18785 | VOS_TIMER_TYPE_SW, |
| 18786 | wlan_hdd_tdls_initiator_wait_cb, |
| 18787 | tdlsInfo); |
Hanumantha Reddy Pothula | c823840 | 2016-03-24 18:02:23 +0530 | [diff] [blame] | 18788 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18789 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 18790 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 18791 | WAIT_TIME_TDLS_INITIATOR); |
| 18792 | /* suspend initiator TX until it receives direct packet from the |
| 18793 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18794 | ret = WLANTL_SuspendDataTx( |
| 18795 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 18796 | &staId, NULL); |
| 18797 | if (ret != VOS_STATUS_SUCCESS) { |
| 18798 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx")); |
| 18799 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 18800 | } |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18801 | |
Pradeep Reddy POTTETI | fcac790 | 2015-04-16 12:25:17 +0530 | [diff] [blame] | 18802 | if ((TRUE == pTdlsPeer->isOffChannelSupported) && |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18803 | (TRUE == pTdlsPeer->isOffChannelConfigured)) |
Pradeep Reddy POTTETI | fcac790 | 2015-04-16 12:25:17 +0530 | [diff] [blame] | 18804 | { |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18805 | suppChannelLen = |
| 18806 | tdlsLinkEstablishParams.supportedChannelsLen; |
| 18807 | |
| 18808 | if ((suppChannelLen > 0) && |
| 18809 | (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS)) |
| 18810 | { |
| 18811 | tANI_U8 suppPeerChannel = 0; |
| 18812 | int i = 0; |
| 18813 | for (i = 0U; i < suppChannelLen; i++) |
| 18814 | { |
| 18815 | suppPeerChannel = |
| 18816 | tdlsLinkEstablishParams.supportedChannels[i]; |
| 18817 | |
| 18818 | pTdlsPeer->isOffChannelSupported = FALSE; |
| 18819 | if (suppPeerChannel == |
| 18820 | pTdlsPeer->peerParams.channel) |
| 18821 | { |
| 18822 | pTdlsPeer->isOffChannelSupported = TRUE; |
| 18823 | break; |
| 18824 | } |
| 18825 | } |
| 18826 | } |
| 18827 | else |
| 18828 | { |
| 18829 | pTdlsPeer->isOffChannelSupported = FALSE; |
| 18830 | } |
Pradeep Reddy POTTETI | fcac790 | 2015-04-16 12:25:17 +0530 | [diff] [blame] | 18831 | } |
| 18832 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18833 | "%s: TDLS channel switch request for channel " |
| 18834 | "%d isOffChannelConfigured %d suppChannelLen " |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18835 | "%d isOffChannelSupported %d", __func__, |
| 18836 | pTdlsPeer->peerParams.channel, |
Pradeep Reddy POTTETI | fcac790 | 2015-04-16 12:25:17 +0530 | [diff] [blame] | 18837 | pTdlsPeer->isOffChannelConfigured, |
Pradeep Reddy POTTETI | fdaf38b | 2015-05-13 13:01:22 +0530 | [diff] [blame] | 18838 | suppChannelLen, |
| 18839 | pTdlsPeer->isOffChannelSupported); |
Pradeep Reddy POTTETI | fcac790 | 2015-04-16 12:25:17 +0530 | [diff] [blame] | 18840 | |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18841 | /* TDLS Off Channel, Enable tdls channel switch, |
| 18842 | when their is only one tdls link and it supports */ |
| 18843 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 18844 | if ((numCurrTdlsPeers == 1) && |
| 18845 | (TRUE == pTdlsPeer->isOffChannelSupported) && |
| 18846 | (TRUE == pTdlsPeer->isOffChannelConfigured)) |
| 18847 | { |
| 18848 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18849 | "%s: Send TDLS channel switch request for channel %d", |
| 18850 | __func__, pTdlsPeer->peerParams.channel); |
Pradeep Reddy POTTETI | 16d8333 | 2015-03-26 18:28:13 +0530 | [diff] [blame] | 18851 | |
| 18852 | pTdlsPeer->isOffChannelEstablished = TRUE; |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18853 | vos_mem_copy(peerMac, pTdlsPeer->peerMac, sizeof (tSirMacAddr)); |
| 18854 | channel = pTdlsPeer->peerParams.channel; |
| 18855 | |
| 18856 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18857 | |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18858 | ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 18859 | pAdapter->sessionId, |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18860 | peerMac, |
| 18861 | channel, |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18862 | TDLS_OFF_CHANNEL_BW_OFFSET, |
| 18863 | TDLS_CHANNEL_SWITCH_ENABLE); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18864 | if (ret != VOS_STATUS_SUCCESS) { |
| 18865 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req")); |
| 18866 | } |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18867 | } |
| 18868 | else |
| 18869 | { |
| 18870 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18871 | "%s: TDLS channel switch request not sent" |
| 18872 | " numCurrTdlsPeers %d " |
| 18873 | "isOffChannelSupported %d " |
| 18874 | "isOffChannelConfigured %d", |
| 18875 | __func__, numCurrTdlsPeers, |
| 18876 | pTdlsPeer->isOffChannelSupported, |
| 18877 | pTdlsPeer->isOffChannelConfigured); |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18878 | mutex_unlock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18879 | } |
| 18880 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 18881 | } |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18882 | else |
| 18883 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18884 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18885 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 18886 | |
| 18887 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 18888 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 18889 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 18890 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 18891 | int ac; |
| 18892 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 18893 | WLANTL_AC_VI, |
| 18894 | WLANTL_AC_BK, |
| 18895 | WLANTL_AC_BE }; |
| 18896 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 18897 | for(ac=0; ac < 4; ac++) |
| 18898 | { |
| 18899 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 18900 | pTdlsPeer->staId, ucAc[ac], |
| 18901 | tlTid[ac], tlTid[ac], 0, 0, |
| 18902 | WLANTL_BI_DIR ); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18903 | if (status != VOS_STATUS_SUCCESS) { |
| 18904 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC")); |
| 18905 | } |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 18906 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 18907 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 18908 | } |
Masti, Narayanraddi | 09c52d5 | 2015-12-19 14:19:18 +0530 | [diff] [blame] | 18909 | |
Bhargav Shah | 6689679 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 18910 | /* stop TCP delack timer if TDLS is enable */ |
| 18911 | set_bit(WLAN_TDLS_MODE, &pHddCtx->mode); |
| 18912 | hdd_manage_delack_timer(pHddCtx); |
Abhishek Singh | 67fa6bc | 2016-01-05 15:57:19 +0530 | [diff] [blame] | 18913 | hdd_wlan_tdls_enable_link_event(peer, |
| 18914 | pTdlsPeer->isOffChannelSupported, |
| 18915 | pTdlsPeer->isOffChannelConfigured, |
| 18916 | pTdlsPeer->isOffChannelEstablished); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 18917 | } |
| 18918 | break; |
| 18919 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18920 | { |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18921 | tANI_U16 numCurrTdlsPeers = 0; |
| 18922 | hddTdlsPeer_t *connPeer = NULL; |
| 18923 | |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 18924 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 18925 | " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR, |
| 18926 | __func__, MAC_ADDR_ARRAY(peer)); |
| 18927 | |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 18928 | mutex_lock(&pHddCtx->tdls_lock); |
| 18929 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 18930 | |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 18931 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 18932 | if ( NULL == pTdlsPeer ) { |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 18933 | mutex_unlock(&pHddCtx->tdls_lock); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 18934 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 18935 | " (oper %d) not exsting. ignored", |
| 18936 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 18937 | return -EINVAL; |
| 18938 | } |
| 18939 | |
| 18940 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18941 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 18942 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 18943 | "NL80211_TDLS_DISABLE_LINK"); |
| 18944 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 18945 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 18946 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 18947 | long status; |
| 18948 | |
Pradeep Reddy POTTETI | f3148e8 | 2015-04-16 12:10:33 +0530 | [diff] [blame] | 18949 | /* set tdls off channel status to false for this peer */ |
| 18950 | pTdlsPeer->isOffChannelEstablished = FALSE; |
Atul Mittal | 271a765 | 2014-09-12 13:18:22 +0530 | [diff] [blame] | 18951 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, |
| 18952 | eTDLS_LINK_TEARING, |
| 18953 | (pTdlsPeer->link_status == eTDLS_LINK_TEARING)? |
| 18954 | eTDLS_LINK_UNSPECIFIED: |
| 18955 | eTDLS_LINK_DROPPED_BY_REMOTE); |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 18956 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18957 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 18958 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 18959 | |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 18960 | status = sme_DeleteTdlsPeerSta( |
| 18961 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 18962 | pAdapter->sessionId, peer ); |
| 18963 | if (status != VOS_STATUS_SUCCESS) { |
| 18964 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA")); |
| 18965 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 18966 | |
| 18967 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 18968 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 18969 | |
| 18970 | mutex_lock(&pHddCtx->tdls_lock); |
| 18971 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, FALSE); |
| 18972 | if ( NULL == pTdlsPeer ) { |
| 18973 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18974 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 18975 | " peer was freed in other context", |
| 18976 | __func__, MAC_ADDR_ARRAY(peer)); |
| 18977 | return -EINVAL; |
| 18978 | } |
| 18979 | |
Atul Mittal | 271a765 | 2014-09-12 13:18:22 +0530 | [diff] [blame] | 18980 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, |
Atul Mittal | 454664b | 2014-10-10 11:03:46 +0530 | [diff] [blame] | 18981 | eTDLS_LINK_IDLE, |
| 18982 | eTDLS_LINK_UNSPECIFIED); |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 18983 | mutex_unlock(&pHddCtx->tdls_lock); |
| 18984 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 18985 | if (status <= 0) |
| 18986 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 18987 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18988 | "%s: Del station failed status %ld", |
| 18989 | __func__, status); |
| 18990 | return -EPERM; |
| 18991 | } |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 18992 | |
| 18993 | /* TDLS Off Channel, Enable tdls channel switch, |
| 18994 | when their is only one tdls link and it supports */ |
| 18995 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 18996 | if (numCurrTdlsPeers == 1) |
| 18997 | { |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 18998 | tSirMacAddr peerMac; |
| 18999 | int channel; |
Masti, Narayanraddi | 3818aea | 2015-10-17 15:20:28 +0530 | [diff] [blame] | 19000 | |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 19001 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 19002 | connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter); |
Masti, Narayanraddi | 3818aea | 2015-10-17 15:20:28 +0530 | [diff] [blame] | 19003 | |
| 19004 | if (connPeer == NULL) { |
| 19005 | mutex_unlock(&pHddCtx->tdls_lock); |
| 19006 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 19007 | "%s connPeer is NULL", __func__); |
| 19008 | return -EINVAL; |
| 19009 | } |
| 19010 | |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 19011 | vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr)); |
| 19012 | channel = connPeer->peerParams.channel; |
| 19013 | |
| 19014 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19015 | "%s: TDLS channel switch " |
| 19016 | "isOffChannelSupported %d " |
| 19017 | "isOffChannelConfigured %d " |
| 19018 | "isOffChannelEstablished %d", |
| 19019 | __func__, |
| 19020 | (connPeer ? connPeer->isOffChannelSupported : -1), |
| 19021 | (connPeer ? connPeer->isOffChannelConfigured : -1), |
| 19022 | (connPeer ? connPeer->isOffChannelEstablished : -1)); |
| 19023 | |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 19024 | if ((connPeer) && |
| 19025 | (connPeer->isOffChannelSupported == TRUE) && |
| 19026 | (connPeer->isOffChannelConfigured == TRUE)) |
| 19027 | { |
Pradeep Reddy POTTETI | 16d8333 | 2015-03-26 18:28:13 +0530 | [diff] [blame] | 19028 | connPeer->isOffChannelEstablished = TRUE; |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 19029 | mutex_unlock(&pHddCtx->tdls_lock); |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 19030 | status = sme_SendTdlsChanSwitchReq( |
| 19031 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 19032 | pAdapter->sessionId, |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 19033 | peerMac, |
| 19034 | channel, |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 19035 | TDLS_OFF_CHANNEL_BW_OFFSET, |
| 19036 | TDLS_CHANNEL_SWITCH_ENABLE); |
| 19037 | if (status != VOS_STATUS_SUCCESS) { |
| 19038 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req")); |
| 19039 | } |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 19040 | } |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 19041 | else |
| 19042 | mutex_unlock(&pHddCtx->tdls_lock); |
| 19043 | } |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 19044 | else |
| 19045 | { |
| 19046 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19047 | "%s: TDLS channel switch request not sent " |
| 19048 | "numCurrTdlsPeers %d ", |
| 19049 | __func__, numCurrTdlsPeers); |
| 19050 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 19051 | } |
| 19052 | else |
| 19053 | { |
Masti, Narayanraddi | 8208f06 | 2015-10-15 13:16:17 +0530 | [diff] [blame] | 19054 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 19055 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19056 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 19057 | } |
Bhargav Shah | 6689679 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 19058 | if (numCurrTdlsPeers == 0) { |
| 19059 | /* start TCP delack timer if TDLS is disable */ |
| 19060 | clear_bit(WLAN_TDLS_MODE, &pHddCtx->mode); |
| 19061 | hdd_manage_delack_timer(pHddCtx); |
| 19062 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 19063 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 19064 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19065 | case NL80211_TDLS_TEARDOWN: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19066 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19067 | status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19068 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19069 | if (0 != status) |
| 19070 | { |
| 19071 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 19072 | FL("Error in TDLS Teardown")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19073 | return status; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19074 | } |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19075 | break; |
| 19076 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19077 | case NL80211_TDLS_SETUP: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19078 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19079 | status = wlan_hdd_tdls_extctrl_config_peer(pAdapter, |
| 19080 | peer, |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 19081 | NULL, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19082 | NULL); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19083 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19084 | if (0 != status) |
| 19085 | { |
| 19086 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 19087 | FL("Error in TDLS Setup")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 19088 | return status; |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 19089 | } |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 19090 | break; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 19091 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19092 | case NL80211_TDLS_DISCOVERY_REQ: |
| 19093 | /* We don't support in-driver setup/teardown/discovery */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 19094 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 19095 | "%s: Driver doesn't support in-driver setup/teardown/discovery " |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 19096 | ,__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19097 | return -ENOTSUPP; |
| 19098 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 19099 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19100 | "%s: unsupported event",__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19101 | return -ENOTSUPP; |
| 19102 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19103 | |
| 19104 | EXIT(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19105 | return 0; |
| 19106 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 19107 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19108 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 19109 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 19110 | const u8 *peer, |
| 19111 | #else |
| 19112 | u8 *peer, |
| 19113 | #endif |
| 19114 | enum nl80211_tdls_operation oper) |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19115 | { |
| 19116 | int ret; |
| 19117 | |
| 19118 | vos_ssr_protect(__func__); |
| 19119 | ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper); |
| 19120 | vos_ssr_unprotect(__func__); |
| 19121 | |
| 19122 | return ret; |
| 19123 | } |
| 19124 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 19125 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 19126 | struct net_device *dev, u8 *peer) |
| 19127 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 19128 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 19129 | "tdls send discover req: "MAC_ADDRESS_STR, |
| 19130 | MAC_ADDR_ARRAY(peer)); |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 19131 | #if TDLS_MGMT_VERSION2 |
| 19132 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 19133 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0); |
| 19134 | #else |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 19135 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) |
| 19136 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 19137 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0); |
| 19138 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) |
| 19139 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 19140 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0); |
| 19141 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) |
| 19142 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 19143 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0); |
| 19144 | #else |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 19145 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 19146 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 19147 | #endif |
Anand N Sunkad | 9bfc262 | 2015-07-30 15:18:54 +0530 | [diff] [blame] | 19148 | #endif /* KERNEL_VERSION */ |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 19149 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 19150 | #endif |
| 19151 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19152 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 19153 | /* |
| 19154 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 19155 | * Callback rountine called upon receiving response for |
| 19156 | * get offload info |
| 19157 | */ |
| 19158 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 19159 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 19160 | { |
| 19161 | |
| 19162 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19163 | tANI_U8 tempReplayCounter[8]; |
| 19164 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19165 | |
| 19166 | ENTER(); |
| 19167 | |
| 19168 | if (NULL == pAdapter) |
| 19169 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 19170 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19171 | "%s: HDD adapter is Null", __func__); |
| 19172 | return ; |
| 19173 | } |
| 19174 | |
| 19175 | if (NULL == pGtkOffloadGetInfoRsp) |
| 19176 | { |
| 19177 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19178 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 19179 | return ; |
| 19180 | } |
| 19181 | |
| 19182 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 19183 | { |
| 19184 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19185 | "%s: wlan Failed to get replay counter value", |
| 19186 | __func__); |
| 19187 | return ; |
| 19188 | } |
| 19189 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19190 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 19191 | /* Update replay counter */ |
| 19192 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 19193 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 19194 | |
| 19195 | { |
| 19196 | /* changing from little to big endian since supplicant |
| 19197 | * works on big endian format |
| 19198 | */ |
| 19199 | int i; |
| 19200 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 19201 | |
| 19202 | for (i = 0; i < 8; i++) |
| 19203 | { |
| 19204 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 19205 | } |
| 19206 | } |
| 19207 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19208 | /* Update replay counter to NL */ |
| 19209 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19210 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19211 | } |
| 19212 | |
| 19213 | /* |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19214 | * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19215 | * This function is used to offload GTK rekeying job to the firmware. |
| 19216 | */ |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19217 | int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19218 | struct cfg80211_gtk_rekey_data *data) |
| 19219 | { |
| 19220 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19221 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 19222 | hdd_station_ctx_t *pHddStaCtx; |
| 19223 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 19224 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19225 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19226 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 19227 | |
| 19228 | ENTER(); |
| 19229 | |
| 19230 | if (NULL == pAdapter) |
| 19231 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 19232 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19233 | "%s: HDD adapter is Null", __func__); |
| 19234 | return -ENODEV; |
| 19235 | } |
| 19236 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 19237 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 19238 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
| 19239 | pAdapter->sessionId, pAdapter->device_mode)); |
| 19240 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 19241 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 19242 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19243 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 19244 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19245 | } |
| 19246 | |
| 19247 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 19248 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 19249 | if (NULL == hHal) |
| 19250 | { |
| 19251 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19252 | "%s: HAL context is Null!!!", __func__); |
| 19253 | return -EAGAIN; |
| 19254 | } |
| 19255 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19256 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 19257 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 19258 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 19259 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19260 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19261 | { |
| 19262 | /* changing from big to little endian since driver |
| 19263 | * works on little endian format |
| 19264 | */ |
| 19265 | tANI_U8 *p = |
| 19266 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 19267 | int i; |
| 19268 | |
| 19269 | for (i = 0; i < 8; i++) |
| 19270 | { |
| 19271 | p[7-i] = data->replay_ctr[i]; |
| 19272 | } |
| 19273 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19274 | |
| 19275 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 19276 | { |
| 19277 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19278 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 19279 | sizeof (tSirGtkOffloadParams)); |
| 19280 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19281 | pAdapter->sessionId); |
| 19282 | |
| 19283 | if (eHAL_STATUS_SUCCESS != status) |
| 19284 | { |
| 19285 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19286 | "%s: sme_SetGTKOffload failed, returned %d", |
| 19287 | __func__, status); |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 19288 | |
| 19289 | /* Need to clear any trace of key value in the memory. |
| 19290 | * Thus zero out the memory even though it is local |
| 19291 | * variable. |
| 19292 | */ |
| 19293 | vos_mem_zero(&hddGtkOffloadReqParams, |
| 19294 | sizeof(hddGtkOffloadReqParams)); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19295 | return status; |
| 19296 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19297 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19298 | "%s: sme_SetGTKOffload successfull", __func__); |
| 19299 | } |
| 19300 | else |
| 19301 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19302 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19303 | "%s: wlan not suspended GTKOffload request is stored", |
| 19304 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19305 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19306 | |
Vinay Krishna Eranna | 6f22c1f | 2014-10-13 16:03:06 +0530 | [diff] [blame] | 19307 | /* Need to clear any trace of key value in the memory. |
| 19308 | * Thus zero out the memory even though it is local |
| 19309 | * variable. |
| 19310 | */ |
| 19311 | vos_mem_zero(&hddGtkOffloadReqParams, |
| 19312 | sizeof(hddGtkOffloadReqParams)); |
| 19313 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19314 | EXIT(); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 19315 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19316 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 19317 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19318 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 19319 | struct cfg80211_gtk_rekey_data *data) |
| 19320 | { |
| 19321 | int ret; |
| 19322 | |
| 19323 | vos_ssr_protect(__func__); |
| 19324 | ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data); |
| 19325 | vos_ssr_unprotect(__func__); |
| 19326 | |
| 19327 | return ret; |
| 19328 | } |
| 19329 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19330 | /* |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 19331 | * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19332 | * This function is used to set access control policy |
| 19333 | */ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 19334 | static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 19335 | struct net_device *dev, |
| 19336 | const struct cfg80211_acl_data *params) |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19337 | { |
| 19338 | int i; |
| 19339 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19340 | hdd_hostapd_state_t *pHostapdState; |
| 19341 | tsap_Config_t *pConfig; |
| 19342 | v_CONTEXT_t pVosContext = NULL; |
| 19343 | hdd_context_t *pHddCtx; |
| 19344 | int status; |
| 19345 | |
| 19346 | ENTER(); |
| 19347 | |
| 19348 | if (NULL == pAdapter) |
| 19349 | { |
| 19350 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 19351 | "%s: HDD adapter is Null", __func__); |
| 19352 | return -ENODEV; |
| 19353 | } |
| 19354 | |
| 19355 | if (NULL == params) |
| 19356 | { |
| 19357 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 19358 | "%s: params is Null", __func__); |
| 19359 | return -EINVAL; |
| 19360 | } |
| 19361 | |
| 19362 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 19363 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19364 | if (0 != status) |
| 19365 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19366 | return status; |
| 19367 | } |
| 19368 | |
| 19369 | pVosContext = pHddCtx->pvosContext; |
| 19370 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 19371 | |
| 19372 | if (NULL == pHostapdState) |
| 19373 | { |
| 19374 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 19375 | "%s: pHostapdState is Null", __func__); |
| 19376 | return -EINVAL; |
| 19377 | } |
| 19378 | |
| 19379 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 19380 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 19381 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 19382 | TRACE_CODE_HDD_CFG80211_SET_MAC_ACL, |
| 19383 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19384 | |
| 19385 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 19386 | { |
| 19387 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 19388 | |
| 19389 | /* default value */ |
| 19390 | pConfig->num_accept_mac = 0; |
| 19391 | pConfig->num_deny_mac = 0; |
| 19392 | |
| 19393 | /** |
| 19394 | * access control policy |
| 19395 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 19396 | * listed in hostapd.deny file. |
| 19397 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 19398 | * listed in hostapd.accept file. |
| 19399 | */ |
| 19400 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 19401 | { |
| 19402 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 19403 | } |
| 19404 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 19405 | { |
| 19406 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 19407 | } |
| 19408 | else |
| 19409 | { |
| 19410 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19411 | "%s:Acl Policy : %d is not supported", |
| 19412 | __func__, params->acl_policy); |
| 19413 | return -ENOTSUPP; |
| 19414 | } |
| 19415 | |
| 19416 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 19417 | { |
| 19418 | pConfig->num_accept_mac = params->n_acl_entries; |
| 19419 | for (i = 0; i < params->n_acl_entries; i++) |
| 19420 | { |
| 19421 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19422 | "** Add ACL MAC entry %i in WhiletList :" |
| 19423 | MAC_ADDRESS_STR, i, |
| 19424 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 19425 | |
| 19426 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 19427 | sizeof(qcmacaddr)); |
| 19428 | } |
| 19429 | } |
| 19430 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 19431 | { |
| 19432 | pConfig->num_deny_mac = params->n_acl_entries; |
| 19433 | for (i = 0; i < params->n_acl_entries; i++) |
| 19434 | { |
| 19435 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19436 | "** Add ACL MAC entry %i in BlackList :" |
| 19437 | MAC_ADDRESS_STR, i, |
| 19438 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 19439 | |
| 19440 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 19441 | sizeof(qcmacaddr)); |
| 19442 | } |
| 19443 | } |
| 19444 | |
| 19445 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 19446 | { |
| 19447 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19448 | "%s: SAP Set Mac Acl fail", __func__); |
| 19449 | return -EINVAL; |
| 19450 | } |
| 19451 | } |
| 19452 | else |
| 19453 | { |
| 19454 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 19455 | "%s: Invalid device_mode = %s (%d)", |
| 19456 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 19457 | pAdapter->device_mode); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19458 | return -EINVAL; |
| 19459 | } |
| 19460 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19461 | EXIT(); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 19462 | return 0; |
| 19463 | } |
| 19464 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 19465 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 19466 | struct net_device *dev, |
| 19467 | const struct cfg80211_acl_data *params) |
| 19468 | { |
| 19469 | int ret; |
| 19470 | vos_ssr_protect(__func__); |
| 19471 | ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params); |
| 19472 | vos_ssr_unprotect(__func__); |
| 19473 | |
| 19474 | return ret; |
| 19475 | } |
| 19476 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19477 | #ifdef WLAN_NL80211_TESTMODE |
| 19478 | #ifdef FEATURE_WLAN_LPHB |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19479 | void wlan_hdd_cfg80211_lphb_ind_handler |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19480 | ( |
| 19481 | void *pAdapter, |
| 19482 | void *indCont |
| 19483 | ) |
| 19484 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19485 | tSirLPHBInd *lphbInd; |
| 19486 | struct sk_buff *skb; |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 19487 | hdd_context_t *pHddCtxt; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19488 | |
| 19489 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19490 | "LPHB indication arrived"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19491 | |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 19492 | if (pAdapter == NULL) |
| 19493 | { |
| 19494 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19495 | "%s: pAdapter is NULL\n",__func__); |
| 19496 | return; |
| 19497 | } |
| 19498 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19499 | if (NULL == indCont) |
| 19500 | { |
| 19501 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19502 | "LPHB IND, invalid argument"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19503 | return; |
| 19504 | } |
| 19505 | |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 19506 | pHddCtxt = (hdd_context_t *)pAdapter; |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19507 | lphbInd = (tSirLPHBInd *)indCont; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19508 | skb = cfg80211_testmode_alloc_event_skb( |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 19509 | pHddCtxt->wiphy, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19510 | sizeof(tSirLPHBInd), |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19511 | GFP_ATOMIC); |
| 19512 | if (!skb) |
| 19513 | { |
| 19514 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19515 | "LPHB timeout, NL buffer alloc fail"); |
| 19516 | return; |
| 19517 | } |
| 19518 | |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 19519 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19520 | { |
| 19521 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19522 | "WLAN_HDD_TM_ATTR_CMD put fail"); |
| 19523 | goto nla_put_failure; |
| 19524 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 19525 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19526 | { |
| 19527 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19528 | "WLAN_HDD_TM_ATTR_TYPE put fail"); |
| 19529 | goto nla_put_failure; |
| 19530 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 19531 | if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19532 | sizeof(tSirLPHBInd), lphbInd)) |
| 19533 | { |
| 19534 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19535 | "WLAN_HDD_TM_ATTR_DATA put fail"); |
| 19536 | goto nla_put_failure; |
| 19537 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19538 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 19539 | return; |
| 19540 | |
| 19541 | nla_put_failure: |
| 19542 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19543 | "NLA Put fail"); |
| 19544 | kfree_skb(skb); |
| 19545 | |
| 19546 | return; |
| 19547 | } |
| 19548 | #endif /* FEATURE_WLAN_LPHB */ |
| 19549 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19550 | static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19551 | { |
| 19552 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 19553 | int err = 0; |
| 19554 | #ifdef FEATURE_WLAN_LPHB |
| 19555 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19556 | eHalStatus smeStatus; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19557 | |
| 19558 | ENTER(); |
| 19559 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 19560 | err = wlan_hdd_validate_context(pHddCtx); |
| 19561 | if (0 != err) |
| 19562 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 19563 | return err; |
| 19564 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19565 | #endif /* FEATURE_WLAN_LPHB */ |
| 19566 | |
| 19567 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 19568 | if (err) |
| 19569 | { |
| 19570 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19571 | "%s Testmode INV ATTR", __func__); |
| 19572 | return err; |
| 19573 | } |
| 19574 | |
| 19575 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 19576 | { |
| 19577 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19578 | "%s Testmode INV CMD", __func__); |
| 19579 | return -EINVAL; |
| 19580 | } |
| 19581 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 19582 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 19583 | TRACE_CODE_HDD_CFG80211_TESTMODE, |
| 19584 | NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19585 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 19586 | { |
| 19587 | #ifdef FEATURE_WLAN_LPHB |
| 19588 | /* Low Power Heartbeat configuration request */ |
| 19589 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 19590 | { |
| 19591 | int buf_len; |
| 19592 | void *buf; |
| 19593 | tSirLPHBReq *hb_params = NULL; |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 19594 | tSirLPHBReq *hb_params_temp = NULL; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19595 | |
| 19596 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 19597 | { |
| 19598 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19599 | "%s Testmode INV DATA", __func__); |
| 19600 | return -EINVAL; |
| 19601 | } |
| 19602 | |
| 19603 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 19604 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 19605 | |
Manjeet Singh | 3c57744 | 2017-02-10 19:03:38 +0530 | [diff] [blame] | 19606 | if (buf_len > sizeof(*hb_params)) { |
| 19607 | hddLog(LOGE, FL("buf_len=%d exceeded hb_params size limit"), |
| 19608 | buf_len); |
| 19609 | return -ERANGE; |
| 19610 | } |
| 19611 | |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 19612 | hb_params_temp =(tSirLPHBReq *)buf; |
| 19613 | if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) && |
| 19614 | (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0)) |
| 19615 | return -EINVAL; |
| 19616 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19617 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 19618 | if (NULL == hb_params) |
| 19619 | { |
| 19620 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19621 | "%s Request Buffer Alloc Fail", __func__); |
| 19622 | return -EINVAL; |
| 19623 | } |
| 19624 | |
| 19625 | vos_mem_copy(hb_params, buf, buf_len); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19626 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 19627 | hb_params, |
| 19628 | wlan_hdd_cfg80211_lphb_ind_handler); |
| 19629 | if (eHAL_STATUS_SUCCESS != smeStatus) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19630 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 19631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19632 | "LPHB Config Fail, disable"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19633 | vos_mem_free(hb_params); |
| 19634 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19635 | return 0; |
| 19636 | } |
| 19637 | #endif /* FEATURE_WLAN_LPHB */ |
| 19638 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 19639 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 19640 | "%s: unsupported event",__func__); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19641 | return -EOPNOTSUPP; |
| 19642 | } |
| 19643 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19644 | EXIT(); |
| 19645 | return err; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19646 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19647 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 19648 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 19649 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) |
| 19650 | struct wireless_dev *wdev, |
| 19651 | #endif |
| 19652 | void *data, int len) |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19653 | { |
| 19654 | int ret; |
| 19655 | |
| 19656 | vos_ssr_protect(__func__); |
| 19657 | ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len); |
| 19658 | vos_ssr_unprotect(__func__); |
| 19659 | |
| 19660 | return ret; |
| 19661 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 19662 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 19663 | |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 19664 | extern void hdd_set_wlan_suspend_mode(bool suspend); |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19665 | static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19666 | struct net_device *dev, |
| 19667 | int idx, struct survey_info *survey) |
| 19668 | { |
| 19669 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19670 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 19671 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19672 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 19673 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19674 | v_S7_t snr,rssi; |
| 19675 | int status, i, j, filled = 0; |
| 19676 | |
| 19677 | ENTER(); |
| 19678 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19679 | if (NULL == pAdapter) |
| 19680 | { |
| 19681 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 19682 | "%s: HDD adapter is Null", __func__); |
| 19683 | return -ENODEV; |
| 19684 | } |
| 19685 | |
| 19686 | if (NULL == wiphy) |
| 19687 | { |
| 19688 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 19689 | "%s: wiphy is Null", __func__); |
| 19690 | return -ENODEV; |
| 19691 | } |
| 19692 | |
| 19693 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 19694 | status = wlan_hdd_validate_context(pHddCtx); |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19695 | if (0 != status) |
| 19696 | { |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19697 | return status; |
| 19698 | } |
| 19699 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 19700 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 19701 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19702 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 19703 | 0 != pAdapter->survey_idx || |
| 19704 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19705 | { |
| 19706 | /* The survey dump ops when implemented completely is expected to |
| 19707 | * return a survey of all channels and the ops is called by the |
| 19708 | * kernel with incremental values of the argument 'idx' till it |
| 19709 | * returns -ENONET. But we can only support the survey for the |
| 19710 | * operating channel for now. survey_idx is used to track |
| 19711 | * that the ops is called only once and then return -ENONET for |
| 19712 | * the next iteration |
| 19713 | */ |
| 19714 | pAdapter->survey_idx = 0; |
| 19715 | return -ENONET; |
| 19716 | } |
| 19717 | |
Mukul Sharma | 9d5233b | 2015-06-11 20:28:20 +0530 | [diff] [blame] | 19718 | if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) |
| 19719 | { |
| 19720 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19721 | "%s: Roaming in progress, hence return ", __func__); |
| 19722 | return -ENONET; |
| 19723 | } |
| 19724 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19725 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 19726 | |
| 19727 | wlan_hdd_get_snr(pAdapter, &snr); |
| 19728 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 19729 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 19730 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 19731 | TRACE_CODE_HDD_CFG80211_DUMP_SURVEY, |
| 19732 | pAdapter->sessionId, pAdapter->device_mode)); |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19733 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 19734 | hdd_wlan_get_freq(channel, &freq); |
| 19735 | |
| 19736 | |
| 19737 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 19738 | { |
| 19739 | if (NULL == wiphy->bands[i]) |
| 19740 | { |
| 19741 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 19742 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 19743 | continue; |
| 19744 | } |
| 19745 | |
| 19746 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 19747 | { |
| 19748 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 19749 | |
| 19750 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 19751 | { |
| 19752 | survey->channel = &band->channels[j]; |
| 19753 | /* The Rx BDs contain SNR values in dB for the received frames |
| 19754 | * while the supplicant expects noise. So we calculate and |
| 19755 | * return the value of noise (dBm) |
| 19756 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 19757 | */ |
| 19758 | survey->noise = rssi - snr; |
| 19759 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 19760 | filled = 1; |
| 19761 | } |
| 19762 | } |
| 19763 | } |
| 19764 | |
| 19765 | if (filled) |
| 19766 | pAdapter->survey_idx = 1; |
| 19767 | else |
| 19768 | { |
| 19769 | pAdapter->survey_idx = 0; |
| 19770 | return -ENONET; |
| 19771 | } |
| 19772 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19773 | EXIT(); |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 19774 | return 0; |
| 19775 | } |
| 19776 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 19777 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 19778 | struct net_device *dev, |
| 19779 | int idx, struct survey_info *survey) |
| 19780 | { |
| 19781 | int ret; |
| 19782 | |
| 19783 | vos_ssr_protect(__func__); |
| 19784 | ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey); |
| 19785 | vos_ssr_unprotect(__func__); |
| 19786 | |
| 19787 | return ret; |
| 19788 | } |
| 19789 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19790 | /* |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 19791 | * FUNCTION: __wlan_hdd_cfg80211_resume_wlan |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19792 | * this is called when cfg80211 driver resume |
| 19793 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 19794 | */ |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 19795 | int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19796 | { |
| 19797 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 19798 | hdd_adapter_t *pAdapter; |
| 19799 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 19800 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 19801 | |
| 19802 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19803 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 19804 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19805 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19806 | return 0; |
| 19807 | } |
| 19808 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 19809 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN, |
| 19810 | NO_SESSION, pHddCtx->isWiphySuspended)); |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 19811 | |
Nishank Aggarwal | c11826c | 2016-12-15 18:54:10 +0530 | [diff] [blame] | 19812 | if (pHddCtx->is_ap_mode_wow_supported) |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 19813 | { |
| 19814 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19815 | "%s: Resume SoftAP", __func__); |
| 19816 | hdd_set_wlan_suspend_mode(false); |
| 19817 | } |
| 19818 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19819 | spin_lock(&pHddCtx->schedScan_lock); |
| 19820 | pHddCtx->isWiphySuspended = FALSE; |
| 19821 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 19822 | { |
| 19823 | spin_unlock(&pHddCtx->schedScan_lock); |
| 19824 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19825 | "%s: Return resume is not due to PNO indication", __func__); |
| 19826 | return 0; |
| 19827 | } |
| 19828 | // Reset flag to avoid updatating cfg80211 data old results again |
| 19829 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 19830 | spin_unlock(&pHddCtx->schedScan_lock); |
| 19831 | |
| 19832 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 19833 | |
| 19834 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 19835 | { |
| 19836 | pAdapter = pAdapterNode->pAdapter; |
| 19837 | if ( (NULL != pAdapter) && |
| 19838 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 19839 | { |
| 19840 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 19841 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19842 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 19843 | "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 19844 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19845 | else |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 19846 | { |
| 19847 | /* Acquire wakelock to handle the case where APP's tries to |
| 19848 | * suspend immediately after updating the scan results. Whis |
| 19849 | * results in app's is in suspended state and not able to |
| 19850 | * process the connect request to AP |
| 19851 | */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 19852 | hdd_prevent_suspend_timeout(2000, |
| 19853 | WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19854 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 19855 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19856 | |
| 19857 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19858 | "%s : cfg80211 scan result database updated", __func__); |
| 19859 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19860 | EXIT(); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19861 | return 0; |
| 19862 | |
| 19863 | } |
| 19864 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 19865 | pAdapterNode = pNext; |
| 19866 | } |
| 19867 | |
| 19868 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19869 | "%s: Failed to find Adapter", __func__); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19870 | EXIT(); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19871 | return 0; |
| 19872 | } |
| 19873 | |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 19874 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 19875 | { |
| 19876 | int ret; |
| 19877 | |
| 19878 | vos_ssr_protect(__func__); |
| 19879 | ret = __wlan_hdd_cfg80211_resume_wlan(wiphy); |
| 19880 | vos_ssr_unprotect(__func__); |
| 19881 | |
| 19882 | return ret; |
| 19883 | } |
| 19884 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19885 | /* |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 19886 | * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19887 | * this is called when cfg80211 driver suspends |
| 19888 | */ |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 19889 | int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19890 | struct cfg80211_wowlan *wow) |
| 19891 | { |
| 19892 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 19893 | int ret = 0; |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19894 | |
| 19895 | ENTER(); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 19896 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 19897 | ret = wlan_hdd_validate_context(pHddCtx); |
| 19898 | if (0 != ret) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19899 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 19900 | return ret; |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19901 | } |
| 19902 | |
Nishank Aggarwal | c11826c | 2016-12-15 18:54:10 +0530 | [diff] [blame] | 19903 | if (pHddCtx->is_ap_mode_wow_supported) { |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 19904 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 19905 | "%s: Suspend SoftAP", __func__); |
| 19906 | hdd_set_wlan_suspend_mode(true); |
| 19907 | } |
| 19908 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 19909 | |
Konamki, Sreelakshmi | 7b464be | 2015-07-14 12:17:01 +0530 | [diff] [blame] | 19910 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 19911 | TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN, |
| 19912 | NO_SESSION, pHddCtx->isWiphySuspended)); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 19913 | pHddCtx->isWiphySuspended = TRUE; |
| 19914 | |
| 19915 | EXIT(); |
| 19916 | |
| 19917 | return 0; |
| 19918 | } |
| 19919 | |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 19920 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 19921 | struct cfg80211_wowlan *wow) |
| 19922 | { |
| 19923 | int ret; |
| 19924 | |
| 19925 | vos_ssr_protect(__func__); |
| 19926 | ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow); |
| 19927 | vos_ssr_unprotect(__func__); |
| 19928 | |
| 19929 | return ret; |
| 19930 | } |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 19931 | |
| 19932 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 19933 | static void wlan_hdd_cfg80211_oem_data_rsp_ind_new(void *ctx, |
Padma, Santhosh Kumar | f75c37b | 2016-01-25 10:36:08 +0530 | [diff] [blame] | 19934 | void *pMsg, tANI_U32 evLen) |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 19935 | { |
| 19936 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 19937 | |
| 19938 | ENTER(); |
| 19939 | |
| 19940 | if (wlan_hdd_validate_context(pHddCtx)) { |
| 19941 | return; |
| 19942 | } |
| 19943 | if (!pMsg) |
| 19944 | { |
| 19945 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null")); |
| 19946 | return; |
| 19947 | } |
| 19948 | |
Padma, Santhosh Kumar | f75c37b | 2016-01-25 10:36:08 +0530 | [diff] [blame] | 19949 | send_oem_data_rsp_msg(evLen, pMsg); |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 19950 | |
| 19951 | EXIT(); |
| 19952 | return; |
| 19953 | |
| 19954 | } |
| 19955 | |
| 19956 | void wlan_hdd_cfg80211_oemdata_callback(void *ctx, const tANI_U16 evType, |
Padma, Santhosh Kumar | f75c37b | 2016-01-25 10:36:08 +0530 | [diff] [blame] | 19957 | void *pMsg, tANI_U32 evLen) |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 19958 | { |
| 19959 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 19960 | |
| 19961 | ENTER(); |
| 19962 | |
| 19963 | if (wlan_hdd_validate_context(pHddCtx)) { |
| 19964 | return; |
| 19965 | } |
| 19966 | |
Padma, Santhosh Kumar | f75c37b | 2016-01-25 10:36:08 +0530 | [diff] [blame] | 19967 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d) evLen %d"), evType, evLen); |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 19968 | |
| 19969 | switch(evType) { |
| 19970 | case SIR_HAL_START_OEM_DATA_RSP_IND_NEW: |
Padma, Santhosh Kumar | f75c37b | 2016-01-25 10:36:08 +0530 | [diff] [blame] | 19971 | wlan_hdd_cfg80211_oem_data_rsp_ind_new(ctx, pMsg, evLen); |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 19972 | break; |
| 19973 | default: |
| 19974 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType); |
| 19975 | break; |
| 19976 | } |
| 19977 | EXIT(); |
| 19978 | } |
| 19979 | #endif |
| 19980 | |
Kanchanapally, Vidyullatha | 740d64e | 2016-05-03 15:25:54 +0530 | [diff] [blame] | 19981 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \ |
| 19982 | defined(CFG80211_ABORT_SCAN) |
Kanchanapally, Vidyullatha | c473516 | 2016-02-09 17:49:39 +0530 | [diff] [blame] | 19983 | /** |
| 19984 | * __wlan_hdd_cfg80211_abort_scan() - cfg80211 abort scan api |
| 19985 | * @wiphy: Pointer to wiphy |
| 19986 | * @wdev: Pointer to wireless device structure |
| 19987 | * |
| 19988 | * This function is used to abort an ongoing scan |
| 19989 | * |
| 19990 | * Return: None |
| 19991 | */ |
| 19992 | static void __wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy, |
| 19993 | struct wireless_dev *wdev) |
| 19994 | { |
| 19995 | struct net_device *dev = wdev->netdev; |
| 19996 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 19997 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 19998 | int ret; |
| 19999 | |
| 20000 | ENTER(); |
| 20001 | |
| 20002 | if (NULL == adapter) { |
| 20003 | hddLog(VOS_TRACE_LEVEL_FATAL, FL("HDD adapter is NULL")); |
| 20004 | return; |
| 20005 | } |
| 20006 | |
| 20007 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 20008 | if (0 != ret) |
| 20009 | return; |
| 20010 | |
| 20011 | wlan_hdd_scan_abort(adapter); |
| 20012 | |
| 20013 | return; |
| 20014 | } |
| 20015 | |
| 20016 | /** |
| 20017 | * wlan_hdd_cfg80211_abort_scan - cfg80211 abort scan api |
| 20018 | * @wiphy: Pointer to wiphy |
| 20019 | * @wdev: Pointer to wireless device structure |
| 20020 | * |
| 20021 | * Return: None |
| 20022 | */ |
| 20023 | void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy, |
| 20024 | struct wireless_dev *wdev) |
| 20025 | { |
| 20026 | vos_ssr_protect(__func__); |
| 20027 | __wlan_hdd_cfg80211_abort_scan(wiphy, wdev); |
| 20028 | vos_ssr_unprotect(__func__); |
| 20029 | |
| 20030 | return; |
| 20031 | } |
Kanchanapally, Vidyullatha | 740d64e | 2016-05-03 15:25:54 +0530 | [diff] [blame] | 20032 | #endif |
Kanchanapally, Vidyullatha | c473516 | 2016-02-09 17:49:39 +0530 | [diff] [blame] | 20033 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20034 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 20035 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20036 | { |
| 20037 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 20038 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 20039 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 20040 | .change_station = wlan_hdd_change_station, |
| 20041 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 20042 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 20043 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 20044 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 20045 | #else |
| 20046 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 20047 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 20048 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20049 | #endif |
| 20050 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 20051 | .add_key = wlan_hdd_cfg80211_add_key, |
| 20052 | .get_key = wlan_hdd_cfg80211_get_key, |
| 20053 | .del_key = wlan_hdd_cfg80211_del_key, |
| 20054 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 20055 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20056 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 20057 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20058 | .scan = wlan_hdd_cfg80211_scan, |
| 20059 | .connect = wlan_hdd_cfg80211_connect, |
| 20060 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 20061 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 20062 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 20063 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 20064 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 20065 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20066 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 20067 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 20068 | .mgmt_tx = wlan_hdd_mgmt_tx, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20069 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 20070 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 20071 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 20072 | .set_txq_params = wlan_hdd_set_txq_params, |
| 20073 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20074 | .get_station = wlan_hdd_cfg80211_get_station, |
| 20075 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 20076 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 20077 | .add_station = wlan_hdd_cfg80211_add_station, |
| 20078 | #ifdef FEATURE_WLAN_LFR |
| 20079 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 20080 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 20081 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 20082 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 20083 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 20084 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 20085 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 20086 | #ifdef FEATURE_WLAN_TDLS |
| 20087 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 20088 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 20089 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 20090 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 20091 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 20092 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 20093 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 20094 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 20095 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 20096 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 20097 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 20098 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 20099 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 20100 | #ifdef WLAN_NL80211_TESTMODE |
| 20101 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 20102 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 20103 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Kanchanapally, Vidyullatha | 740d64e | 2016-05-03 15:25:54 +0530 | [diff] [blame] | 20104 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) || \ |
| 20105 | defined(CFG80211_ABORT_SCAN) |
Kanchanapally, Vidyullatha | c473516 | 2016-02-09 17:49:39 +0530 | [diff] [blame] | 20106 | .abort_scan = wlan_hdd_cfg80211_abort_scan, |
Kanchanapally, Vidyullatha | 740d64e | 2016-05-03 15:25:54 +0530 | [diff] [blame] | 20107 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20108 | }; |
| 20109 | |