Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
| 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. |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 26 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 27 | |
| 28 | |
Kiet Lam | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 29 | |
| 30 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | /**======================================================================== |
| 32 | |
| 33 | \file wlan_hdd_cfg80211.c |
| 34 | |
| 35 | \brief WLAN Host Device Driver implementation |
| 36 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | ========================================================================*/ |
| 38 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 39 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 40 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 41 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 42 | |
| 43 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 44 | This section contains comments describing changes made to the module. |
| 45 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 46 | |
| 47 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 48 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 49 | |
| 50 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 51 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 53 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | |
| 55 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 56 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | ==========================================================================*/ |
| 58 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 59 | |
| 60 | #include <linux/version.h> |
| 61 | #include <linux/module.h> |
| 62 | #include <linux/kernel.h> |
| 63 | #include <linux/init.h> |
| 64 | #include <linux/wireless.h> |
| 65 | #include <wlan_hdd_includes.h> |
| 66 | #include <net/arp.h> |
| 67 | #include <net/cfg80211.h> |
| 68 | #include <linux/wireless.h> |
| 69 | #include <wlan_hdd_wowl.h> |
| 70 | #include <aniGlobal.h> |
| 71 | #include "ccmApi.h" |
| 72 | #include "sirParams.h" |
| 73 | #include "dot11f.h" |
| 74 | #include "wlan_hdd_assoc.h" |
| 75 | #include "wlan_hdd_wext.h" |
| 76 | #include "sme_Api.h" |
| 77 | #include "wlan_hdd_p2p.h" |
| 78 | #include "wlan_hdd_cfg80211.h" |
| 79 | #include "wlan_hdd_hostapd.h" |
| 80 | #include "sapInternal.h" |
| 81 | #include "wlan_hdd_softap_tx_rx.h" |
| 82 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 83 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 84 | #include "wlan_hdd_power.h" |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 85 | #include "wlan_hdd_trace.h" |
| 86 | #include "vos_types.h" |
| 87 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 88 | #ifdef WLAN_BTAMP_FEATURE |
| 89 | #include "bap_hdd_misc.h" |
| 90 | #endif |
| 91 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 92 | #ifdef FEATURE_WLAN_TDLS |
| 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" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 96 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 97 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 98 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 99 | |
| 100 | #define g_mode_rates_size (12) |
| 101 | #define a_mode_rates_size (8) |
| 102 | #define FREQ_BASE_80211G (2407) |
| 103 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 104 | #define MAX_SCAN_SSID 9 |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 105 | #define MAX_PENDING_LOG 5 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 106 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
krunal soni | 2a6a906 | 2014-02-11 14:14:23 -0800 | [diff] [blame] | 107 | ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 108 | |
| 109 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 110 | .band = IEEE80211_BAND_2GHZ, \ |
| 111 | .center_freq = (freq), \ |
| 112 | .hw_value = (chan),\ |
| 113 | .flags = (flag), \ |
| 114 | .max_antenna_gain = 0 ,\ |
| 115 | .max_power = 30, \ |
| 116 | } |
| 117 | |
| 118 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 119 | .band = IEEE80211_BAND_5GHZ, \ |
| 120 | .center_freq = (freq), \ |
| 121 | .hw_value = (chan),\ |
| 122 | .flags = (flag), \ |
| 123 | .max_antenna_gain = 0 ,\ |
| 124 | .max_power = 30, \ |
| 125 | } |
| 126 | |
| 127 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 128 | {\ |
| 129 | .bitrate = rate, \ |
| 130 | .hw_value = rate_id, \ |
| 131 | .flags = flag, \ |
| 132 | } |
| 133 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 134 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 135 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 136 | #else |
| 137 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 138 | #endif |
| 139 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 140 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 141 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 142 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 143 | #endif |
| 144 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 145 | #define HDD_CHANNEL_14 14 |
| 146 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 147 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 148 | /* |
| 149 | * Used to allocate the size of 4096 for the link layer stats. |
| 150 | * The size of 4096 is considered assuming that all data per |
| 151 | * respective event fit with in the limit.Please take a call |
| 152 | * on the limit based on the data requirements on link layer |
| 153 | * statistics. |
| 154 | */ |
| 155 | #define LL_STATS_EVENT_BUF_SIZE 4096 |
| 156 | #endif |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 157 | #ifdef WLAN_FEATURE_EXTSCAN |
| 158 | /* |
| 159 | * Used to allocate the size of 4096 for the EXTScan NL data. |
| 160 | * The size of 4096 is considered assuming that all data per |
| 161 | * respective event fit with in the limit.Please take a call |
| 162 | * on the limit based on the data requirements. |
| 163 | */ |
| 164 | |
| 165 | #define EXTSCAN_EVENT_BUF_SIZE 4096 |
| 166 | #define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32 |
| 167 | #endif |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 168 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 169 | /*EXT TDLS*/ |
| 170 | /* |
| 171 | * Used to allocate the size of 4096 for the TDLS. |
| 172 | * The size of 4096 is considered assuming that all data per |
| 173 | * respective event fit with in the limit.Please take a call |
| 174 | * on the limit based on the data requirements on link layer |
| 175 | * statistics. |
| 176 | */ |
| 177 | #define EXTTDLS_EVENT_BUF_SIZE 4096 |
| 178 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 179 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | { |
| 181 | WLAN_CIPHER_SUITE_WEP40, |
| 182 | WLAN_CIPHER_SUITE_WEP104, |
| 183 | WLAN_CIPHER_SUITE_TKIP, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 184 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 185 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 186 | WLAN_CIPHER_SUITE_KRK, |
| 187 | WLAN_CIPHER_SUITE_CCMP, |
| 188 | #else |
| 189 | WLAN_CIPHER_SUITE_CCMP, |
| 190 | #endif |
| 191 | #ifdef FEATURE_WLAN_WAPI |
| 192 | WLAN_CIPHER_SUITE_SMS4, |
| 193 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 194 | #ifdef WLAN_FEATURE_11W |
| 195 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 196 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 200 | { |
| 201 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 202 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 203 | } |
| 204 | |
| 205 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 206 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 207 | HDD2GHZCHAN(2412, 1, 0) , |
| 208 | HDD2GHZCHAN(2417, 2, 0) , |
| 209 | HDD2GHZCHAN(2422, 3, 0) , |
| 210 | HDD2GHZCHAN(2427, 4, 0) , |
| 211 | HDD2GHZCHAN(2432, 5, 0) , |
| 212 | HDD2GHZCHAN(2437, 6, 0) , |
| 213 | HDD2GHZCHAN(2442, 7, 0) , |
| 214 | HDD2GHZCHAN(2447, 8, 0) , |
| 215 | HDD2GHZCHAN(2452, 9, 0) , |
| 216 | HDD2GHZCHAN(2457, 10, 0) , |
| 217 | HDD2GHZCHAN(2462, 11, 0) , |
| 218 | HDD2GHZCHAN(2467, 12, 0) , |
| 219 | HDD2GHZCHAN(2472, 13, 0) , |
| 220 | HDD2GHZCHAN(2484, 14, 0) , |
| 221 | }; |
| 222 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 223 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 224 | { |
| 225 | HDD2GHZCHAN(2412, 1, 0) , |
| 226 | HDD2GHZCHAN(2437, 6, 0) , |
| 227 | HDD2GHZCHAN(2462, 11, 0) , |
| 228 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 229 | |
| 230 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 231 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 232 | HDD5GHZCHAN(4920, 240, 0) , |
| 233 | HDD5GHZCHAN(4940, 244, 0) , |
| 234 | HDD5GHZCHAN(4960, 248, 0) , |
| 235 | HDD5GHZCHAN(4980, 252, 0) , |
| 236 | HDD5GHZCHAN(5040, 208, 0) , |
| 237 | HDD5GHZCHAN(5060, 212, 0) , |
| 238 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | HDD5GHZCHAN(5180, 36, 0) , |
| 240 | HDD5GHZCHAN(5200, 40, 0) , |
| 241 | HDD5GHZCHAN(5220, 44, 0) , |
| 242 | HDD5GHZCHAN(5240, 48, 0) , |
| 243 | HDD5GHZCHAN(5260, 52, 0) , |
| 244 | HDD5GHZCHAN(5280, 56, 0) , |
| 245 | HDD5GHZCHAN(5300, 60, 0) , |
| 246 | HDD5GHZCHAN(5320, 64, 0) , |
| 247 | HDD5GHZCHAN(5500,100, 0) , |
| 248 | HDD5GHZCHAN(5520,104, 0) , |
| 249 | HDD5GHZCHAN(5540,108, 0) , |
| 250 | HDD5GHZCHAN(5560,112, 0) , |
| 251 | HDD5GHZCHAN(5580,116, 0) , |
| 252 | HDD5GHZCHAN(5600,120, 0) , |
| 253 | HDD5GHZCHAN(5620,124, 0) , |
| 254 | HDD5GHZCHAN(5640,128, 0) , |
| 255 | HDD5GHZCHAN(5660,132, 0) , |
| 256 | HDD5GHZCHAN(5680,136, 0) , |
| 257 | HDD5GHZCHAN(5700,140, 0) , |
Leo Chang | 80de3c2 | 2013-11-26 10:52:12 -0800 | [diff] [blame] | 258 | #ifdef FEATURE_WLAN_CH144 |
| 259 | HDD5GHZCHAN(5720,144, 0) , |
| 260 | #endif /* FEATURE_WLAN_CH144 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | HDD5GHZCHAN(5745,149, 0) , |
| 262 | HDD5GHZCHAN(5765,153, 0) , |
| 263 | HDD5GHZCHAN(5785,157, 0) , |
| 264 | HDD5GHZCHAN(5805,161, 0) , |
| 265 | HDD5GHZCHAN(5825,165, 0) , |
| 266 | }; |
| 267 | |
| 268 | static struct ieee80211_rate g_mode_rates[] = |
| 269 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 270 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 271 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 272 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 273 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 274 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 275 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 276 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 277 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 278 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 279 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 280 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 281 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 282 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 283 | |
| 284 | static struct ieee80211_rate a_mode_rates[] = |
| 285 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 286 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 287 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 288 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 289 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 290 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 291 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 292 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 293 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 294 | }; |
| 295 | |
| 296 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 297 | { |
| 298 | .channels = hdd_channels_2_4_GHZ, |
| 299 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 300 | .band = IEEE80211_BAND_2GHZ, |
| 301 | .bitrates = g_mode_rates, |
| 302 | .n_bitrates = g_mode_rates_size, |
| 303 | .ht_cap.ht_supported = 1, |
| 304 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 305 | | IEEE80211_HT_CAP_GRN_FLD |
| 306 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 307 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 308 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 309 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 310 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 311 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 312 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 313 | }; |
| 314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 315 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 316 | { |
| 317 | .channels = hdd_social_channels_2_4_GHZ, |
| 318 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 319 | .band = IEEE80211_BAND_2GHZ, |
| 320 | .bitrates = g_mode_rates, |
| 321 | .n_bitrates = g_mode_rates_size, |
| 322 | .ht_cap.ht_supported = 1, |
| 323 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 324 | | IEEE80211_HT_CAP_GRN_FLD |
| 325 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 326 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 327 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 328 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 329 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 330 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 331 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 332 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 333 | |
| 334 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 335 | { |
| 336 | .channels = hdd_channels_5_GHZ, |
| 337 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 338 | .band = IEEE80211_BAND_5GHZ, |
| 339 | .bitrates = a_mode_rates, |
| 340 | .n_bitrates = a_mode_rates_size, |
| 341 | .ht_cap.ht_supported = 1, |
| 342 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 343 | | IEEE80211_HT_CAP_GRN_FLD |
| 344 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 345 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 346 | | IEEE80211_HT_CAP_SGI_40 |
| 347 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 348 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 349 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 350 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 351 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 352 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 353 | }; |
| 354 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 355 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 356 | TX/RX direction for each kind of interface */ |
| 357 | static const struct ieee80211_txrx_stypes |
| 358 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 359 | [NL80211_IFTYPE_STATION] = { |
| 360 | .tx = 0xffff, |
| 361 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 362 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 363 | }, |
| 364 | [NL80211_IFTYPE_AP] = { |
| 365 | .tx = 0xffff, |
| 366 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 367 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 368 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 369 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 370 | BIT(SIR_MAC_MGMT_AUTH) | |
| 371 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 372 | BIT(SIR_MAC_MGMT_ACTION), |
| 373 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 374 | [NL80211_IFTYPE_ADHOC] = { |
| 375 | .tx = 0xffff, |
| 376 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 377 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 378 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 379 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 380 | BIT(SIR_MAC_MGMT_AUTH) | |
| 381 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 382 | BIT(SIR_MAC_MGMT_ACTION), |
| 383 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 384 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 385 | .tx = 0xffff, |
| 386 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 387 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 388 | }, |
| 389 | [NL80211_IFTYPE_P2P_GO] = { |
| 390 | /* This is also same as for SoftAP */ |
| 391 | .tx = 0xffff, |
| 392 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 393 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 394 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 395 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 396 | BIT(SIR_MAC_MGMT_AUTH) | |
| 397 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 398 | BIT(SIR_MAC_MGMT_ACTION), |
| 399 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 400 | }; |
| 401 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 402 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 403 | static const struct ieee80211_iface_limit |
| 404 | wlan_hdd_iface_limit[] = { |
| 405 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 406 | /* max = 3 ; Our driver create two interfaces during driver init |
| 407 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 408 | * interface until a group is formed. In JB architecture, once the |
| 409 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 410 | * Client. |
| 411 | * When supplicant remove the group, it first issue a set interface |
| 412 | * cmd to change the mode back to Station. In JB this works fine as |
| 413 | * we advertize two station type interface during driver init. |
| 414 | * Some vendors create separate interface for P2P GO/Client, |
| 415 | * after group formation(Third one). But while group remove |
| 416 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 417 | * But as we advertized only two sta type interfaces nl80211 was |
| 418 | * returning error for the third one which was leading to failure in |
| 419 | * delete interface. Ideally while removing the group, supplicant |
| 420 | * should not try to change the 3rd interface mode to Station type. |
| 421 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 422 | * interface type to 3 |
| 423 | */ |
| 424 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 425 | .types = BIT(NL80211_IFTYPE_STATION), |
| 426 | }, |
| 427 | { |
| 428 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 429 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 430 | }, |
| 431 | { |
| 432 | .max = 1, |
| 433 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 434 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 435 | }, |
| 436 | }; |
| 437 | |
| 438 | /* By default, only single channel concurrency is allowed */ |
| 439 | static struct ieee80211_iface_combination |
| 440 | wlan_hdd_iface_combination = { |
| 441 | .limits = wlan_hdd_iface_limit, |
| 442 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 443 | /* |
| 444 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 445 | * and p2p0 interfaces during driver init |
| 446 | * Some vendors create separate interface for P2P operations. |
| 447 | * wlan0: STA interface |
| 448 | * p2p0: P2P Device interface, action frames goes |
| 449 | * through this interface. |
| 450 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 451 | * created for p2p operations(GO/CLIENT interface). |
| 452 | */ |
| 453 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 454 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 455 | .beacon_int_infra_match = false, |
| 456 | }; |
| 457 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 458 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 460 | |
| 461 | /* Data rate 100KBPS based on IE Index */ |
| 462 | struct index_data_rate_type |
| 463 | { |
| 464 | v_U8_t beacon_rate_index; |
| 465 | v_U16_t supported_rate[4]; |
| 466 | }; |
| 467 | |
| 468 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 469 | The IDX field is the rate index |
| 470 | The HI field is the rate when RSSI is strong or being ignored |
| 471 | (in this case we report actual rate) |
| 472 | The MID field is the rate when RSSI is moderate |
| 473 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 474 | The LO field is the rate when RSSI is low |
| 475 | (in this case we don't report rates, actual current rate used) |
| 476 | */ |
| 477 | static const struct |
| 478 | { |
| 479 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 480 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 481 | } supported_data_rate[] = |
| 482 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 483 | /* IDX HI HM LM LO (RSSI-based index */ |
| 484 | {2, { 10, 10, 10, 0}}, |
| 485 | {4, { 20, 20, 10, 0}}, |
| 486 | {11, { 55, 20, 10, 0}}, |
| 487 | {12, { 60, 55, 20, 0}}, |
| 488 | {18, { 90, 55, 20, 0}}, |
| 489 | {22, {110, 55, 20, 0}}, |
| 490 | {24, {120, 90, 60, 0}}, |
| 491 | {36, {180, 120, 60, 0}}, |
| 492 | {44, {220, 180, 60, 0}}, |
| 493 | {48, {240, 180, 90, 0}}, |
| 494 | {66, {330, 180, 90, 0}}, |
| 495 | {72, {360, 240, 90, 0}}, |
| 496 | {96, {480, 240, 120, 0}}, |
| 497 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 498 | }; |
| 499 | |
| 500 | /* MCS Based rate table */ |
| 501 | static struct index_data_rate_type supported_mcs_rate[] = |
| 502 | { |
| 503 | /* MCS L20 L40 S20 S40 */ |
| 504 | {0, {65, 135, 72, 150}}, |
| 505 | {1, {130, 270, 144, 300}}, |
| 506 | {2, {195, 405, 217, 450}}, |
| 507 | {3, {260, 540, 289, 600}}, |
| 508 | {4, {390, 810, 433, 900}}, |
| 509 | {5, {520, 1080, 578, 1200}}, |
| 510 | {6, {585, 1215, 650, 1350}}, |
| 511 | {7, {650, 1350, 722, 1500}} |
| 512 | }; |
| 513 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 514 | #ifdef WLAN_FEATURE_11AC |
| 515 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 516 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 517 | |
| 518 | struct index_vht_data_rate_type |
| 519 | { |
| 520 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 521 | v_U16_t supported_VHT80_rate[2]; |
| 522 | v_U16_t supported_VHT40_rate[2]; |
| 523 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | typedef enum |
| 527 | { |
| 528 | DATA_RATE_11AC_MAX_MCS_7, |
| 529 | DATA_RATE_11AC_MAX_MCS_8, |
| 530 | DATA_RATE_11AC_MAX_MCS_9, |
| 531 | DATA_RATE_11AC_MAX_MCS_NA |
| 532 | } eDataRate11ACMaxMcs; |
| 533 | |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 534 | /* SSID broadcast type */ |
| 535 | typedef enum eSSIDBcastType |
| 536 | { |
| 537 | eBCAST_UNKNOWN = 0, |
| 538 | eBCAST_NORMAL = 1, |
| 539 | eBCAST_HIDDEN = 2, |
| 540 | } tSSIDBcastType; |
| 541 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 542 | /* MCS Based VHT rate table */ |
| 543 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 544 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 545 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 546 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 547 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 548 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 549 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 550 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 551 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 552 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 553 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 554 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 555 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 556 | }; |
| 557 | #endif /* WLAN_FEATURE_11AC */ |
| 558 | |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 559 | /*array index points to MCS and array value points respective rssi*/ |
| 560 | static int rssiMcsTbl[][10] = |
| 561 | { |
| 562 | /*MCS 0 1 2 3 4 5 6 7 8 9*/ |
| 563 | {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20 |
| 564 | {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40 |
| 565 | {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80 |
| 566 | }; |
| 567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 568 | extern struct net_device_ops net_ops_struct; |
| 569 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 570 | #ifdef WLAN_NL80211_TESTMODE |
| 571 | enum wlan_hdd_tm_attr |
| 572 | { |
| 573 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 574 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 575 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 576 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 577 | /* keep last */ |
| 578 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 579 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 580 | }; |
| 581 | |
| 582 | enum wlan_hdd_tm_cmd |
| 583 | { |
| 584 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 585 | }; |
| 586 | |
| 587 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 588 | |
| 589 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 590 | { |
| 591 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 592 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 593 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 594 | }; |
| 595 | #endif /* WLAN_NL80211_TESTMODE */ |
| 596 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 597 | #ifdef FEATURE_WLAN_CH_AVOID |
| 598 | /* |
| 599 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 600 | * This is called when wlan driver needs to send vendor specific |
| 601 | * avoid frequency range event to userspace |
| 602 | */ |
| 603 | int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx, |
| 604 | tHddAvoidFreqList *pAvoidFreqList) |
| 605 | { |
| 606 | struct sk_buff *vendor_event; |
| 607 | |
| 608 | ENTER(); |
| 609 | |
| 610 | if (!pHddCtx) |
| 611 | { |
| 612 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 613 | "%s: HDD context is null", __func__); |
| 614 | return -1; |
| 615 | } |
| 616 | |
| 617 | if (!pAvoidFreqList) |
| 618 | { |
| 619 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 620 | "%s: pAvoidFreqList is null", __func__); |
| 621 | return -1; |
| 622 | } |
| 623 | |
| 624 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 625 | sizeof(tHddAvoidFreqList), |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 626 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 627 | GFP_KERNEL); |
| 628 | if (!vendor_event) |
| 629 | { |
| 630 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 631 | "%s: cfg80211_vendor_event_alloc failed", __func__); |
| 632 | return -1; |
| 633 | } |
| 634 | |
| 635 | memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)), |
| 636 | (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList)); |
| 637 | |
| 638 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 639 | |
| 640 | EXIT(); |
| 641 | return 0; |
| 642 | } |
| 643 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 644 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 645 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 646 | |
| 647 | static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats, |
| 648 | struct sk_buff *vendor_event) |
| 649 | { |
| 650 | if (nla_put_u8(vendor_event, |
| 651 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE, |
| 652 | stats->rate.preamble) || |
| 653 | nla_put_u8(vendor_event, |
| 654 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS, |
| 655 | stats->rate.nss) || |
| 656 | nla_put_u8(vendor_event, |
| 657 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW, |
| 658 | stats->rate.bw) || |
| 659 | nla_put_u8(vendor_event, |
| 660 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX, |
| 661 | stats->rate.rateMcsIdx) || |
| 662 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE, |
| 663 | stats->rate.bitrate ) || |
| 664 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU, |
| 665 | stats->txMpdu ) || |
| 666 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU, |
| 667 | stats->rxMpdu ) || |
| 668 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST, |
| 669 | stats->mpduLost ) || |
| 670 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES, |
| 671 | stats->retries) || |
| 672 | nla_put_u32(vendor_event, |
| 673 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT, |
| 674 | stats->retriesShort ) || |
| 675 | nla_put_u32(vendor_event, |
| 676 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG, |
| 677 | stats->retriesLong)) |
| 678 | { |
| 679 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 680 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 681 | return FALSE; |
| 682 | } |
| 683 | return TRUE; |
| 684 | } |
| 685 | |
| 686 | static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats, |
| 687 | struct sk_buff *vendor_event) |
| 688 | { |
| 689 | u32 i = 0; |
| 690 | struct nlattr *rateInfo; |
| 691 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE, |
| 692 | stats->type) || |
| 693 | nla_put(vendor_event, |
| 694 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS, |
| 695 | VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) || |
| 696 | nla_put_u32(vendor_event, |
| 697 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES, |
| 698 | stats->capabilities) || |
| 699 | nla_put_u32(vendor_event, |
| 700 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES, |
| 701 | stats->numRate)) |
| 702 | { |
| 703 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 704 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 705 | goto error; |
| 706 | } |
| 707 | |
| 708 | rateInfo = nla_nest_start(vendor_event, |
| 709 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO); |
| 710 | for (i = 0; i < stats->numRate; i++) |
| 711 | { |
| 712 | struct nlattr *rates; |
| 713 | tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *) |
| 714 | stats->rateStats + |
| 715 | (i * sizeof(tSirWifiRateStat))); |
| 716 | rates = nla_nest_start(vendor_event, i); |
| 717 | |
| 718 | if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event)) |
| 719 | { |
| 720 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 721 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 722 | return FALSE; |
| 723 | } |
| 724 | nla_nest_end(vendor_event, rates); |
| 725 | } |
| 726 | nla_nest_end(vendor_event, rateInfo); |
| 727 | |
| 728 | return TRUE; |
| 729 | error: |
| 730 | return FALSE; |
| 731 | } |
| 732 | |
| 733 | static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats, |
| 734 | struct sk_buff *vendor_event) |
| 735 | { |
| 736 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC, |
| 737 | stats->ac ) || |
| 738 | nla_put_u32(vendor_event, |
| 739 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU, |
| 740 | stats->txMpdu ) || |
| 741 | nla_put_u32(vendor_event, |
| 742 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU, |
| 743 | stats->rxMpdu ) || |
| 744 | nla_put_u32(vendor_event, |
| 745 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST, |
| 746 | stats->txMcast ) || |
| 747 | nla_put_u32(vendor_event, |
| 748 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST, |
| 749 | stats->rxMcast ) || |
| 750 | nla_put_u32(vendor_event, |
| 751 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU, |
| 752 | stats->rxAmpdu ) || |
| 753 | nla_put_u32(vendor_event, |
| 754 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU, |
| 755 | stats->txAmpdu ) || |
| 756 | nla_put_u32(vendor_event, |
| 757 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST, |
| 758 | stats->mpduLost )|| |
| 759 | nla_put_u32(vendor_event, |
| 760 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES, |
| 761 | stats->retries ) || |
| 762 | nla_put_u32(vendor_event, |
| 763 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT, |
| 764 | stats->retriesShort ) || |
| 765 | nla_put_u32(vendor_event, |
| 766 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG, |
| 767 | stats->retriesLong ) || |
| 768 | nla_put_u32(vendor_event, |
| 769 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN, |
| 770 | stats->contentionTimeMin ) || |
| 771 | nla_put_u32(vendor_event, |
| 772 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX, |
| 773 | stats->contentionTimeMax ) || |
| 774 | nla_put_u32(vendor_event, |
| 775 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG, |
| 776 | stats->contentionTimeAvg ) || |
| 777 | nla_put_u32(vendor_event, |
| 778 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES, |
| 779 | stats->contentionNumSamples )) |
| 780 | { |
| 781 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 782 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 783 | return FALSE; |
| 784 | } |
| 785 | return TRUE; |
| 786 | } |
| 787 | |
| 788 | static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats, |
| 789 | struct sk_buff *vendor_event) |
| 790 | { |
Dino Mycle | c8f3f33 | 2014-07-21 16:48:27 +0530 | [diff] [blame] | 791 | if (nla_put_s32(vendor_event, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 792 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) || |
| 793 | nla_put(vendor_event, |
| 794 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR, |
| 795 | VOS_MAC_ADDR_SIZE, stats->macAddr) || |
| 796 | nla_put_u32(vendor_event, |
| 797 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE, |
| 798 | stats->state ) || |
| 799 | nla_put_u32(vendor_event, |
| 800 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING, |
| 801 | stats->roaming ) || |
| 802 | nla_put_u32(vendor_event, |
| 803 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES, |
| 804 | stats->capabilities ) || |
| 805 | nla_put(vendor_event, |
| 806 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID, |
| 807 | strlen(stats->ssid), stats->ssid) || |
| 808 | nla_put(vendor_event, |
| 809 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID, |
| 810 | WNI_CFG_BSSID_LEN, stats->bssid) || |
| 811 | nla_put(vendor_event, |
| 812 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR, |
| 813 | WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) || |
| 814 | nla_put(vendor_event, |
| 815 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR, |
| 816 | WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr) |
| 817 | ) |
| 818 | { |
| 819 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 820 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 821 | return FALSE; |
| 822 | } |
| 823 | return TRUE; |
| 824 | } |
| 825 | |
| 826 | static v_BOOL_t put_wifi_iface_stats(tpSirWifiIfaceStat pWifiIfaceStat, |
| 827 | struct sk_buff *vendor_event) |
| 828 | { |
| 829 | int i = 0; |
| 830 | struct nlattr *wmmInfo; |
| 831 | if (FALSE == put_wifi_interface_info( |
| 832 | &pWifiIfaceStat->info, |
| 833 | vendor_event)) |
| 834 | { |
| 835 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 836 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 837 | return FALSE; |
| 838 | |
| 839 | } |
| 840 | |
| 841 | if (nla_put_u32(vendor_event, |
| 842 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX, |
| 843 | pWifiIfaceStat->beaconRx) || |
| 844 | nla_put_u32(vendor_event, |
| 845 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX, |
| 846 | pWifiIfaceStat->mgmtRx) || |
| 847 | nla_put_u32(vendor_event, |
| 848 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX, |
| 849 | pWifiIfaceStat->mgmtActionRx) || |
| 850 | nla_put_u32(vendor_event, |
| 851 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX, |
| 852 | pWifiIfaceStat->mgmtActionTx) || |
| 853 | nla_put_u32(vendor_event, |
| 854 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT, |
| 855 | pWifiIfaceStat->rssiMgmt) || |
| 856 | nla_put_u32(vendor_event, |
| 857 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA, |
| 858 | pWifiIfaceStat->rssiData) || |
| 859 | nla_put_u32(vendor_event, |
| 860 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK, |
| 861 | pWifiIfaceStat->rssiAck)) |
| 862 | { |
| 863 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 864 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 865 | return FALSE; |
| 866 | } |
| 867 | |
| 868 | wmmInfo = nla_nest_start(vendor_event, |
| 869 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO); |
| 870 | for (i = 0; i < WIFI_AC_MAX; i++) |
| 871 | { |
| 872 | struct nlattr *wmmStats; |
| 873 | wmmStats = nla_nest_start(vendor_event, i); |
| 874 | if (FALSE == put_wifi_wmm_ac_stat( |
| 875 | &pWifiIfaceStat->AccessclassStats[i], |
| 876 | vendor_event)) |
| 877 | { |
| 878 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 879 | FL("QCA_WLAN_VENDOR_ATTR put Fail")); |
| 880 | return FALSE; |
| 881 | } |
| 882 | |
| 883 | nla_nest_end(vendor_event, wmmStats); |
| 884 | } |
| 885 | nla_nest_end(vendor_event, wmmInfo); |
| 886 | return TRUE; |
| 887 | } |
| 888 | |
| 889 | static tSirWifiInterfaceMode |
| 890 | hdd_map_device_to_ll_iface_mode ( int deviceMode ) |
| 891 | { |
| 892 | switch (deviceMode) |
| 893 | { |
| 894 | case WLAN_HDD_INFRA_STATION: |
| 895 | return WIFI_INTERFACE_STA; |
| 896 | case WLAN_HDD_SOFTAP: |
| 897 | return WIFI_INTERFACE_SOFTAP; |
| 898 | case WLAN_HDD_P2P_CLIENT: |
| 899 | return WIFI_INTERFACE_P2P_CLIENT; |
| 900 | case WLAN_HDD_P2P_GO: |
| 901 | return WIFI_INTERFACE_P2P_GO; |
| 902 | case WLAN_HDD_IBSS: |
| 903 | return WIFI_INTERFACE_IBSS; |
| 904 | default: |
Dino Mycle | c8f3f33 | 2014-07-21 16:48:27 +0530 | [diff] [blame] | 905 | return WIFI_INTERFACE_UNKNOWN; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 906 | } |
| 907 | } |
| 908 | |
| 909 | static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter, |
| 910 | tpSirWifiInterfaceInfo pInfo) |
| 911 | { |
| 912 | v_U8_t *staMac = NULL; |
| 913 | hdd_station_ctx_t *pHddStaCtx; |
| 914 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 915 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
| 916 | |
| 917 | pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode); |
| 918 | |
| 919 | vos_mem_copy(pInfo->macAddr, |
| 920 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
| 921 | |
| 922 | if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 923 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 924 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))) |
| 925 | { |
| 926 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 927 | if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) |
| 928 | { |
| 929 | pInfo->state = WIFI_DISCONNECTED; |
| 930 | } |
| 931 | if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) |
| 932 | { |
| 933 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 934 | "%s: Session ID %d, Connection is in progress", __func__, |
| 935 | pAdapter->sessionId); |
| 936 | pInfo->state = WIFI_ASSOCIATING; |
| 937 | } |
| 938 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 939 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 940 | { |
| 941 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 942 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 943 | "%s: client " MAC_ADDRESS_STR |
| 944 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 945 | MAC_ADDR_ARRAY(staMac)); |
| 946 | pInfo->state = WIFI_AUTHENTICATING; |
| 947 | } |
| 948 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 949 | { |
| 950 | pInfo->state = WIFI_ASSOCIATED; |
| 951 | vos_mem_copy(pInfo->bssid, |
| 952 | &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN); |
| 953 | vos_mem_copy(pInfo->ssid, |
| 954 | pHddStaCtx->conn_info.SSID.SSID.ssId, |
| 955 | pHddStaCtx->conn_info.SSID.SSID.length); |
| 956 | //NULL Terminate the string. |
| 957 | pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0; |
| 958 | } |
| 959 | } |
| 960 | vos_mem_copy(pInfo->countryStr, |
| 961 | pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN); |
| 962 | |
| 963 | vos_mem_copy(pInfo->apCountryStr, |
| 964 | pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN); |
| 965 | |
| 966 | return TRUE; |
| 967 | } |
| 968 | |
| 969 | /* |
| 970 | * hdd_link_layer_process_peer_stats () - This function is called after |
| 971 | * receiving Link Layer Peer statistics from FW.This function converts |
| 972 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 973 | * layers. |
| 974 | */ |
| 975 | static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter, |
| 976 | v_VOID_t *pData) |
| 977 | { |
| 978 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 979 | tpSirWifiRateStat pWifiRateStat; |
| 980 | tpSirWifiPeerStat pWifiPeerStat; |
| 981 | tpSirWifiPeerInfo pWifiPeerInfo; |
| 982 | struct nlattr *peerInfo; |
| 983 | struct sk_buff *vendor_event; |
| 984 | int status, i; |
| 985 | |
| 986 | status = wlan_hdd_validate_context(pHddCtx); |
| 987 | if (0 != status) |
| 988 | { |
| 989 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 990 | FL("HDD context is not valid") ); |
| 991 | return; |
| 992 | } |
| 993 | |
| 994 | pWifiPeerStat = (tpSirWifiPeerStat) pData; |
| 995 | |
| 996 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 997 | "LL_STATS_PEER_ALL : numPeers %u", |
| 998 | pWifiPeerStat->numPeers); |
| 999 | { |
| 1000 | for (i = 0; i < pWifiPeerStat->numPeers; i++) |
| 1001 | { |
| 1002 | pWifiPeerInfo = (tpSirWifiPeerInfo) |
| 1003 | ((uint8 *)pWifiPeerStat->peerInfo + |
| 1004 | ( i * sizeof(tSirWifiPeerInfo))); |
| 1005 | |
| 1006 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1007 | " %d) LL_STATS Channel Stats " |
| 1008 | " Peer Type %u " |
| 1009 | " peerMacAddress %pM " |
| 1010 | " capabilities 0x%x " |
| 1011 | " numRate %u ", |
| 1012 | i, |
| 1013 | pWifiPeerInfo->type, |
| 1014 | pWifiPeerInfo->peerMacAddress, |
| 1015 | pWifiPeerInfo->capabilities, |
| 1016 | pWifiPeerInfo->numRate); |
| 1017 | { |
| 1018 | int j; |
| 1019 | for (j = 0; j < pWifiPeerInfo->numRate; j++) |
| 1020 | { |
| 1021 | pWifiRateStat = (tpSirWifiRateStat) |
| 1022 | ((tANI_U8 *) pWifiPeerInfo->rateStats + |
| 1023 | ( j * sizeof(tSirWifiRateStat))); |
| 1024 | |
| 1025 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1026 | " peer Rate Stats " |
| 1027 | " preamble %u " |
| 1028 | " nss %u " |
| 1029 | " bw %u " |
| 1030 | " rateMcsIdx %u " |
| 1031 | " reserved %u " |
| 1032 | " bitrate %u " |
| 1033 | " txMpdu %u " |
| 1034 | " rxMpdu %u " |
| 1035 | " mpduLost %u " |
| 1036 | " retries %u " |
| 1037 | " retriesShort %u " |
| 1038 | " retriesLong %u", |
| 1039 | pWifiRateStat->rate.preamble, |
| 1040 | pWifiRateStat->rate.nss, |
| 1041 | pWifiRateStat->rate.bw, |
| 1042 | pWifiRateStat->rate.rateMcsIdx, |
| 1043 | pWifiRateStat->rate.reserved, |
| 1044 | pWifiRateStat->rate.bitrate, |
| 1045 | pWifiRateStat->txMpdu, |
| 1046 | pWifiRateStat->rxMpdu, |
| 1047 | pWifiRateStat->mpduLost, |
| 1048 | pWifiRateStat->retries, |
| 1049 | pWifiRateStat->retriesShort, |
| 1050 | pWifiRateStat->retriesLong); |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | /* |
| 1057 | * Allocate a size of 4096 for the peer stats comprising |
| 1058 | * each of size = sizeof (tSirWifiPeerInfo) + numRate * |
| 1059 | * sizeof (tSirWifiRateStat).Each field is put with an |
| 1060 | * NL attribute.The size of 4096 is considered assuming |
| 1061 | * that number of rates shall not exceed beyond 50 with |
| 1062 | * the sizeof (tSirWifiRateStat) being 32. |
| 1063 | */ |
| 1064 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1065 | LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 1066 | QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX, |
| 1067 | GFP_KERNEL); |
| 1068 | if (!vendor_event) |
| 1069 | { |
| 1070 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1071 | "%s: cfg80211_vendor_event_alloc failed", |
| 1072 | __func__); |
| 1073 | return; |
| 1074 | } |
| 1075 | if (nla_put_u32(vendor_event, |
| 1076 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS, |
| 1077 | pWifiPeerStat->numPeers)) |
| 1078 | { |
| 1079 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1080 | "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__); |
| 1081 | kfree_skb(vendor_event); |
| 1082 | return; |
| 1083 | } |
| 1084 | |
| 1085 | peerInfo = nla_nest_start(vendor_event, |
| 1086 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO); |
| 1087 | |
| 1088 | pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *) |
| 1089 | pWifiPeerStat->peerInfo); |
| 1090 | |
| 1091 | for (i = 1; i <= pWifiPeerStat->numPeers; i++) |
| 1092 | { |
| 1093 | struct nlattr *peers = nla_nest_start(vendor_event, i); |
| 1094 | int numRate = pWifiPeerInfo->numRate; |
| 1095 | |
| 1096 | if (FALSE == put_wifi_peer_info( |
| 1097 | pWifiPeerInfo, vendor_event)) |
| 1098 | { |
| 1099 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1100 | "%s: put_wifi_peer_info put fail", __func__); |
| 1101 | kfree_skb(vendor_event); |
| 1102 | return; |
| 1103 | } |
| 1104 | |
| 1105 | pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *) |
| 1106 | pWifiPeerStat->peerInfo + |
| 1107 | (i * sizeof(tSirWifiPeerInfo)) + |
| 1108 | (numRate * sizeof (tSirWifiRateStat))); |
| 1109 | nla_nest_end(vendor_event, peers); |
| 1110 | } |
| 1111 | nla_nest_end(vendor_event, peerInfo); |
| 1112 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1113 | } |
| 1114 | |
| 1115 | /* |
| 1116 | * hdd_link_layer_process_iface_stats () - This function is called after |
| 1117 | * receiving Link Layer Interface statistics from FW.This function converts |
| 1118 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1119 | * layers. |
| 1120 | */ |
| 1121 | static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter, |
| 1122 | v_VOID_t *pData) |
| 1123 | { |
| 1124 | tpSirWifiIfaceStat pWifiIfaceStat; |
| 1125 | struct sk_buff *vendor_event; |
| 1126 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1127 | int status; |
| 1128 | |
| 1129 | status = wlan_hdd_validate_context(pHddCtx); |
| 1130 | if (0 != status) |
| 1131 | { |
| 1132 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1133 | FL("HDD context is not valid") ); |
| 1134 | return; |
| 1135 | } |
| 1136 | /* |
| 1137 | * Allocate a size of 4096 for the interface stats comprising |
| 1138 | * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered |
| 1139 | * assuming that all these fit with in the limit.Please take |
| 1140 | * a call on the limit based on the data requirements on |
| 1141 | * interface statistics. |
| 1142 | */ |
| 1143 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1144 | LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 1145 | QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX, |
| 1146 | GFP_KERNEL); |
| 1147 | if (!vendor_event) |
| 1148 | { |
| 1149 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1150 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1151 | return; |
| 1152 | } |
| 1153 | |
| 1154 | pWifiIfaceStat = (tpSirWifiIfaceStat) pData; |
| 1155 | |
| 1156 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1157 | "WMI_LINK_STATS_IFACE Data"); |
| 1158 | |
| 1159 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1160 | "LL_STATS_IFACE: " |
| 1161 | " Mode %u " |
| 1162 | " MAC %pM " |
| 1163 | " State %u " |
| 1164 | " Roaming %u " |
| 1165 | " capabilities 0x%x " |
| 1166 | " SSID %s " |
| 1167 | " BSSID %pM", |
| 1168 | pWifiIfaceStat->info.mode, |
| 1169 | pWifiIfaceStat->info.macAddr, |
| 1170 | pWifiIfaceStat->info.state, |
| 1171 | pWifiIfaceStat->info.roaming, |
| 1172 | pWifiIfaceStat->info.capabilities, |
| 1173 | pWifiIfaceStat->info.ssid, |
| 1174 | pWifiIfaceStat->info.bssid); |
| 1175 | |
| 1176 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1177 | " AP country str: %c%c%c", |
| 1178 | pWifiIfaceStat->info.apCountryStr[0], |
| 1179 | pWifiIfaceStat->info.apCountryStr[1], |
| 1180 | pWifiIfaceStat->info.apCountryStr[2]); |
| 1181 | |
| 1182 | |
| 1183 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1184 | " Country Str Association: %c%c%c", |
| 1185 | pWifiIfaceStat->info.countryStr[0], |
| 1186 | pWifiIfaceStat->info.countryStr[1], |
| 1187 | pWifiIfaceStat->info.countryStr[2]); |
| 1188 | |
| 1189 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1190 | " beaconRx %u " |
| 1191 | " mgmtRx %u " |
| 1192 | " mgmtActionRx %u " |
| 1193 | " mgmtActionTx %u " |
| 1194 | " rssiMgmt %u " |
| 1195 | " rssiData %u " |
| 1196 | " rssiAck %u", |
| 1197 | pWifiIfaceStat->beaconRx, |
| 1198 | pWifiIfaceStat->mgmtRx, |
| 1199 | pWifiIfaceStat->mgmtActionRx, |
| 1200 | pWifiIfaceStat->mgmtActionTx, |
| 1201 | pWifiIfaceStat->rssiMgmt, |
| 1202 | pWifiIfaceStat->rssiData, |
| 1203 | pWifiIfaceStat->rssiAck ); |
| 1204 | |
| 1205 | |
| 1206 | { |
| 1207 | int i; |
| 1208 | for (i = 0 ; i < WIFI_AC_MAX; i ++) |
| 1209 | { |
| 1210 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1211 | |
| 1212 | " %d) LL_STATS IFACE: " |
| 1213 | " ac: %u txMpdu: %u " |
| 1214 | " rxMpdu: %u txMcast: %u " |
| 1215 | " rxMcast: %u rxAmpdu: %u " |
| 1216 | " txAmpdu: %u mpduLost: %u " |
| 1217 | " retries: %u retriesShort: %u " |
| 1218 | " retriesLong: %u contentionTimeMin: %u " |
| 1219 | " contentionTimeMax: %u contentionTimeAvg: %u " |
| 1220 | " contentionNumSamples: %u", |
| 1221 | i, |
| 1222 | pWifiIfaceStat->AccessclassStats[i].ac, |
| 1223 | pWifiIfaceStat->AccessclassStats[i].txMpdu, |
| 1224 | pWifiIfaceStat->AccessclassStats[i].rxMpdu, |
| 1225 | pWifiIfaceStat->AccessclassStats[i].txMcast, |
| 1226 | pWifiIfaceStat->AccessclassStats[i].rxMcast, |
| 1227 | pWifiIfaceStat->AccessclassStats[i].rxAmpdu, |
| 1228 | pWifiIfaceStat->AccessclassStats[i].txAmpdu, |
| 1229 | pWifiIfaceStat->AccessclassStats[i].mpduLost, |
| 1230 | pWifiIfaceStat->AccessclassStats[i].retries, |
| 1231 | pWifiIfaceStat-> |
| 1232 | AccessclassStats[i].retriesShort, |
| 1233 | pWifiIfaceStat->AccessclassStats[i].retriesLong, |
| 1234 | pWifiIfaceStat-> |
| 1235 | AccessclassStats[i].contentionTimeMin, |
| 1236 | pWifiIfaceStat-> |
| 1237 | AccessclassStats[i].contentionTimeMax, |
| 1238 | pWifiIfaceStat-> |
| 1239 | AccessclassStats[i].contentionTimeAvg, |
| 1240 | pWifiIfaceStat-> |
| 1241 | AccessclassStats[i].contentionNumSamples); |
| 1242 | |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | if (FALSE == hdd_get_interface_info( pAdapter, |
| 1247 | &pWifiIfaceStat->info)) |
| 1248 | { |
| 1249 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1250 | FL("hdd_get_interface_info get fail") ); |
| 1251 | kfree_skb(vendor_event); |
| 1252 | return; |
| 1253 | } |
| 1254 | |
| 1255 | if (FALSE == put_wifi_iface_stats( pWifiIfaceStat, |
| 1256 | vendor_event)) |
| 1257 | { |
| 1258 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1259 | FL("put_wifi_iface_stats fail") ); |
| 1260 | kfree_skb(vendor_event); |
| 1261 | return; |
| 1262 | } |
| 1263 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1264 | } |
| 1265 | |
| 1266 | /* |
| 1267 | * hdd_link_layer_process_radio_stats () - This function is called after |
| 1268 | * receiving Link Layer Radio statistics from FW.This function converts |
| 1269 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1270 | * layers. |
| 1271 | */ |
| 1272 | static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter, |
| 1273 | v_VOID_t *pData) |
| 1274 | { |
| 1275 | int status, i; |
| 1276 | tpSirWifiRadioStat pWifiRadioStat; |
| 1277 | tpSirWifiChannelStats pWifiChannelStats; |
| 1278 | struct sk_buff *vendor_event; |
| 1279 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1280 | struct nlattr *chList; |
| 1281 | |
| 1282 | status = wlan_hdd_validate_context(pHddCtx); |
| 1283 | if (0 != status) |
| 1284 | { |
| 1285 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1286 | FL("HDD context is not valid") ); |
| 1287 | return; |
| 1288 | } |
| 1289 | pWifiRadioStat = (tpSirWifiRadioStat) pData; |
| 1290 | |
| 1291 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1292 | "LL_STATS_RADIO" |
| 1293 | " radio is %d onTime is %u " |
| 1294 | " txTime is %u rxTime is %u " |
| 1295 | " onTimeScan is %u onTimeNbd is %u " |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1296 | " onTimeEXTScan is %u onTimeRoamScan is %u " |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1297 | " onTimePnoScan is %u onTimeHs20 is %u " |
| 1298 | " numChannels is %u", |
| 1299 | pWifiRadioStat->radio, pWifiRadioStat->onTime, |
| 1300 | pWifiRadioStat->txTime, pWifiRadioStat->rxTime, |
| 1301 | pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1302 | pWifiRadioStat->onTimeEXTScan, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1303 | pWifiRadioStat->onTimeRoamScan, |
| 1304 | pWifiRadioStat->onTimePnoScan, |
| 1305 | pWifiRadioStat->onTimeHs20, |
| 1306 | pWifiRadioStat->numChannels); |
| 1307 | /* |
| 1308 | * Allocate a size of 4096 for the Radio stats comprising |
| 1309 | * sizeof (tSirWifiRadioStat) + numChannels * sizeof |
| 1310 | * (tSirWifiChannelStats).Each channel data is put with an |
| 1311 | * NL attribute.The size of 4096 is considered assuming that |
| 1312 | * number of channels shall not exceed beyond 60 with the |
| 1313 | * sizeof (tSirWifiChannelStats) being 24 bytes. |
| 1314 | */ |
| 1315 | |
| 1316 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1317 | LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN , |
| 1318 | QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX, |
| 1319 | GFP_KERNEL); |
| 1320 | |
| 1321 | if (!vendor_event) |
| 1322 | { |
| 1323 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1324 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1325 | return; |
| 1326 | } |
| 1327 | |
| 1328 | if (nla_put_u32(vendor_event, |
| 1329 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID, |
| 1330 | pWifiRadioStat->radio) || |
| 1331 | nla_put_u32(vendor_event, |
| 1332 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME, |
| 1333 | pWifiRadioStat->onTime) || |
| 1334 | nla_put_u32(vendor_event, |
| 1335 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME, |
| 1336 | pWifiRadioStat->txTime) || |
| 1337 | nla_put_u32(vendor_event, |
| 1338 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME, |
| 1339 | pWifiRadioStat->rxTime) || |
| 1340 | nla_put_u32(vendor_event, |
| 1341 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN, |
| 1342 | pWifiRadioStat->onTimeScan) || |
| 1343 | nla_put_u32(vendor_event, |
| 1344 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD, |
| 1345 | pWifiRadioStat->onTimeNbd) || |
| 1346 | nla_put_u32(vendor_event, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1347 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN, |
| 1348 | pWifiRadioStat->onTimeEXTScan)|| |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1349 | nla_put_u32(vendor_event, |
| 1350 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN, |
| 1351 | pWifiRadioStat->onTimeRoamScan) || |
| 1352 | nla_put_u32(vendor_event, |
| 1353 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN, |
| 1354 | pWifiRadioStat->onTimePnoScan) || |
| 1355 | nla_put_u32(vendor_event, |
| 1356 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20, |
| 1357 | pWifiRadioStat->onTimeHs20) || |
| 1358 | nla_put_u32(vendor_event, |
| 1359 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS, |
| 1360 | pWifiRadioStat->numChannels)) |
| 1361 | { |
| 1362 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1363 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 1364 | kfree_skb(vendor_event); |
| 1365 | return ; |
| 1366 | } |
| 1367 | |
| 1368 | chList = nla_nest_start(vendor_event, |
| 1369 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO); |
| 1370 | for (i = 0; i < pWifiRadioStat->numChannels; i++) |
| 1371 | { |
| 1372 | struct nlattr *chInfo; |
| 1373 | |
| 1374 | pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*) |
| 1375 | pWifiRadioStat->channels + |
| 1376 | (i * sizeof(tSirWifiChannelStats))); |
| 1377 | |
| 1378 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1379 | " %d) Channel Info" |
| 1380 | " width is %u " |
| 1381 | " CenterFreq %u " |
| 1382 | " CenterFreq0 %u " |
| 1383 | " CenterFreq1 %u " |
| 1384 | " onTime %u " |
| 1385 | " ccaBusyTime %u", |
| 1386 | i, |
| 1387 | pWifiChannelStats->channel.width, |
| 1388 | pWifiChannelStats->channel.centerFreq, |
| 1389 | pWifiChannelStats->channel.centerFreq0, |
| 1390 | pWifiChannelStats->channel.centerFreq1, |
| 1391 | pWifiChannelStats->onTime, |
| 1392 | pWifiChannelStats->ccaBusyTime); |
| 1393 | |
| 1394 | |
| 1395 | chInfo = nla_nest_start(vendor_event, i); |
| 1396 | |
| 1397 | if (nla_put_u32(vendor_event, |
| 1398 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH, |
| 1399 | pWifiChannelStats->channel.width) || |
| 1400 | nla_put_u32(vendor_event, |
| 1401 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ, |
| 1402 | pWifiChannelStats->channel.centerFreq) || |
| 1403 | nla_put_u32(vendor_event, |
| 1404 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0, |
| 1405 | pWifiChannelStats->channel.centerFreq0) || |
| 1406 | nla_put_u32(vendor_event, |
| 1407 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1, |
| 1408 | pWifiChannelStats->channel.centerFreq1) || |
| 1409 | nla_put_u32(vendor_event, |
| 1410 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME, |
| 1411 | pWifiChannelStats->onTime) || |
| 1412 | nla_put_u32(vendor_event, |
| 1413 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME, |
| 1414 | pWifiChannelStats->ccaBusyTime)) |
| 1415 | { |
| 1416 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1417 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1418 | kfree_skb(vendor_event); |
| 1419 | return ; |
| 1420 | } |
| 1421 | nla_nest_end(vendor_event, chInfo); |
| 1422 | } |
| 1423 | nla_nest_end(vendor_event, chList); |
| 1424 | |
| 1425 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1426 | return; |
| 1427 | } |
| 1428 | |
| 1429 | /* |
| 1430 | * hdd_link_layer_stats_ind_callback () - This function is called after |
| 1431 | * receiving Link Layer indications from FW.This callback converts the firmware |
| 1432 | * data to the NL data and send the same to the kernel/upper layers. |
| 1433 | */ |
| 1434 | static void hdd_link_layer_stats_ind_callback ( void *pCtx, |
| 1435 | int indType, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1436 | void *pRsp, u8 *macAddr) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1437 | { |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1438 | hdd_context_t *pHddCtx = (hdd_context_t *)pCtx; |
| 1439 | hdd_adapter_t *pAdapter = NULL; |
| 1440 | tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1441 | int status; |
| 1442 | |
| 1443 | status = wlan_hdd_validate_context(pHddCtx); |
| 1444 | |
| 1445 | if (0 != status) |
| 1446 | { |
| 1447 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1448 | FL("HDD context is not valid")); |
| 1449 | return; |
| 1450 | } |
| 1451 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1452 | |
| 1453 | |
| 1454 | pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr); |
| 1455 | if (NULL == pAdapter) |
| 1456 | { |
| 1457 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1458 | FL(" MAC address %pM does not exist with host"), |
| 1459 | macAddr); |
| 1460 | return; |
| 1461 | } |
| 1462 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1463 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1464 | "%s: Interface: %s LLStats indType: %d", __func__, |
| 1465 | pAdapter->dev->name, indType); |
| 1466 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1467 | switch (indType) |
| 1468 | { |
| 1469 | case SIR_HAL_LL_STATS_RESULTS_RSP: |
| 1470 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1471 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1472 | FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") ); |
| 1473 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1474 | "LL_STATS RESULTS RESPONSE paramID = 0x%x", |
| 1475 | linkLayerStatsResults->paramId); |
| 1476 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1477 | "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM", |
| 1478 | linkLayerStatsResults->ifaceId, macAddr); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1479 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1480 | "LL_STATS RESULTS RESPONSE respId = %u", |
| 1481 | linkLayerStatsResults->respId); |
| 1482 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1483 | "LL_STATS RESULTS RESPONSE moreResultToFollow = %u", |
| 1484 | linkLayerStatsResults->moreResultToFollow); |
| 1485 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1486 | "LL_STATS RESULTS RESPONSE result = %p", |
| 1487 | linkLayerStatsResults->result); |
| 1488 | if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO ) |
| 1489 | { |
| 1490 | hdd_link_layer_process_radio_stats(pAdapter, |
| 1491 | (v_VOID_t *)linkLayerStatsResults->result); |
| 1492 | } |
| 1493 | else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE ) |
| 1494 | { |
| 1495 | hdd_link_layer_process_iface_stats(pAdapter, |
| 1496 | (v_VOID_t *)linkLayerStatsResults->result); |
| 1497 | } |
| 1498 | else if ( linkLayerStatsResults->paramId & |
| 1499 | WMI_LINK_STATS_ALL_PEER ) |
| 1500 | { |
| 1501 | hdd_link_layer_process_peer_stats(pAdapter, |
| 1502 | (v_VOID_t *)linkLayerStatsResults->result); |
| 1503 | } /* WMI_LINK_STATS_ALL_PEER */ |
| 1504 | else |
| 1505 | { |
| 1506 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1507 | FL("INVALID LL_STATS_NOTIFY RESPONSE ***********")); |
| 1508 | } |
| 1509 | |
| 1510 | break; |
| 1511 | } |
| 1512 | default: |
| 1513 | hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType); |
| 1514 | break; |
| 1515 | } |
| 1516 | return; |
| 1517 | } |
| 1518 | |
| 1519 | const struct |
| 1520 | nla_policy |
| 1521 | qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] = |
| 1522 | { |
| 1523 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] = |
| 1524 | { .type = NLA_U32 }, |
| 1525 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] = |
| 1526 | { .type = NLA_U32 }, |
| 1527 | }; |
| 1528 | |
| 1529 | static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy, |
| 1530 | struct wireless_dev *wdev, |
| 1531 | void *data, |
| 1532 | int data_len) |
| 1533 | { |
| 1534 | int status; |
| 1535 | 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] | 1536 | tSirLLStatsSetReq linkLayerStatsSetReq; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1537 | struct net_device *dev = wdev->netdev; |
| 1538 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1539 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1540 | |
| 1541 | status = wlan_hdd_validate_context(pHddCtx); |
| 1542 | if (0 != status) |
| 1543 | { |
| 1544 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1545 | FL("HDD context is not valid")); |
| 1546 | return -EINVAL; |
| 1547 | } |
| 1548 | |
| 1549 | if (NULL == pAdapter) |
| 1550 | { |
| 1551 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1552 | FL("HDD adapter is Null")); |
| 1553 | return -ENODEV; |
| 1554 | } |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1555 | /* check the LLStats Capability */ |
| 1556 | if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) || |
| 1557 | (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) |
| 1558 | { |
| 1559 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1560 | FL("Link Layer Statistics not supported by Firmware")); |
| 1561 | return -EINVAL; |
| 1562 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1563 | |
| 1564 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX, |
| 1565 | (struct nlattr *)data, |
| 1566 | data_len, qca_wlan_vendor_ll_set_policy)) |
| 1567 | { |
| 1568 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1569 | return -EINVAL; |
| 1570 | } |
| 1571 | if (!tb_vendor |
| 1572 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]) |
| 1573 | { |
| 1574 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present")); |
| 1575 | return -EINVAL; |
| 1576 | } |
| 1577 | if (!tb_vendor[ |
| 1578 | QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]) |
| 1579 | { |
| 1580 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present")); |
| 1581 | return -EINVAL; |
| 1582 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1583 | // 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] | 1584 | linkLayerStatsSetReq.reqId = 1; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1585 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1586 | linkLayerStatsSetReq.mpduSizeThreshold = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1587 | nla_get_u32( |
| 1588 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]); |
| 1589 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1590 | linkLayerStatsSetReq.aggressiveStatisticsGathering = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1591 | nla_get_u32( |
| 1592 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]); |
| 1593 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1594 | vos_mem_copy(linkLayerStatsSetReq.macAddr, |
| 1595 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1596 | |
| 1597 | |
| 1598 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1599 | "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1600 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1601 | "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1602 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1603 | "LL_STATS_SET mpduSizeThreshold = %d", |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1604 | linkLayerStatsSetReq.mpduSizeThreshold); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1605 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1606 | "LL_STATS_SET aggressive Statistics Gathering = %d", |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1607 | linkLayerStatsSetReq.aggressiveStatisticsGathering); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1608 | |
| 1609 | if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB( |
| 1610 | pHddCtx->hHal, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1611 | hdd_link_layer_stats_ind_callback)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1612 | { |
| 1613 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1614 | "sme_SetLinkLayerStatsIndCB Failed", __func__); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1615 | return -EINVAL; |
| 1616 | |
| 1617 | } |
| 1618 | if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1619 | &linkLayerStatsSetReq)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1620 | { |
| 1621 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1622 | "sme_LLStatsSetReq Failed", __func__); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1623 | return -EINVAL; |
| 1624 | } |
| 1625 | |
| 1626 | pAdapter->isLinkLayerStatsSet = 1; |
| 1627 | |
| 1628 | return 0; |
| 1629 | } |
| 1630 | |
| 1631 | const struct |
| 1632 | nla_policy |
| 1633 | qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] = |
| 1634 | { |
| 1635 | /* Unsigned 32bit value provided by the caller issuing the GET stats |
| 1636 | * command. When reporting |
| 1637 | * the stats results, the driver uses the same value to indicate |
| 1638 | * which GET request the results |
| 1639 | * correspond to. |
| 1640 | */ |
| 1641 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 }, |
| 1642 | |
| 1643 | /* Unsigned 32bit value . bit mask to identify what statistics are |
| 1644 | requested for retrieval */ |
| 1645 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 }, |
| 1646 | }; |
| 1647 | |
| 1648 | static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy, |
| 1649 | struct wireless_dev *wdev, |
| 1650 | void *data, |
| 1651 | int data_len) |
| 1652 | { |
| 1653 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1654 | 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] | 1655 | tSirLLStatsGetReq linkLayerStatsGetReq; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1656 | struct net_device *dev = wdev->netdev; |
| 1657 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1658 | int status; |
| 1659 | |
| 1660 | status = wlan_hdd_validate_context(pHddCtx); |
| 1661 | if (0 != status) |
| 1662 | { |
| 1663 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1664 | FL("HDD context is not valid")); |
| 1665 | return -EINVAL ; |
| 1666 | } |
| 1667 | |
| 1668 | if (NULL == pAdapter) |
| 1669 | { |
| 1670 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1671 | "%s: HDD adapter is Null", __func__); |
| 1672 | return -ENODEV; |
| 1673 | } |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1674 | /* check the LLStats Capability */ |
| 1675 | if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) || |
| 1676 | (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) |
| 1677 | { |
| 1678 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1679 | FL("Link Layer Statistics not supported by Firmware")); |
| 1680 | return -EINVAL; |
| 1681 | } |
| 1682 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1683 | |
| 1684 | if (!pAdapter->isLinkLayerStatsSet) |
| 1685 | { |
| 1686 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1687 | "%s: isLinkLayerStatsSet : %d", |
| 1688 | __func__, pAdapter->isLinkLayerStatsSet); |
| 1689 | return -EINVAL; |
| 1690 | } |
| 1691 | |
| 1692 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX, |
| 1693 | (struct nlattr *)data, |
| 1694 | data_len, qca_wlan_vendor_ll_get_policy)) |
| 1695 | { |
| 1696 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1697 | return -EINVAL; |
| 1698 | } |
| 1699 | |
| 1700 | if (!tb_vendor |
| 1701 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]) |
| 1702 | { |
| 1703 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present")); |
| 1704 | return -EINVAL; |
| 1705 | } |
| 1706 | |
| 1707 | if (!tb_vendor |
| 1708 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]) |
| 1709 | { |
| 1710 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present")); |
| 1711 | return -EINVAL; |
| 1712 | } |
| 1713 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1714 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1715 | linkLayerStatsGetReq.reqId = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1716 | nla_get_u32( tb_vendor[ |
| 1717 | QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]); |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1718 | linkLayerStatsGetReq.paramIdMask = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1719 | nla_get_u32( tb_vendor[ |
| 1720 | QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]); |
| 1721 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1722 | vos_mem_copy(linkLayerStatsGetReq.macAddr, |
| 1723 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1724 | |
| 1725 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1726 | "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1727 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1728 | "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1729 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1730 | "LL_STATS_GET paramIdMask = %d", |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1731 | linkLayerStatsGetReq.paramIdMask); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1732 | |
| 1733 | if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1734 | &linkLayerStatsGetReq)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1735 | { |
| 1736 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1737 | "sme_LLStatsGetReq Failed", __func__); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1738 | return -EINVAL; |
| 1739 | } |
| 1740 | return 0; |
| 1741 | } |
| 1742 | |
| 1743 | const struct |
| 1744 | nla_policy |
| 1745 | qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] = |
| 1746 | { |
| 1747 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 }, |
| 1748 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 }, |
| 1749 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 }, |
| 1750 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 }, |
| 1751 | }; |
| 1752 | |
| 1753 | static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy, |
| 1754 | struct wireless_dev *wdev, |
| 1755 | void *data, |
| 1756 | int data_len) |
| 1757 | { |
| 1758 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1759 | 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] | 1760 | tSirLLStatsClearReq linkLayerStatsClearReq; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1761 | struct net_device *dev = wdev->netdev; |
| 1762 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1763 | u32 statsClearReqMask; |
| 1764 | u8 stopReq; |
| 1765 | int status; |
| 1766 | |
| 1767 | status = wlan_hdd_validate_context(pHddCtx); |
| 1768 | if (0 != status) |
| 1769 | { |
| 1770 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1771 | FL("HDD context is not valid")); |
| 1772 | return -EINVAL; |
| 1773 | } |
| 1774 | |
| 1775 | if (NULL == pAdapter) |
| 1776 | { |
| 1777 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1778 | "%s: HDD adapter is Null", __func__); |
| 1779 | return -ENODEV; |
| 1780 | } |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1781 | /* check the LLStats Capability */ |
| 1782 | if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) || |
| 1783 | (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS))) |
| 1784 | { |
| 1785 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1786 | FL("Enable LLStats Capability")); |
| 1787 | return -EINVAL; |
| 1788 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1789 | |
| 1790 | if (!pAdapter->isLinkLayerStatsSet) |
| 1791 | { |
| 1792 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1793 | "%s: isLinkLayerStatsSet : %d", |
| 1794 | __func__, pAdapter->isLinkLayerStatsSet); |
| 1795 | return -EINVAL; |
| 1796 | } |
| 1797 | |
| 1798 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX, |
| 1799 | (struct nlattr *)data, |
| 1800 | data_len, qca_wlan_vendor_ll_clr_policy)) |
| 1801 | { |
| 1802 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1803 | return -EINVAL; |
| 1804 | } |
| 1805 | |
| 1806 | if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] || |
| 1807 | |
| 1808 | !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]) |
| 1809 | { |
| 1810 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") ); |
| 1811 | return -EINVAL; |
| 1812 | |
| 1813 | } |
| 1814 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1815 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1816 | statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1817 | nla_get_u32( |
| 1818 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]); |
| 1819 | |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1820 | stopReq = linkLayerStatsClearReq.stopReq = |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1821 | nla_get_u8( |
| 1822 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]); |
| 1823 | |
| 1824 | // 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] | 1825 | linkLayerStatsClearReq.reqId = 1; |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1826 | |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1827 | vos_mem_copy(linkLayerStatsClearReq.macAddr, |
| 1828 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1829 | |
| 1830 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1831 | "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1832 | hddLog(VOS_TRACE_LEVEL_INFO, |
Dino Mycle | d3d5002 | 2014-07-07 12:58:25 +0530 | [diff] [blame] | 1833 | "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1834 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1835 | "LL_STATS_CLEAR statsClearReqMask = 0x%X", |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1836 | linkLayerStatsClearReq.statsClearReqMask); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1837 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1838 | "LL_STATS_CLEAR stopReq = %d", |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1839 | linkLayerStatsClearReq.stopReq); |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1840 | |
| 1841 | if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal, |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1842 | &linkLayerStatsClearReq)) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1843 | { |
| 1844 | struct sk_buff *temp_skbuff; |
| 1845 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 1846 | 2 * sizeof(u32) + |
| 1847 | NLMSG_HDRLEN); |
| 1848 | |
| 1849 | if (temp_skbuff != NULL) |
| 1850 | { |
| 1851 | |
| 1852 | if (nla_put_u32(temp_skbuff, |
| 1853 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK, |
| 1854 | statsClearReqMask) || |
| 1855 | nla_put_u32(temp_skbuff, |
| 1856 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP, |
| 1857 | stopReq)) |
| 1858 | { |
| 1859 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail")); |
| 1860 | kfree_skb(temp_skbuff); |
| 1861 | return -EINVAL; |
| 1862 | } |
| 1863 | /* If the ask is to stop the stats collection as part of clear |
| 1864 | * (stopReq = 1) , ensure that no further requests of get |
| 1865 | * go to the firmware by having isLinkLayerStatsSet set to 0. |
| 1866 | * However it the stopReq as part of the clear request is 0 , |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1867 | * the request to get the statistics are honoured as in this |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1868 | * case the firmware is just asked to clear the statistics. |
| 1869 | */ |
Dino Mycle | df0a5d9 | 2014-07-04 09:41:55 +0530 | [diff] [blame] | 1870 | if (linkLayerStatsClearReq.stopReq == 1) |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1871 | pAdapter->isLinkLayerStatsSet = 0; |
| 1872 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 1873 | } |
| 1874 | return -ENOMEM; |
| 1875 | } |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1876 | return -EINVAL; |
| 1877 | } |
| 1878 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1879 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 1880 | #ifdef WLAN_FEATURE_EXTSCAN |
| 1881 | static const struct nla_policy |
| 1882 | wlan_hdd_extscan_config_policy |
| 1883 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] = |
| 1884 | { |
| 1885 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] = |
| 1886 | { .type = NLA_U32 }, |
| 1887 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] = |
| 1888 | { .type = NLA_U32 }, |
| 1889 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 }, |
| 1890 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] = |
| 1891 | { .type = NLA_U32 }, |
| 1892 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 }, |
| 1893 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 }, |
| 1894 | |
| 1895 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 }, |
| 1896 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 }, |
| 1897 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 }, |
| 1898 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] = |
| 1899 | { .type = NLA_U8 }, |
| 1900 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] = |
| 1901 | { .type = NLA_U32 }, |
| 1902 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] = |
| 1903 | { .type = NLA_U32 }, |
| 1904 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] = |
| 1905 | { .type = NLA_U32 }, |
| 1906 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] = |
| 1907 | { .type = NLA_U8 }, |
| 1908 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] = |
| 1909 | { .type = NLA_U8 }, |
| 1910 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] = |
| 1911 | { .type = NLA_U8 }, |
| 1912 | |
| 1913 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] = |
| 1914 | { .type = NLA_U32 }, |
| 1915 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] = |
| 1916 | { .type = NLA_UNSPEC }, |
| 1917 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] = |
| 1918 | { .type = NLA_S32 }, |
| 1919 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] = |
| 1920 | { .type = NLA_S32 }, |
| 1921 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] = |
| 1922 | { .type = NLA_U32 }, |
| 1923 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] = |
| 1924 | { .type = NLA_U32 }, |
| 1925 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] = |
| 1926 | { .type = NLA_U32 }, |
| 1927 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE] |
| 1928 | = { .type = NLA_U32 }, |
| 1929 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] = |
| 1930 | { .type = NLA_U32 }, |
| 1931 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type = |
| 1932 | NLA_U32 }, |
| 1933 | }; |
| 1934 | |
| 1935 | static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg) |
| 1936 | { |
| 1937 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 1938 | struct sk_buff *skb = NULL; |
| 1939 | tpSirEXTScanCapabilitiesEvent pData = |
| 1940 | (tpSirEXTScanCapabilitiesEvent) pMsg; |
| 1941 | |
| 1942 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 1943 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 1944 | "or pData(%p) is null"), pData); |
| 1945 | return; |
| 1946 | } |
| 1947 | |
| 1948 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1949 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 1950 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX, |
| 1951 | GFP_KERNEL); |
| 1952 | |
| 1953 | if (!skb) { |
| 1954 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1955 | FL("cfg80211_vendor_event_alloc failed")); |
| 1956 | return; |
| 1957 | } |
| 1958 | |
| 1959 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 1960 | hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize); |
| 1961 | hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets); |
| 1962 | hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan); |
| 1963 | hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)", |
| 1964 | pData->maxRssiSampleSize); |
| 1965 | hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)", |
| 1966 | pData->maxScanReportingThreshold); |
| 1967 | hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs); |
| 1968 | hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)", |
| 1969 | pData->maxSignificantWifiChangeAPs); |
| 1970 | hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)", |
| 1971 | pData->maxBsidHistoryEntries); |
| 1972 | |
| 1973 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 1974 | pData->requestId) || |
| 1975 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) || |
| 1976 | nla_put_u32(skb, |
| 1977 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE, |
| 1978 | pData->scanCacheSize) || |
| 1979 | nla_put_u32(skb, |
| 1980 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS, |
| 1981 | pData->scanBuckets) || |
| 1982 | nla_put_u32(skb, |
| 1983 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN, |
| 1984 | pData->maxApPerScan) || |
| 1985 | nla_put_u32(skb, |
| 1986 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE, |
| 1987 | pData->maxRssiSampleSize) || |
| 1988 | nla_put_u32(skb, |
| 1989 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD, |
| 1990 | pData->maxScanReportingThreshold) || |
| 1991 | nla_put_u32(skb, |
| 1992 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS, |
| 1993 | pData->maxHotlistAPs) || |
| 1994 | nla_put_u32(skb, |
| 1995 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS, |
| 1996 | pData->maxSignificantWifiChangeAPs) || |
| 1997 | nla_put_u32(skb, |
| 1998 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES, |
| 1999 | pData->maxBsidHistoryEntries)) { |
| 2000 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2001 | goto nla_put_failure; |
| 2002 | } |
| 2003 | |
| 2004 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2005 | return; |
| 2006 | |
| 2007 | nla_put_failure: |
| 2008 | kfree_skb(skb); |
| 2009 | return; |
| 2010 | } |
| 2011 | |
| 2012 | |
| 2013 | static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg) |
| 2014 | { |
| 2015 | tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg; |
| 2016 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2017 | struct sk_buff *skb = NULL; |
| 2018 | tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal ); |
| 2019 | |
| 2020 | |
| 2021 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2022 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2023 | "or pData(%p) is null"), pData); |
| 2024 | return; |
| 2025 | } |
| 2026 | |
| 2027 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2028 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2029 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX, |
| 2030 | GFP_KERNEL); |
| 2031 | |
| 2032 | if (!skb) { |
| 2033 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2034 | FL("cfg80211_vendor_event_alloc failed")); |
| 2035 | return; |
| 2036 | } |
| 2037 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2038 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2039 | hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status); |
| 2040 | |
| 2041 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2042 | pData->requestId) || |
| 2043 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) { |
| 2044 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2045 | goto nla_put_failure; |
| 2046 | } |
| 2047 | |
| 2048 | /* |
| 2049 | * Store the Request ID for comparing with the requestID obtained |
| 2050 | * in other requests.HDD shall return a failure is the extscan_stop |
| 2051 | * request is issued with a different requestId as that of the |
| 2052 | * extscan_start request. Also, This requestId shall be used while |
| 2053 | * indicating the full scan results to the upper layers. |
| 2054 | * The requestId is stored with the assumption that the firmware |
| 2055 | * shall return the ext scan start request's requestId in ext scan |
| 2056 | * start response. |
| 2057 | */ |
| 2058 | if (pData->status == 0) |
| 2059 | pMac->sme.extScanStartReqId = pData->requestId; |
| 2060 | |
| 2061 | |
| 2062 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2063 | return; |
| 2064 | |
| 2065 | nla_put_failure: |
| 2066 | kfree_skb(skb); |
| 2067 | return; |
| 2068 | } |
| 2069 | |
| 2070 | |
| 2071 | static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg) |
| 2072 | { |
| 2073 | tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg; |
| 2074 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2075 | struct sk_buff *skb = NULL; |
| 2076 | |
| 2077 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2078 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2079 | "or pData(%p) is null"), pData); |
| 2080 | return; |
| 2081 | } |
| 2082 | |
| 2083 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2084 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2085 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX, |
| 2086 | GFP_KERNEL); |
| 2087 | |
| 2088 | if (!skb) { |
| 2089 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2090 | FL("cfg80211_vendor_event_alloc failed")); |
| 2091 | return; |
| 2092 | } |
| 2093 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2094 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2095 | |
| 2096 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2097 | pData->requestId) || |
| 2098 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) { |
| 2099 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2100 | goto nla_put_failure; |
| 2101 | } |
| 2102 | |
| 2103 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2104 | return; |
| 2105 | |
| 2106 | nla_put_failure: |
| 2107 | kfree_skb(skb); |
| 2108 | return; |
| 2109 | } |
| 2110 | |
| 2111 | |
| 2112 | static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx, |
| 2113 | void *pMsg) |
| 2114 | { |
| 2115 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2116 | struct sk_buff *skb = NULL; |
| 2117 | tpSirEXTScanSetBssidHotListRspParams pData = |
| 2118 | (tpSirEXTScanSetBssidHotListRspParams) pMsg; |
| 2119 | |
| 2120 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2121 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2122 | "or pData(%p) is null"), pData); |
| 2123 | return; |
| 2124 | } |
| 2125 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2126 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2127 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX, |
| 2128 | GFP_KERNEL); |
| 2129 | |
| 2130 | if (!skb) { |
| 2131 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2132 | FL("cfg80211_vendor_event_alloc failed")); |
| 2133 | return; |
| 2134 | } |
| 2135 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2136 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2137 | hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status); |
| 2138 | |
| 2139 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2140 | pData->requestId) || |
| 2141 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) { |
| 2142 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2143 | goto nla_put_failure; |
| 2144 | } |
| 2145 | |
| 2146 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2147 | return; |
| 2148 | |
| 2149 | nla_put_failure: |
| 2150 | kfree_skb(skb); |
| 2151 | return; |
| 2152 | } |
| 2153 | |
| 2154 | static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx, |
| 2155 | void *pMsg) |
| 2156 | { |
| 2157 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2158 | struct sk_buff *skb = NULL; |
| 2159 | tpSirEXTScanResetBssidHotlistRspParams pData = |
| 2160 | (tpSirEXTScanResetBssidHotlistRspParams) pMsg; |
| 2161 | |
| 2162 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2163 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2164 | "or pData(%p) is null"), pData); |
| 2165 | return; |
| 2166 | } |
| 2167 | |
| 2168 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2169 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2170 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX, |
| 2171 | GFP_KERNEL); |
| 2172 | |
| 2173 | if (!skb) { |
| 2174 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2175 | FL("cfg80211_vendor_event_alloc failed")); |
| 2176 | return; |
| 2177 | } |
| 2178 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2179 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2180 | |
| 2181 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2182 | pData->requestId) || |
| 2183 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) { |
| 2184 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2185 | goto nla_put_failure; |
| 2186 | } |
| 2187 | |
| 2188 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2189 | return; |
| 2190 | |
| 2191 | nla_put_failure: |
| 2192 | kfree_skb(skb); |
| 2193 | return; |
| 2194 | } |
| 2195 | |
| 2196 | |
| 2197 | static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx, |
| 2198 | void *pMsg) |
| 2199 | { |
| 2200 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2201 | struct sk_buff *skb = NULL; |
| 2202 | tpSirEXTScanSetSignificantChangeRspParams pData = |
| 2203 | (tpSirEXTScanSetSignificantChangeRspParams) pMsg; |
| 2204 | |
| 2205 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2206 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2207 | "or pData(%p) is null"), pData); |
| 2208 | return; |
| 2209 | } |
| 2210 | |
| 2211 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2212 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2213 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX, |
| 2214 | GFP_KERNEL); |
| 2215 | |
| 2216 | if (!skb) { |
| 2217 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2218 | FL("cfg80211_vendor_event_alloc failed")); |
| 2219 | return; |
| 2220 | } |
| 2221 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2222 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2223 | hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status); |
| 2224 | |
| 2225 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2226 | pData->requestId) || |
| 2227 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) { |
| 2228 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2229 | goto nla_put_failure; |
| 2230 | } |
| 2231 | |
| 2232 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2233 | return; |
| 2234 | |
| 2235 | nla_put_failure: |
| 2236 | kfree_skb(skb); |
| 2237 | return; |
| 2238 | } |
| 2239 | |
| 2240 | |
| 2241 | static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx, |
| 2242 | void *pMsg) |
| 2243 | { |
| 2244 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2245 | struct sk_buff *skb = NULL; |
| 2246 | tpSirEXTScanResetSignificantChangeRspParams pData = |
| 2247 | (tpSirEXTScanResetSignificantChangeRspParams) pMsg; |
| 2248 | |
| 2249 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2250 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2251 | "or pData(%p) is null"), pData); |
| 2252 | return; |
| 2253 | } |
| 2254 | |
| 2255 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2256 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2257 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX, |
| 2258 | GFP_KERNEL); |
| 2259 | |
| 2260 | if (!skb) { |
| 2261 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2262 | FL("cfg80211_vendor_event_alloc failed")); |
| 2263 | return; |
| 2264 | } |
| 2265 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2266 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2267 | hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status); |
| 2268 | |
| 2269 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2270 | pData->requestId) || |
| 2271 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) { |
| 2272 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2273 | goto nla_put_failure; |
| 2274 | } |
| 2275 | |
| 2276 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2277 | return; |
| 2278 | |
| 2279 | nla_put_failure: |
| 2280 | kfree_skb(skb); |
| 2281 | return; |
| 2282 | } |
| 2283 | |
| 2284 | static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx, |
| 2285 | void *pMsg) |
| 2286 | { |
| 2287 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2288 | struct sk_buff *skb = NULL; |
| 2289 | tANI_U32 i = 0, j, resultsPerEvent; |
| 2290 | tANI_S32 totalResults; |
| 2291 | tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg; |
| 2292 | tpSirWifiScanResult pSirWifiScanResult; |
| 2293 | |
| 2294 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2295 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2296 | "or pData(%p) is null"), pData); |
| 2297 | return; |
| 2298 | } |
| 2299 | totalResults = pData->numOfAps; |
| 2300 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2301 | hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps); |
| 2302 | hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData); |
| 2303 | |
| 2304 | do{ |
| 2305 | resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ? |
| 2306 | EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults); |
| 2307 | totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND; |
| 2308 | |
| 2309 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2310 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2311 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX, |
| 2312 | GFP_KERNEL); |
| 2313 | |
| 2314 | if (!skb) { |
| 2315 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2316 | FL("cfg80211_vendor_event_alloc failed")); |
| 2317 | return; |
| 2318 | } |
| 2319 | |
| 2320 | hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent); |
| 2321 | |
| 2322 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2323 | pData->requestId) || |
| 2324 | nla_put_u32(skb, |
| 2325 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 2326 | resultsPerEvent)) { |
| 2327 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2328 | goto fail; |
| 2329 | } |
| 2330 | if (nla_put_u8(skb, |
| 2331 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA, |
| 2332 | pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 ))) |
| 2333 | { |
| 2334 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2335 | goto fail; |
| 2336 | } |
| 2337 | |
| 2338 | if (resultsPerEvent) { |
| 2339 | struct nlattr *aps; |
| 2340 | |
| 2341 | aps = nla_nest_start(skb, |
| 2342 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST); |
| 2343 | if (!aps) |
| 2344 | { |
| 2345 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2346 | goto fail; |
| 2347 | } |
| 2348 | |
| 2349 | for (j = 0; j < resultsPerEvent; j++, i++) { |
| 2350 | struct nlattr *ap; |
| 2351 | pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *) |
| 2352 | pData->ap + ( i* sizeof(tSirWifiScanResult))); |
| 2353 | |
| 2354 | hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) " |
| 2355 | "Ssid (%s)" |
| 2356 | "Bssid: %pM " |
| 2357 | "Channel (%u)" |
| 2358 | "Rssi (%d)" |
| 2359 | "RTT (%u)" |
| 2360 | "RTT_SD (%u)", |
| 2361 | i, |
| 2362 | pSirWifiScanResult->ts, |
| 2363 | pSirWifiScanResult->ssid, |
| 2364 | pSirWifiScanResult->bssid, |
| 2365 | pSirWifiScanResult->channel, |
| 2366 | pSirWifiScanResult->rssi, |
| 2367 | pSirWifiScanResult->rtt, |
| 2368 | pSirWifiScanResult->rtt_sd); |
| 2369 | |
| 2370 | ap = nla_nest_start(skb, j + 1); |
| 2371 | if (!ap) |
| 2372 | { |
| 2373 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2374 | goto fail; |
| 2375 | } |
| 2376 | |
| 2377 | if (nla_put_u64(skb, |
| 2378 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP, |
| 2379 | pSirWifiScanResult->ts) ) |
| 2380 | { |
| 2381 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2382 | goto fail; |
| 2383 | } |
| 2384 | if (nla_put(skb, |
| 2385 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID, |
| 2386 | sizeof(pSirWifiScanResult->ssid), |
| 2387 | pSirWifiScanResult->ssid) ) |
| 2388 | { |
| 2389 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2390 | goto fail; |
| 2391 | } |
| 2392 | if (nla_put(skb, |
| 2393 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID, |
| 2394 | sizeof(pSirWifiScanResult->bssid), |
| 2395 | pSirWifiScanResult->bssid) ) |
| 2396 | { |
| 2397 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2398 | goto fail; |
| 2399 | } |
| 2400 | if (nla_put_u32(skb, |
| 2401 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL, |
| 2402 | pSirWifiScanResult->channel) ) |
| 2403 | { |
| 2404 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2405 | goto fail; |
| 2406 | } |
| 2407 | if (nla_put_u32(skb, |
| 2408 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI, |
| 2409 | pSirWifiScanResult->rssi) ) |
| 2410 | { |
| 2411 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2412 | goto fail; |
| 2413 | } |
| 2414 | if (nla_put_u32(skb, |
| 2415 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT, |
| 2416 | pSirWifiScanResult->rtt) ) |
| 2417 | { |
| 2418 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2419 | goto fail; |
| 2420 | } |
| 2421 | if (nla_put_u32(skb, |
| 2422 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD, |
| 2423 | pSirWifiScanResult->rtt_sd)) |
| 2424 | { |
| 2425 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2426 | goto fail; |
| 2427 | } |
| 2428 | |
| 2429 | nla_nest_end(skb, ap); |
| 2430 | } |
| 2431 | nla_nest_end(skb, aps); |
| 2432 | |
| 2433 | } |
| 2434 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2435 | } while (totalResults > 0); |
| 2436 | |
| 2437 | return; |
| 2438 | fail: |
| 2439 | kfree_skb(skb); |
| 2440 | return; |
| 2441 | } |
| 2442 | |
| 2443 | static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx, |
| 2444 | void *pMsg) |
| 2445 | { |
| 2446 | tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg; |
| 2447 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2448 | struct sk_buff *skb = NULL; |
| 2449 | tANI_U32 i; |
| 2450 | |
| 2451 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2452 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2453 | "or pData(%p) is null"), pData); |
| 2454 | return; |
| 2455 | } |
| 2456 | |
| 2457 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2458 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2459 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX, |
| 2460 | GFP_KERNEL); |
| 2461 | |
| 2462 | if (!skb) { |
| 2463 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2464 | FL("cfg80211_vendor_event_alloc failed")); |
| 2465 | return; |
| 2466 | } |
| 2467 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2468 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2469 | hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps); |
| 2470 | hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData); |
| 2471 | |
| 2472 | for (i = 0; i < pData->numOfAps; i++) { |
| 2473 | hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) " |
| 2474 | "Ssid (%s) " |
| 2475 | "Bssid (" MAC_ADDRESS_STR ") " |
| 2476 | "Channel (%u) " |
| 2477 | "Rssi (%d) " |
| 2478 | "RTT (%u) " |
| 2479 | "RTT_SD (%u) ", |
| 2480 | i, |
| 2481 | pData->ap[i].ts, |
| 2482 | pData->ap[i].ssid, |
| 2483 | MAC_ADDR_ARRAY(pData->ap[i].bssid), |
| 2484 | pData->ap[i].channel, |
| 2485 | pData->ap[i].rssi, |
| 2486 | pData->ap[i].rtt, |
| 2487 | pData->ap[i].rtt_sd); |
| 2488 | } |
| 2489 | |
| 2490 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2491 | pData->requestId) || |
| 2492 | nla_put_u32(skb, |
| 2493 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 2494 | pData->numOfAps)) { |
| 2495 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2496 | goto fail; |
| 2497 | } |
| 2498 | if (pData->numOfAps) { |
| 2499 | struct nlattr *aps; |
| 2500 | |
| 2501 | aps = nla_nest_start(skb, |
| 2502 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST); |
| 2503 | if (!aps) |
| 2504 | goto fail; |
| 2505 | |
| 2506 | for (i = 0; i < pData->numOfAps; i++) { |
| 2507 | struct nlattr *ap; |
| 2508 | |
| 2509 | ap = nla_nest_start(skb, i + 1); |
| 2510 | if (!ap) |
| 2511 | goto fail; |
| 2512 | |
| 2513 | if (nla_put_u64(skb, |
| 2514 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP, |
| 2515 | pData->ap[i].ts) || |
| 2516 | nla_put(skb, |
| 2517 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID, |
| 2518 | sizeof(pData->ap[i].ssid), |
| 2519 | pData->ap[i].ssid) || |
| 2520 | nla_put(skb, |
| 2521 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID, |
| 2522 | sizeof(pData->ap[i].bssid), |
| 2523 | pData->ap[i].bssid) || |
| 2524 | nla_put_u32(skb, |
| 2525 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL, |
| 2526 | pData->ap[i].channel) || |
| 2527 | nla_put_s32(skb, |
| 2528 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI, |
| 2529 | pData->ap[i].rssi) || |
| 2530 | nla_put_u32(skb, |
| 2531 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT, |
| 2532 | pData->ap[i].rtt) || |
| 2533 | nla_put_u32(skb, |
| 2534 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD, |
| 2535 | pData->ap[i].rtt_sd)) |
| 2536 | goto fail; |
| 2537 | |
| 2538 | nla_nest_end(skb, ap); |
| 2539 | } |
| 2540 | nla_nest_end(skb, aps); |
| 2541 | |
| 2542 | if (nla_put_u8(skb, |
| 2543 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA, |
| 2544 | pData->moreData)) |
| 2545 | goto fail; |
| 2546 | } |
| 2547 | |
| 2548 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2549 | return; |
| 2550 | |
| 2551 | fail: |
| 2552 | kfree_skb(skb); |
| 2553 | return; |
| 2554 | |
| 2555 | } |
| 2556 | static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx, |
| 2557 | void *pMsg) |
| 2558 | { |
| 2559 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2560 | struct sk_buff *skb = NULL; |
| 2561 | tANI_U32 i, j; |
| 2562 | tpSirWifiSignificantChangeEvent pData = |
| 2563 | (tpSirWifiSignificantChangeEvent) pMsg; |
| 2564 | |
| 2565 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2566 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2567 | "or pData(%p) is null"), pData); |
| 2568 | return; |
| 2569 | } |
| 2570 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2571 | EXTSCAN_EVENT_BUF_SIZE, |
| 2572 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX, |
| 2573 | GFP_KERNEL); |
| 2574 | |
| 2575 | if (!skb) { |
| 2576 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2577 | FL("cfg80211_vendor_event_alloc failed")); |
| 2578 | return; |
| 2579 | } |
| 2580 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2581 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2582 | hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss); |
| 2583 | hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)", |
| 2584 | pData->numSigRssiBss); |
| 2585 | hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData); |
| 2586 | |
| 2587 | for (i = 0; i < pData->numSigRssiBss; i++) { |
| 2588 | hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u " |
| 2589 | " num RSSI %u ", |
| 2590 | i, pData->sigRssiResult[i].bssid, |
| 2591 | pData->sigRssiResult[i].channel, |
| 2592 | pData->sigRssiResult[i].numRssi); |
| 2593 | |
| 2594 | for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){ |
| 2595 | |
| 2596 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2597 | " [%d]", |
Dino Mycle | c8f3f33 | 2014-07-21 16:48:27 +0530 | [diff] [blame] | 2598 | pData->sigRssiResult[i].rssi[j]); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2599 | |
| 2600 | } |
| 2601 | } |
| 2602 | |
| 2603 | |
| 2604 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2605 | pData->requestId) || |
| 2606 | nla_put_u32(skb, |
| 2607 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 2608 | pData->numSigRssiBss)) { |
| 2609 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail")); |
| 2610 | goto fail; |
| 2611 | } |
| 2612 | |
| 2613 | if (pData->numSigRssiBss) { |
| 2614 | struct nlattr *aps; |
| 2615 | aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST); |
| 2616 | if (!aps) |
| 2617 | goto fail; |
| 2618 | for (i = 0; i < pData->numSigRssiBss; i++) { |
| 2619 | struct nlattr *ap; |
| 2620 | |
| 2621 | ap = nla_nest_start(skb, i); |
| 2622 | if (!ap) |
| 2623 | goto fail; |
| 2624 | if (nla_put(skb, |
| 2625 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID, |
| 2626 | sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) || |
| 2627 | nla_put_u32(skb, |
| 2628 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL, |
| 2629 | pData->sigRssiResult[i].channel) || |
| 2630 | nla_put_u32(skb, |
| 2631 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI, |
| 2632 | pData->sigRssiResult[i].numRssi) || |
| 2633 | nla_put(skb, |
| 2634 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST, |
| 2635 | sizeof(s32) * pData->sigRssiResult[i].numRssi, |
| 2636 | pData->sigRssiResult[i].rssi)) |
| 2637 | goto fail; |
| 2638 | nla_nest_end(skb, ap); |
| 2639 | } |
| 2640 | nla_nest_end(skb, aps); |
| 2641 | if (nla_put_u8(skb, |
| 2642 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA, |
| 2643 | pData->moreData)) |
| 2644 | goto fail; |
| 2645 | } |
| 2646 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2647 | return; |
| 2648 | fail: |
| 2649 | kfree_skb(skb); |
| 2650 | return; |
| 2651 | } |
| 2652 | |
| 2653 | static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx, |
| 2654 | void *pMsg) |
| 2655 | { |
| 2656 | struct sk_buff *skb; |
| 2657 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2658 | tpSirWifiFullScanResultEvent pData = |
| 2659 | (tpSirWifiFullScanResultEvent) (pMsg); |
| 2660 | |
| 2661 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2662 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2663 | "or pData(%p) is null"), pData); |
| 2664 | return; |
| 2665 | } |
| 2666 | |
| 2667 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2668 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2669 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX, |
| 2670 | GFP_KERNEL); |
| 2671 | |
| 2672 | if (!skb) { |
| 2673 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2674 | FL("cfg80211_vendor_event_alloc failed")); |
| 2675 | return; |
| 2676 | } |
| 2677 | |
| 2678 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2679 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId); |
| 2680 | hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData); |
| 2681 | hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) " |
| 2682 | "Ssid (%s)" |
| 2683 | "Bssid (" MAC_ADDRESS_STR ")" |
| 2684 | "Channel (%u)" |
| 2685 | "Rssi (%d)" |
| 2686 | "RTT (%u)" |
| 2687 | "RTT_SD (%u)"), |
| 2688 | pData->ap.ts, |
| 2689 | pData->ap.ssid, |
| 2690 | MAC_ADDR_ARRAY(pData->ap.bssid), |
| 2691 | pData->ap.channel, |
| 2692 | pData->ap.rssi, |
| 2693 | pData->ap.rtt, |
| 2694 | pData->ap.rtt_sd); |
| 2695 | hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength); |
| 2696 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2697 | pData->requestId) || |
| 2698 | nla_put_u64(skb, |
| 2699 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP, |
| 2700 | pData->ap.ts) || |
| 2701 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID, |
| 2702 | sizeof(pData->ap.ssid), |
| 2703 | pData->ap.ssid) || |
| 2704 | nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID, |
| 2705 | WNI_CFG_BSSID_LEN, |
| 2706 | pData->ap.bssid) || |
| 2707 | nla_put_u32(skb, |
| 2708 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL, |
| 2709 | pData->ap.channel) || |
| 2710 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI, |
| 2711 | pData->ap.rssi) || |
| 2712 | nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT, |
| 2713 | pData->ap.rtt) || |
| 2714 | nla_put_u32(skb, |
| 2715 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD, |
| 2716 | pData->ap.rtt_sd) || |
| 2717 | nla_put_u16(skb, |
| 2718 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD, |
| 2719 | pData->ap.beaconPeriod) || |
| 2720 | nla_put_u16(skb, |
| 2721 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY, |
| 2722 | pData->ap.capability) || |
| 2723 | nla_put_u32(skb, |
| 2724 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH, |
| 2725 | pData->ieLength)) |
| 2726 | { |
| 2727 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2728 | goto nla_put_failure; |
| 2729 | } |
| 2730 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA, |
| 2731 | pData->ieLength, |
| 2732 | pData->ie)) |
| 2733 | { |
| 2734 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2735 | goto nla_put_failure; |
| 2736 | } |
| 2737 | |
| 2738 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2739 | return; |
| 2740 | |
| 2741 | nla_put_failure: |
| 2742 | kfree_skb(skb); |
| 2743 | return; |
| 2744 | } |
| 2745 | |
| 2746 | static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx, |
| 2747 | void *pMsg) |
| 2748 | { |
| 2749 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2750 | struct sk_buff *skb = NULL; |
| 2751 | tpSirEXTScanResultsAvailableIndParams pData = |
| 2752 | (tpSirEXTScanResultsAvailableIndParams) pMsg; |
| 2753 | |
| 2754 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2755 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2756 | "or pData(%p) is null"), pData); |
| 2757 | return; |
| 2758 | } |
| 2759 | |
| 2760 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2761 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2762 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX, |
| 2763 | GFP_KERNEL); |
| 2764 | |
| 2765 | if (!skb) { |
| 2766 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2767 | FL("cfg80211_vendor_event_alloc failed")); |
| 2768 | return; |
| 2769 | } |
| 2770 | |
| 2771 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2772 | hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId); |
| 2773 | hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", |
| 2774 | pData->numResultsAvailable); |
| 2775 | if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2776 | pData->requestId) || |
| 2777 | nla_put_u32(skb, |
| 2778 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE, |
| 2779 | pData->numResultsAvailable)) { |
| 2780 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2781 | goto nla_put_failure; |
| 2782 | } |
| 2783 | |
| 2784 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2785 | return; |
| 2786 | |
| 2787 | nla_put_failure: |
| 2788 | kfree_skb(skb); |
| 2789 | return; |
| 2790 | } |
| 2791 | |
| 2792 | static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg) |
| 2793 | { |
| 2794 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2795 | struct sk_buff *skb = NULL; |
| 2796 | tpSirEXTScanProgressIndParams pData = |
| 2797 | (tpSirEXTScanProgressIndParams) pMsg; |
| 2798 | |
| 2799 | if (wlan_hdd_validate_context(pHddCtx) || !pData) { |
| 2800 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid " |
| 2801 | "or pData(%p) is null"), pData); |
| 2802 | return; |
| 2803 | } |
| 2804 | |
| 2805 | skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 2806 | EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 2807 | QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX, |
| 2808 | GFP_KERNEL); |
| 2809 | |
| 2810 | if (!skb) { |
| 2811 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2812 | FL("cfg80211_vendor_event_alloc failed")); |
| 2813 | return; |
| 2814 | } |
| 2815 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 2816 | hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)", |
| 2817 | pData->extScanEventType); |
| 2818 | hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)", |
| 2819 | pData->status); |
| 2820 | |
| 2821 | if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE, |
| 2822 | pData->extScanEventType) || |
| 2823 | nla_put_u32(skb, |
Dasari Srinivas | 5a28865 | 2014-06-30 17:13:22 +0530 | [diff] [blame] | 2824 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID, |
| 2825 | pData->requestId) || |
| 2826 | nla_put_u32(skb, |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2827 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS, |
| 2828 | pData->status)) { |
| 2829 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 2830 | goto nla_put_failure; |
| 2831 | } |
| 2832 | |
| 2833 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 2834 | return; |
| 2835 | |
| 2836 | nla_put_failure: |
| 2837 | kfree_skb(skb); |
| 2838 | return; |
| 2839 | } |
| 2840 | |
| 2841 | void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType, |
| 2842 | void *pMsg) |
| 2843 | { |
| 2844 | hdd_context_t *pHddCtx = (hdd_context_t *)ctx; |
| 2845 | |
| 2846 | if (wlan_hdd_validate_context(pHddCtx)) { |
| 2847 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid")); |
| 2848 | return; |
| 2849 | } |
| 2850 | |
| 2851 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType); |
| 2852 | |
| 2853 | |
| 2854 | switch(evType) { |
| 2855 | case SIR_HAL_EXTSCAN_START_RSP: |
| 2856 | wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg); |
| 2857 | break; |
| 2858 | |
| 2859 | case SIR_HAL_EXTSCAN_STOP_RSP: |
| 2860 | wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg); |
| 2861 | break; |
| 2862 | case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP: |
| 2863 | /* There is no need to send this response to upper layer |
| 2864 | Just log the message */ |
| 2865 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2866 | FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP")); |
| 2867 | break; |
| 2868 | case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP: |
| 2869 | wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg); |
| 2870 | break; |
| 2871 | |
| 2872 | case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP: |
| 2873 | wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg); |
| 2874 | break; |
| 2875 | |
| 2876 | case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP: |
| 2877 | wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg); |
| 2878 | break; |
| 2879 | |
| 2880 | case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP: |
| 2881 | wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg); |
| 2882 | break; |
| 2883 | case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP: |
| 2884 | wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg); |
| 2885 | break; |
| 2886 | case SIR_HAL_EXTSCAN_PROGRESS_IND: |
| 2887 | wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg); |
| 2888 | break; |
| 2889 | case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND: |
| 2890 | wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg); |
| 2891 | break; |
| 2892 | case SIR_HAL_EXTSCAN_SCAN_RESULT_IND: |
| 2893 | wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg); |
| 2894 | break; |
| 2895 | case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND: |
| 2896 | wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg); |
| 2897 | break; |
| 2898 | case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND: |
| 2899 | wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg); |
| 2900 | break; |
| 2901 | case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND: |
| 2902 | wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg); |
| 2903 | break; |
| 2904 | default: |
| 2905 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType); |
| 2906 | break; |
| 2907 | } |
| 2908 | } |
| 2909 | |
| 2910 | static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy, |
| 2911 | struct wireless_dev *wdev, |
| 2912 | void *data, int dataLen) |
| 2913 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2914 | tSirGetEXTScanCapabilitiesReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2915 | struct net_device *dev = wdev->netdev; |
| 2916 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2917 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2918 | struct nlattr |
| 2919 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 2920 | eHalStatus status; |
| 2921 | |
| 2922 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering")); |
| 2923 | status = wlan_hdd_validate_context(pHddCtx); |
| 2924 | if (0 != status) |
| 2925 | { |
| 2926 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2927 | FL("HDD context is not valid")); |
| 2928 | return -EINVAL; |
| 2929 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2930 | /* check the EXTScan Capability */ |
| 2931 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 2932 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 2933 | { |
| 2934 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2935 | FL("EXTScan not enabled/supported by Firmware")); |
| 2936 | return -EINVAL; |
| 2937 | } |
| 2938 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2939 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 2940 | data, dataLen, |
| 2941 | wlan_hdd_extscan_config_policy)) { |
| 2942 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 2943 | return -EINVAL; |
| 2944 | } |
| 2945 | |
| 2946 | /* Parse and fetch request Id */ |
| 2947 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 2948 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 2949 | return -EINVAL; |
| 2950 | } |
| 2951 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2952 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2953 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2954 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2955 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2956 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2957 | reqMsg.sessionId = pAdapter->sessionId; |
| 2958 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2959 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2960 | status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2961 | if (!HAL_STATUS_SUCCESS(status)) { |
| 2962 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2963 | FL("sme_EXTScanGetCapabilities failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2964 | return -EINVAL; |
| 2965 | } |
| 2966 | |
| 2967 | return 0; |
| 2968 | } |
| 2969 | |
| 2970 | |
| 2971 | static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy, |
| 2972 | struct wireless_dev *wdev, |
| 2973 | void *data, int dataLen) |
| 2974 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2975 | tSirEXTScanGetCachedResultsReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2976 | struct net_device *dev = wdev->netdev; |
| 2977 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2978 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2979 | struct nlattr |
| 2980 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 2981 | eHalStatus status; |
| 2982 | |
| 2983 | status = wlan_hdd_validate_context(pHddCtx); |
| 2984 | if (0 != status) |
| 2985 | { |
| 2986 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2987 | FL("HDD context is not valid")); |
| 2988 | return -EINVAL; |
| 2989 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 2990 | /* check the EXTScan Capability */ |
| 2991 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 2992 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 2993 | { |
| 2994 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2995 | FL("EXTScan not enabled/supported by Firmware")); |
| 2996 | return -EINVAL; |
| 2997 | } |
| 2998 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 2999 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3000 | data, dataLen, |
| 3001 | wlan_hdd_extscan_config_policy)) { |
| 3002 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3003 | return -EINVAL; |
| 3004 | } |
| 3005 | /* Parse and fetch request Id */ |
| 3006 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3007 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3008 | return -EINVAL; |
| 3009 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3010 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3011 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3012 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3013 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3014 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3015 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3016 | reqMsg.sessionId = pAdapter->sessionId; |
| 3017 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3018 | |
| 3019 | /* Parse and fetch flush parameter */ |
| 3020 | if (!tb |
| 3021 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]) |
| 3022 | { |
| 3023 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed")); |
| 3024 | goto failed; |
| 3025 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3026 | reqMsg.flush = nla_get_u8( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3027 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]); |
| 3028 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3029 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3030 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3031 | status = sme_getCachedResults(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3032 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3033 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3034 | FL("sme_getCachedResults failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3035 | return -EINVAL; |
| 3036 | } |
| 3037 | return 0; |
| 3038 | |
| 3039 | failed: |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3040 | return -EINVAL; |
| 3041 | } |
| 3042 | |
| 3043 | static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy, |
| 3044 | struct wireless_dev *wdev, |
| 3045 | void *data, int dataLen) |
| 3046 | { |
| 3047 | tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL; |
| 3048 | struct net_device *dev = wdev->netdev; |
| 3049 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3050 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3051 | struct nlattr |
| 3052 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3053 | struct nlattr |
| 3054 | *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3055 | struct nlattr *apTh; |
| 3056 | eHalStatus status; |
| 3057 | tANI_U8 i = 0; |
| 3058 | int rem; |
| 3059 | |
| 3060 | status = wlan_hdd_validate_context(pHddCtx); |
| 3061 | if (0 != status) |
| 3062 | { |
| 3063 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3064 | FL("HDD context is not valid")); |
| 3065 | return -EINVAL; |
| 3066 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3067 | /* check the EXTScan Capability */ |
| 3068 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3069 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3070 | { |
| 3071 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3072 | FL("EXTScan not enabled/supported by Firmware")); |
| 3073 | return -EINVAL; |
| 3074 | } |
| 3075 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3076 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3077 | data, dataLen, |
| 3078 | wlan_hdd_extscan_config_policy)) { |
| 3079 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3080 | return -EINVAL; |
| 3081 | } |
| 3082 | |
| 3083 | /* Parse and fetch request Id */ |
| 3084 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3085 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3086 | return -EINVAL; |
| 3087 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3088 | pReqMsg = (tpSirEXTScanSetBssidHotListReqParams) |
| 3089 | vos_mem_malloc(sizeof(*pReqMsg)); |
| 3090 | if (!pReqMsg) { |
| 3091 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed")); |
| 3092 | return -ENOMEM; |
| 3093 | } |
| 3094 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3095 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3096 | pReqMsg->requestId = nla_get_u32( |
| 3097 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3098 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId); |
| 3099 | |
| 3100 | /* Parse and fetch number of APs */ |
| 3101 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) { |
| 3102 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed")); |
| 3103 | goto fail; |
| 3104 | } |
| 3105 | |
| 3106 | pReqMsg->sessionId = pAdapter->sessionId; |
| 3107 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId); |
| 3108 | |
| 3109 | pReqMsg->numAp = nla_get_u32( |
| 3110 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]); |
| 3111 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp); |
| 3112 | |
| 3113 | nla_for_each_nested(apTh, |
| 3114 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) { |
| 3115 | if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3116 | nla_data(apTh), nla_len(apTh), |
| 3117 | NULL)) { |
| 3118 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed")); |
| 3119 | goto fail; |
| 3120 | } |
| 3121 | |
| 3122 | /* Parse and fetch MAC address */ |
| 3123 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) { |
| 3124 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed")); |
| 3125 | goto fail; |
| 3126 | } |
| 3127 | memcpy(pReqMsg->ap[i].bssid, nla_data( |
| 3128 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]), |
| 3129 | sizeof(tSirMacAddr)); |
| 3130 | hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid); |
| 3131 | |
| 3132 | /* Parse and fetch low RSSI */ |
| 3133 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) { |
| 3134 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed")); |
| 3135 | goto fail; |
| 3136 | } |
| 3137 | pReqMsg->ap[i].low = nla_get_s32( |
| 3138 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]); |
| 3139 | hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low); |
| 3140 | |
| 3141 | /* Parse and fetch high RSSI */ |
| 3142 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) { |
| 3143 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed")); |
| 3144 | goto fail; |
| 3145 | } |
| 3146 | pReqMsg->ap[i].high = nla_get_s32( |
| 3147 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]); |
| 3148 | hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"), |
| 3149 | pReqMsg->ap[i].high); |
| 3150 | |
| 3151 | /* Parse and fetch channel */ |
| 3152 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) { |
| 3153 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed")); |
| 3154 | goto fail; |
| 3155 | } |
| 3156 | pReqMsg->ap[i].channel = nla_get_u32( |
| 3157 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]); |
| 3158 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3159 | FL("Channel (%u)"), pReqMsg->ap[i].channel); |
| 3160 | i++; |
| 3161 | } |
| 3162 | status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg); |
| 3163 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3164 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3165 | FL("sme_SetBssHotlist failed(err=%d)"), status); |
| 3166 | vos_mem_free(pReqMsg); |
| 3167 | return -EINVAL; |
| 3168 | } |
| 3169 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3170 | vos_mem_free(pReqMsg); |
| 3171 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3172 | return 0; |
| 3173 | |
| 3174 | fail: |
| 3175 | vos_mem_free(pReqMsg); |
| 3176 | return -EINVAL; |
| 3177 | } |
| 3178 | |
| 3179 | static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy, |
| 3180 | struct wireless_dev *wdev, |
| 3181 | void *data, int dataLen) |
| 3182 | { |
| 3183 | tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL; |
| 3184 | struct net_device *dev = wdev->netdev; |
| 3185 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3186 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3187 | struct nlattr |
| 3188 | *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3189 | struct nlattr |
| 3190 | *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3191 | struct nlattr *apTh; |
| 3192 | eHalStatus status; |
| 3193 | int i = 0; |
| 3194 | int rem; |
| 3195 | |
| 3196 | status = wlan_hdd_validate_context(pHddCtx); |
| 3197 | if (0 != status) |
| 3198 | { |
| 3199 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3200 | FL("HDD context is not valid")); |
| 3201 | return -EINVAL; |
| 3202 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3203 | /* check the EXTScan Capability */ |
| 3204 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3205 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3206 | { |
| 3207 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3208 | FL("EXTScan not enabled/supported by Firmware")); |
| 3209 | return -EINVAL; |
| 3210 | } |
| 3211 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3212 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3213 | data, dataLen, |
| 3214 | wlan_hdd_extscan_config_policy)) { |
| 3215 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3216 | return -EINVAL; |
| 3217 | } |
| 3218 | |
| 3219 | /* Parse and fetch request Id */ |
| 3220 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3221 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3222 | return -EINVAL; |
| 3223 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3224 | pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams) |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3225 | vos_mem_malloc(sizeof(*pReqMsg)); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3226 | if (!pReqMsg) { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3227 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed")); |
| 3228 | return -ENOMEM; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3229 | } |
| 3230 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3231 | |
| 3232 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3233 | pReqMsg->requestId = nla_get_u32( |
| 3234 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3235 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId); |
| 3236 | |
| 3237 | /* Parse and fetch RSSI sample size */ |
| 3238 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]) |
| 3239 | { |
| 3240 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed")); |
| 3241 | goto fail; |
| 3242 | } |
| 3243 | pReqMsg->rssiSampleSize = nla_get_u32( |
| 3244 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]); |
| 3245 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3246 | FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize); |
| 3247 | |
| 3248 | /* Parse and fetch lost AP sample size */ |
| 3249 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]) |
| 3250 | { |
| 3251 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed")); |
| 3252 | goto fail; |
| 3253 | } |
| 3254 | pReqMsg->lostApSampleSize = nla_get_u32( |
| 3255 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]); |
| 3256 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3257 | FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize); |
| 3258 | /* Parse and fetch minimum Breaching */ |
| 3259 | if (!tb |
| 3260 | [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) { |
| 3261 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed")); |
| 3262 | goto fail; |
| 3263 | } |
| 3264 | pReqMsg->minBreaching = nla_get_u32( |
| 3265 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]); |
| 3266 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching); |
| 3267 | |
| 3268 | /* Parse and fetch number of APs */ |
| 3269 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) { |
| 3270 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed")); |
| 3271 | goto fail; |
| 3272 | } |
| 3273 | pReqMsg->numAp = nla_get_u32( |
| 3274 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]); |
| 3275 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp); |
| 3276 | |
| 3277 | pReqMsg->sessionId = pAdapter->sessionId; |
| 3278 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId); |
| 3279 | |
| 3280 | nla_for_each_nested(apTh, |
| 3281 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) { |
| 3282 | if(nla_parse(tb2, |
| 3283 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3284 | nla_data(apTh), nla_len(apTh), |
| 3285 | NULL)) { |
| 3286 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed")); |
| 3287 | goto fail; |
| 3288 | } |
| 3289 | |
| 3290 | /* Parse and fetch MAC address */ |
| 3291 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) { |
| 3292 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed")); |
| 3293 | goto fail; |
| 3294 | } |
| 3295 | memcpy(pReqMsg->ap[i].bssid, nla_data( |
| 3296 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]), |
| 3297 | sizeof(tSirMacAddr)); |
| 3298 | |
| 3299 | /* Parse and fetch low RSSI */ |
| 3300 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) { |
| 3301 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed")); |
| 3302 | goto fail; |
| 3303 | } |
| 3304 | pReqMsg->ap[i].low = nla_get_s32( |
| 3305 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]); |
| 3306 | hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low); |
| 3307 | |
| 3308 | /* Parse and fetch high RSSI */ |
| 3309 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) { |
| 3310 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed")); |
| 3311 | goto fail; |
| 3312 | } |
| 3313 | pReqMsg->ap[i].high = nla_get_s32( |
| 3314 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]); |
| 3315 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3316 | FL("RSSI High (%d)"), pReqMsg->ap[i].high); |
| 3317 | |
| 3318 | /* Parse and fetch channel */ |
| 3319 | if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) { |
| 3320 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed")); |
| 3321 | goto fail; |
| 3322 | } |
| 3323 | pReqMsg->ap[i].channel = nla_get_u32( |
| 3324 | tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]); |
| 3325 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3326 | FL("Channel (%u)"), pReqMsg->ap[i].channel); |
| 3327 | i++; |
| 3328 | } |
| 3329 | |
| 3330 | status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg); |
| 3331 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3332 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3333 | FL("sme_SetSignificantChange failed(err=%d)"), status); |
| 3334 | vos_mem_free(pReqMsg); |
| 3335 | return -EINVAL; |
| 3336 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3337 | vos_mem_free(pReqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3338 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting")); |
| 3339 | return 0; |
| 3340 | |
| 3341 | fail: |
| 3342 | vos_mem_free(pReqMsg); |
| 3343 | return -EINVAL; |
| 3344 | } |
| 3345 | |
| 3346 | static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy, |
| 3347 | struct wireless_dev *wdev, |
| 3348 | void *data, int dataLen) |
| 3349 | { |
| 3350 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3351 | tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3352 | tANI_U8 numChannels = 0; |
| 3353 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3354 | tANI_U32 requestId; |
| 3355 | tWifiBand wifiBand; |
| 3356 | eHalStatus status; |
| 3357 | struct sk_buff *replySkb; |
| 3358 | tANI_U8 i; |
| 3359 | |
| 3360 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering")); |
| 3361 | status = wlan_hdd_validate_context(pHddCtx); |
| 3362 | if (0 != status) |
| 3363 | { |
| 3364 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3365 | FL("HDD context is not valid")); |
| 3366 | return -EINVAL; |
| 3367 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3368 | /* check the EXTScan Capability */ |
| 3369 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3370 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3371 | { |
| 3372 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3373 | FL("EXTScan not enabled/supported by Firmware")); |
| 3374 | return -EINVAL; |
| 3375 | } |
| 3376 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3377 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3378 | data, dataLen, |
| 3379 | wlan_hdd_extscan_config_policy)) { |
| 3380 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3381 | return -EINVAL; |
| 3382 | } |
| 3383 | |
| 3384 | /* Parse and fetch request Id */ |
| 3385 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3386 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3387 | return -EINVAL; |
| 3388 | } |
| 3389 | requestId = nla_get_u32( |
| 3390 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3391 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId); |
| 3392 | |
| 3393 | /* Parse and fetch wifi band */ |
| 3394 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]) |
| 3395 | { |
| 3396 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed")); |
| 3397 | return -EINVAL; |
| 3398 | } |
| 3399 | wifiBand = nla_get_u32( |
| 3400 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]); |
| 3401 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand); |
| 3402 | |
| 3403 | status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal), |
| 3404 | wifiBand, ChannelList, |
| 3405 | &numChannels); |
| 3406 | if (eHAL_STATUS_SUCCESS != status) { |
| 3407 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3408 | FL("sme_GetValidChannelsByBand failed (err=%d)"), status); |
| 3409 | return -EINVAL; |
| 3410 | } |
| 3411 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels); |
| 3412 | for (i = 0; i < numChannels; i++) |
| 3413 | hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]); |
| 3414 | |
| 3415 | replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) + |
| 3416 | sizeof(u32) * numChannels + |
| 3417 | NLMSG_HDRLEN); |
| 3418 | |
| 3419 | if (!replySkb) { |
| 3420 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3421 | FL("valid channels: buffer alloc fail")); |
| 3422 | return -EINVAL; |
| 3423 | } |
| 3424 | if (nla_put_u32(replySkb, |
| 3425 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS, |
| 3426 | numChannels) || |
| 3427 | nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS, |
| 3428 | sizeof(u32) * numChannels, ChannelList)) { |
| 3429 | |
| 3430 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3431 | kfree_skb(replySkb); |
| 3432 | return -EINVAL; |
| 3433 | } |
| 3434 | |
| 3435 | return cfg80211_vendor_cmd_reply(replySkb); |
| 3436 | } |
| 3437 | |
| 3438 | static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy, |
| 3439 | struct wireless_dev *wdev, |
| 3440 | void *data, int dataLen) |
| 3441 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3442 | tpSirEXTScanStartReqParams pReqMsg = NULL; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3443 | struct net_device *dev = wdev->netdev; |
| 3444 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3445 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3446 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3447 | struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3448 | struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3449 | struct nlattr *buckets; |
| 3450 | struct nlattr *channels; |
| 3451 | int rem1; |
| 3452 | int rem2; |
| 3453 | eHalStatus status; |
| 3454 | tANI_U8 bktIndex; |
| 3455 | tANI_U32 i = 0, j = 0; |
| 3456 | |
| 3457 | status = wlan_hdd_validate_context(pHddCtx); |
| 3458 | if (0 != status) |
| 3459 | { |
| 3460 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3461 | FL("HDD context is not valid")); |
| 3462 | return -EINVAL; |
| 3463 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3464 | /* check the EXTScan Capability */ |
| 3465 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3466 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3467 | { |
| 3468 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3469 | FL("EXTScan not enabled/supported by Firmware")); |
| 3470 | return -EINVAL; |
| 3471 | } |
| 3472 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3473 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3474 | data, dataLen, |
| 3475 | wlan_hdd_extscan_config_policy)) { |
| 3476 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3477 | return -EINVAL; |
| 3478 | } |
| 3479 | |
| 3480 | /* Parse and fetch request Id */ |
| 3481 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3482 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3483 | return -EINVAL; |
| 3484 | } |
| 3485 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3486 | pReqMsg = (tpSirEXTScanStartReqParams) |
| 3487 | vos_mem_malloc(sizeof(*pReqMsg)); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3488 | if (!pReqMsg) { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3489 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed")); |
| 3490 | return -ENOMEM; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3491 | } |
| 3492 | |
| 3493 | pReqMsg->requestId = nla_get_u32( |
| 3494 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
| 3495 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId); |
| 3496 | |
| 3497 | pReqMsg->sessionId = pAdapter->sessionId; |
| 3498 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId); |
| 3499 | |
| 3500 | /* Parse and fetch base period */ |
| 3501 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) { |
| 3502 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed")); |
| 3503 | goto fail; |
| 3504 | } |
| 3505 | pReqMsg->basePeriod = nla_get_u32( |
| 3506 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]); |
| 3507 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"), |
| 3508 | pReqMsg->basePeriod); |
| 3509 | |
| 3510 | /* Parse and fetch max AP per scan */ |
| 3511 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) { |
| 3512 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed")); |
| 3513 | goto fail; |
| 3514 | } |
| 3515 | pReqMsg->maxAPperScan = nla_get_u32( |
| 3516 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]); |
| 3517 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"), |
| 3518 | pReqMsg->maxAPperScan); |
| 3519 | |
| 3520 | /* Parse and fetch report threshold */ |
| 3521 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) { |
| 3522 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed")); |
| 3523 | goto fail; |
| 3524 | } |
| 3525 | pReqMsg->reportThreshold = nla_get_u8( |
| 3526 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]); |
| 3527 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"), |
| 3528 | pReqMsg->reportThreshold); |
| 3529 | |
| 3530 | /* Parse and fetch number of buckets */ |
| 3531 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) { |
| 3532 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed")); |
| 3533 | goto fail; |
| 3534 | } |
| 3535 | pReqMsg->numBuckets = nla_get_u8( |
| 3536 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]); |
| 3537 | if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) { |
| 3538 | hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets " |
| 3539 | "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS); |
| 3540 | pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS; |
| 3541 | } |
| 3542 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"), |
| 3543 | pReqMsg->numBuckets); |
| 3544 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) { |
| 3545 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed")); |
| 3546 | goto fail; |
| 3547 | } |
| 3548 | |
| 3549 | nla_for_each_nested(buckets, |
| 3550 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) { |
| 3551 | if(nla_parse(bucket, |
| 3552 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3553 | nla_data(buckets), nla_len(buckets), NULL)) { //policy |
| 3554 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed")); |
| 3555 | goto fail; |
| 3556 | } |
| 3557 | |
| 3558 | /* Parse and fetch bucket spec */ |
| 3559 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) { |
| 3560 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed")); |
| 3561 | goto fail; |
| 3562 | } |
| 3563 | bktIndex = nla_get_u8( |
| 3564 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]); |
| 3565 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"), bktIndex); |
| 3566 | pReqMsg->buckets[bktIndex].bucket = bktIndex; |
| 3567 | |
| 3568 | /* Parse and fetch wifi band */ |
| 3569 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) { |
| 3570 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed")); |
| 3571 | goto fail; |
| 3572 | } |
| 3573 | pReqMsg->buckets[bktIndex].band = nla_get_u8( |
| 3574 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]); |
| 3575 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), |
| 3576 | pReqMsg->buckets[bktIndex].band); |
| 3577 | |
| 3578 | /* Parse and fetch period */ |
| 3579 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) { |
| 3580 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed")); |
| 3581 | goto fail; |
| 3582 | } |
| 3583 | pReqMsg->buckets[bktIndex].period = nla_get_u32( |
| 3584 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]); |
| 3585 | hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"), |
| 3586 | pReqMsg->buckets[bktIndex].period); |
| 3587 | |
| 3588 | /* Parse and fetch report events */ |
| 3589 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) { |
| 3590 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed")); |
| 3591 | goto fail; |
| 3592 | } |
| 3593 | pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8( |
| 3594 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]); |
| 3595 | hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"), |
| 3596 | pReqMsg->buckets[bktIndex].reportEvents); |
| 3597 | |
| 3598 | /* Parse and fetch number of channels */ |
| 3599 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) { |
| 3600 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed")); |
| 3601 | goto fail; |
| 3602 | } |
| 3603 | pReqMsg->buckets[bktIndex].numChannels = nla_get_u32( |
| 3604 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]); |
| 3605 | hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"), |
| 3606 | pReqMsg->buckets[bktIndex].numChannels); |
| 3607 | |
| 3608 | if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) { |
| 3609 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed")); |
| 3610 | goto fail; |
| 3611 | } |
| 3612 | |
| 3613 | j = 0; |
| 3614 | nla_for_each_nested(channels, |
| 3615 | bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) { |
| 3616 | if(nla_parse(channel, |
| 3617 | QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3618 | nla_data(channels), nla_len(channels), |
| 3619 | NULL)) { //wlan_hdd_extscan_config_policy here |
| 3620 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed")); |
| 3621 | goto fail; |
| 3622 | } |
| 3623 | |
| 3624 | /* Parse and fetch channel */ |
| 3625 | if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) { |
| 3626 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed")); |
| 3627 | goto fail; |
| 3628 | } |
| 3629 | pReqMsg->buckets[bktIndex].channels[j].channel = nla_get_u32( |
| 3630 | channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]); |
| 3631 | hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"), |
| 3632 | pReqMsg->buckets[bktIndex].channels[j].channel); |
| 3633 | |
| 3634 | /* Parse and fetch dwell time */ |
| 3635 | if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) { |
| 3636 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed")); |
| 3637 | goto fail; |
| 3638 | } |
| 3639 | pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs = nla_get_u32( |
| 3640 | channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]); |
| 3641 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"), |
| 3642 | pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs); |
| 3643 | |
| 3644 | /* Parse and fetch channel spec passive */ |
| 3645 | if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) { |
| 3646 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3647 | FL("attr channel spec passive failed")); |
| 3648 | goto fail; |
| 3649 | } |
| 3650 | pReqMsg->buckets[bktIndex].channels[j].passive = nla_get_u8( |
| 3651 | channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]); |
| 3652 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"), |
| 3653 | pReqMsg->buckets[bktIndex].channels[j].passive); |
| 3654 | j++; |
| 3655 | } |
| 3656 | i++; |
| 3657 | } |
| 3658 | status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg); |
| 3659 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3660 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3661 | FL("sme_EXTScanStart failed(err=%d)"), status); |
| 3662 | vos_mem_free(pReqMsg); |
| 3663 | return -EINVAL; |
| 3664 | } |
| 3665 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3666 | vos_mem_free(pReqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3667 | return 0; |
| 3668 | |
| 3669 | fail: |
| 3670 | vos_mem_free(pReqMsg); |
| 3671 | return -EINVAL; |
| 3672 | } |
| 3673 | |
| 3674 | static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy, |
| 3675 | struct wireless_dev *wdev, |
| 3676 | void *data, int dataLen) |
| 3677 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3678 | tSirEXTScanStopReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3679 | struct net_device *dev = wdev->netdev; |
| 3680 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3681 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3682 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3683 | eHalStatus status; |
| 3684 | |
| 3685 | status = wlan_hdd_validate_context(pHddCtx); |
| 3686 | if (0 != status) |
| 3687 | { |
| 3688 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3689 | FL("HDD context is not valid")); |
| 3690 | return -EINVAL; |
| 3691 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3692 | /* check the EXTScan Capability */ |
| 3693 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3694 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3695 | { |
| 3696 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3697 | FL("EXTScan not enabled/supported by Firmware")); |
| 3698 | return -EINVAL; |
| 3699 | } |
| 3700 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3701 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3702 | data, dataLen, |
| 3703 | wlan_hdd_extscan_config_policy)) { |
| 3704 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3705 | return -EINVAL; |
| 3706 | } |
| 3707 | |
| 3708 | /* Parse and fetch request Id */ |
| 3709 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3710 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3711 | return -EINVAL; |
| 3712 | } |
| 3713 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3714 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3715 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3716 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3717 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3718 | reqMsg.sessionId = pAdapter->sessionId; |
| 3719 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3720 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3721 | status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3722 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3723 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3724 | FL("sme_EXTScanStop failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3725 | return -EINVAL; |
| 3726 | } |
| 3727 | |
| 3728 | return 0; |
| 3729 | } |
| 3730 | |
| 3731 | static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy, |
| 3732 | struct wireless_dev *wdev, |
| 3733 | void *data, int dataLen) |
| 3734 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3735 | tSirEXTScanResetBssidHotlistReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3736 | struct net_device *dev = wdev->netdev; |
| 3737 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3738 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3739 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3740 | eHalStatus status; |
| 3741 | |
| 3742 | status = wlan_hdd_validate_context(pHddCtx); |
| 3743 | if (0 != status) |
| 3744 | { |
| 3745 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3746 | FL("HDD context is not valid")); |
| 3747 | return -EINVAL; |
| 3748 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3749 | /* check the EXTScan Capability */ |
| 3750 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3751 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3752 | { |
| 3753 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3754 | FL("EXTScan not enabled/supported by Firmware")); |
| 3755 | return -EINVAL; |
| 3756 | } |
| 3757 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3758 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3759 | data, dataLen, |
| 3760 | wlan_hdd_extscan_config_policy)) { |
| 3761 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3762 | return -EINVAL; |
| 3763 | } |
| 3764 | |
| 3765 | /* Parse and fetch request Id */ |
| 3766 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3767 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3768 | return -EINVAL; |
| 3769 | } |
| 3770 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3771 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3772 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3773 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3774 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3775 | reqMsg.sessionId = pAdapter->sessionId; |
| 3776 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3777 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3778 | status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3779 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3780 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3781 | FL("sme_ResetBssHotlist failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3782 | return -EINVAL; |
| 3783 | } |
| 3784 | |
| 3785 | return 0; |
| 3786 | } |
| 3787 | |
| 3788 | static int wlan_hdd_cfg80211_extscan_reset_significant_change( |
| 3789 | struct wiphy *wiphy, |
| 3790 | struct wireless_dev *wdev, |
| 3791 | void *data, int dataLen) |
| 3792 | { |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3793 | tSirEXTScanResetSignificantChangeReqParams reqMsg; |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3794 | struct net_device *dev = wdev->netdev; |
| 3795 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3796 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3797 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1]; |
| 3798 | eHalStatus status; |
| 3799 | |
| 3800 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" Entering")); |
| 3801 | status = wlan_hdd_validate_context(pHddCtx); |
| 3802 | if (0 != status) |
| 3803 | { |
| 3804 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3805 | FL("HDD context is not valid")); |
| 3806 | return -EINVAL; |
| 3807 | } |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3808 | /* check the EXTScan Capability */ |
| 3809 | if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) || |
| 3810 | (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN))) |
| 3811 | { |
| 3812 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3813 | FL("EXTScan not enabled/supported by Firmware")); |
| 3814 | return -EINVAL; |
| 3815 | } |
| 3816 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3817 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX, |
| 3818 | data, dataLen, |
| 3819 | wlan_hdd_extscan_config_policy)) { |
| 3820 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3821 | return -EINVAL; |
| 3822 | } |
| 3823 | |
| 3824 | /* Parse and fetch request Id */ |
| 3825 | if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) { |
| 3826 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed")); |
| 3827 | return -EINVAL; |
| 3828 | } |
| 3829 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3830 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3831 | reqMsg.requestId = nla_get_u32( |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3832 | tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]); |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3833 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3834 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3835 | reqMsg.sessionId = pAdapter->sessionId; |
| 3836 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3837 | |
Dino Mycle | e8843b3 | 2014-07-04 14:21:45 +0530 | [diff] [blame] | 3838 | status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3839 | if (!HAL_STATUS_SUCCESS(status)) { |
| 3840 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3841 | FL("sme_ResetSignificantChange failed(err=%d)"), status); |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 3842 | return -EINVAL; |
| 3843 | } |
| 3844 | |
| 3845 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting")); |
| 3846 | return 0; |
| 3847 | } |
| 3848 | |
| 3849 | #endif /* WLAN_FEATURE_EXTSCAN */ |
| 3850 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3851 | /*EXT TDLS*/ |
| 3852 | static const struct nla_policy |
| 3853 | wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] = |
| 3854 | { |
| 3855 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 3856 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 }, |
| 3857 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] = |
| 3858 | {.type = NLA_S32 }, |
| 3859 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 }, |
| 3860 | [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 }, |
| 3861 | |
| 3862 | }; |
| 3863 | |
| 3864 | static const struct nla_policy |
| 3865 | wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] = |
| 3866 | { |
| 3867 | [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 3868 | |
| 3869 | }; |
| 3870 | |
| 3871 | static const struct nla_policy |
| 3872 | wlan_hdd_tdls_config_state_change_policy[ |
| 3873 | QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] = |
| 3874 | { |
| 3875 | [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 3876 | [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 }, |
| 3877 | [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 }, |
| 3878 | |
| 3879 | }; |
| 3880 | |
| 3881 | static const struct nla_policy |
| 3882 | wlan_hdd_tdls_config_get_status_policy[ |
| 3883 | QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] = |
| 3884 | { |
| 3885 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC }, |
| 3886 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 }, |
| 3887 | [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 }, |
| 3888 | |
| 3889 | }; |
| 3890 | static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy, |
| 3891 | struct wireless_dev *wdev, |
| 3892 | void *data, |
| 3893 | int data_len) |
| 3894 | { |
| 3895 | u8 peer[6] = {0}; |
| 3896 | struct net_device *dev = wdev->netdev; |
| 3897 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3898 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3899 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1]; |
| 3900 | eHalStatus ret; |
| 3901 | tANI_S32 state; |
| 3902 | tANI_S32 reason; |
| 3903 | struct sk_buff *skb = NULL; |
| 3904 | |
| 3905 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3906 | if (0 != ret) { |
| 3907 | |
| 3908 | return -EINVAL; |
| 3909 | } |
| 3910 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
| 3911 | |
| 3912 | return -ENOTSUPP; |
| 3913 | } |
| 3914 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX, |
| 3915 | data, data_len, |
| 3916 | wlan_hdd_tdls_config_get_status_policy)) { |
| 3917 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 3918 | return -EINVAL; |
| 3919 | } |
| 3920 | |
| 3921 | /* Parse and fetch mac address */ |
| 3922 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) { |
| 3923 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 3924 | return -EINVAL; |
| 3925 | } |
| 3926 | |
| 3927 | memcpy(peer, nla_data( |
| 3928 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]), |
| 3929 | sizeof(peer)); |
| 3930 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer)); |
| 3931 | |
| 3932 | ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason); |
| 3933 | |
| 3934 | if (0 != ret) { |
| 3935 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3936 | FL("get status Failed")); |
| 3937 | return -EINVAL; |
| 3938 | } |
| 3939 | skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 3940 | 2 * sizeof(s32) + |
| 3941 | NLMSG_HDRLEN); |
| 3942 | |
| 3943 | if (!skb) { |
| 3944 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3945 | FL("cfg80211_vendor_cmd_alloc_reply_skb failed")); |
| 3946 | return -EINVAL; |
| 3947 | } |
| 3948 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) tdls peer" MAC_ADDRESS_STR), |
| 3949 | reason, |
| 3950 | state, |
| 3951 | MAC_ADDR_ARRAY(peer)); |
| 3952 | |
| 3953 | if (nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE, state) || |
| 3954 | nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON, reason)) { |
| 3955 | |
| 3956 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 3957 | goto nla_put_failure; |
| 3958 | } |
| 3959 | |
| 3960 | return cfg80211_vendor_cmd_reply(skb); |
| 3961 | |
| 3962 | nla_put_failure: |
| 3963 | kfree_skb(skb); |
| 3964 | return -EINVAL; |
| 3965 | } |
| 3966 | |
| 3967 | static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac, |
| 3968 | tANI_S32 state, |
| 3969 | tANI_S32 reason, |
| 3970 | void *ctx) |
| 3971 | { |
| 3972 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx; |
| 3973 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3974 | struct sk_buff *skb = NULL; |
| 3975 | |
| 3976 | if (wlan_hdd_validate_context(pHddCtx)) { |
| 3977 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid ")); |
| 3978 | return -EINVAL; |
| 3979 | } |
| 3980 | |
| 3981 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
| 3982 | |
| 3983 | return -ENOTSUPP; |
| 3984 | } |
| 3985 | skb = cfg80211_vendor_event_alloc( |
| 3986 | pHddCtx->wiphy, |
| 3987 | EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 3988 | QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX, |
| 3989 | GFP_KERNEL); |
| 3990 | |
| 3991 | if (!skb) { |
| 3992 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3993 | FL("cfg80211_vendor_event_alloc failed")); |
| 3994 | return -EINVAL; |
| 3995 | } |
| 3996 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering ")); |
| 3997 | hddLog(VOS_TRACE_LEVEL_INFO, "Reason (%d) Status (%d)", reason, state); |
| 3998 | hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR, |
| 3999 | MAC_ADDR_ARRAY(mac)); |
| 4000 | |
| 4001 | if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR, |
| 4002 | VOS_MAC_ADDR_SIZE, mac) || |
| 4003 | nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE, state) || |
| 4004 | nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON, reason) |
| 4005 | ) { |
| 4006 | |
| 4007 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail")); |
| 4008 | goto nla_put_failure; |
| 4009 | } |
| 4010 | |
| 4011 | cfg80211_vendor_event(skb, GFP_KERNEL); |
| 4012 | return (0); |
| 4013 | |
| 4014 | nla_put_failure: |
| 4015 | kfree_skb(skb); |
| 4016 | return -EINVAL; |
| 4017 | } |
| 4018 | |
| 4019 | static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy, |
| 4020 | struct wireless_dev *wdev, |
| 4021 | void *data, |
| 4022 | int data_len) |
| 4023 | { |
| 4024 | u8 peer[6] = {0}; |
| 4025 | struct net_device *dev = wdev->netdev; |
| 4026 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4027 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4028 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1]; |
| 4029 | eHalStatus status; |
| 4030 | tdls_req_params_t pReqMsg = {0}; |
| 4031 | |
| 4032 | status = wlan_hdd_validate_context(pHddCtx); |
| 4033 | if (0 != status) { |
| 4034 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4035 | FL("HDD context is not valid")); |
| 4036 | return -EINVAL; |
| 4037 | } |
| 4038 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
| 4039 | |
| 4040 | return -ENOTSUPP; |
| 4041 | } |
| 4042 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX, |
| 4043 | data, data_len, |
| 4044 | wlan_hdd_tdls_config_enable_policy)) { |
| 4045 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4046 | return -EINVAL; |
| 4047 | } |
| 4048 | |
| 4049 | /* Parse and fetch mac address */ |
| 4050 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) { |
| 4051 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 4052 | return -EINVAL; |
| 4053 | } |
| 4054 | |
| 4055 | memcpy(peer, nla_data( |
| 4056 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]), |
| 4057 | sizeof(peer)); |
| 4058 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer)); |
| 4059 | |
| 4060 | /* Parse and fetch channel */ |
| 4061 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) { |
| 4062 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed")); |
| 4063 | return -EINVAL; |
| 4064 | } |
| 4065 | pReqMsg.channel = nla_get_s32( |
| 4066 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]); |
| 4067 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel); |
| 4068 | |
| 4069 | /* Parse and fetch global operating class */ |
| 4070 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) { |
| 4071 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed")); |
| 4072 | return -EINVAL; |
| 4073 | } |
| 4074 | pReqMsg.global_operating_class = nla_get_s32( |
| 4075 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]); |
| 4076 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"), |
| 4077 | pReqMsg.global_operating_class); |
| 4078 | |
| 4079 | /* Parse and fetch latency ms */ |
| 4080 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) { |
| 4081 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed")); |
| 4082 | return -EINVAL; |
| 4083 | } |
| 4084 | pReqMsg.max_latency_ms = nla_get_s32( |
| 4085 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]); |
| 4086 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"), |
| 4087 | pReqMsg.max_latency_ms); |
| 4088 | |
| 4089 | /* Parse and fetch required bandwidth kbps */ |
| 4090 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) { |
| 4091 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed")); |
| 4092 | return -EINVAL; |
| 4093 | } |
| 4094 | |
| 4095 | pReqMsg.min_bandwidth_kbps = nla_get_s32( |
| 4096 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]); |
| 4097 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"), |
| 4098 | pReqMsg.min_bandwidth_kbps); |
| 4099 | |
| 4100 | return (wlan_hdd_tdls_extctrl_config_peer(pAdapter, |
| 4101 | peer, |
| 4102 | wlan_hdd_cfg80211_exttdls_callback)); |
| 4103 | } |
| 4104 | |
| 4105 | static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy, |
| 4106 | struct wireless_dev *wdev, |
| 4107 | void *data, |
| 4108 | int data_len) |
| 4109 | { |
| 4110 | u8 peer[6] = {0}; |
| 4111 | struct net_device *dev = wdev->netdev; |
| 4112 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4113 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4114 | struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1]; |
| 4115 | eHalStatus status; |
| 4116 | |
| 4117 | status = wlan_hdd_validate_context(pHddCtx); |
| 4118 | if (0 != status) { |
| 4119 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4120 | FL("HDD context is not valid")); |
| 4121 | return -EINVAL; |
| 4122 | } |
| 4123 | if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) { |
| 4124 | |
| 4125 | return -ENOTSUPP; |
| 4126 | } |
| 4127 | if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX, |
| 4128 | data, data_len, |
| 4129 | wlan_hdd_tdls_config_disable_policy)) { |
| 4130 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR")); |
| 4131 | return -EINVAL; |
| 4132 | } |
| 4133 | /* Parse and fetch mac address */ |
| 4134 | if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) { |
| 4135 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed")); |
| 4136 | return -EINVAL; |
| 4137 | } |
| 4138 | |
| 4139 | memcpy(peer, nla_data( |
| 4140 | tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]), |
| 4141 | sizeof(peer)); |
| 4142 | hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer)); |
| 4143 | |
| 4144 | return (wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer)); |
| 4145 | } |
| 4146 | |
| 4147 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4148 | const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = |
| 4149 | { |
| 4150 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 4151 | { |
| 4152 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4153 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR, |
| 4154 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4155 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4156 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4157 | .doit = wlan_hdd_cfg80211_ll_stats_clear |
| 4158 | }, |
| 4159 | |
| 4160 | { |
| 4161 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4162 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET, |
| 4163 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4164 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4165 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4166 | .doit = wlan_hdd_cfg80211_ll_stats_set |
| 4167 | }, |
| 4168 | |
| 4169 | { |
| 4170 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4171 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET, |
| 4172 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4173 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4174 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4175 | .doit = wlan_hdd_cfg80211_ll_stats_get |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4176 | }, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4177 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4178 | #ifdef WLAN_FEATURE_EXTSCAN |
| 4179 | { |
| 4180 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4181 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START, |
| 4182 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4183 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4184 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4185 | .doit = wlan_hdd_cfg80211_extscan_start |
| 4186 | }, |
| 4187 | { |
| 4188 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4189 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP, |
| 4190 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4191 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4192 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4193 | .doit = wlan_hdd_cfg80211_extscan_stop |
| 4194 | }, |
| 4195 | { |
| 4196 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4197 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS, |
| 4198 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4199 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 4200 | .doit = wlan_hdd_cfg80211_extscan_get_valid_channels |
| 4201 | }, |
| 4202 | { |
| 4203 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4204 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES, |
| 4205 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4206 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4207 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4208 | .doit = wlan_hdd_cfg80211_extscan_get_capabilities |
| 4209 | }, |
| 4210 | { |
| 4211 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4212 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS, |
| 4213 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4214 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4215 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4216 | .doit = wlan_hdd_cfg80211_extscan_get_cached_results |
| 4217 | }, |
| 4218 | { |
| 4219 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4220 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST, |
| 4221 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4222 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4223 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4224 | .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist |
| 4225 | }, |
| 4226 | { |
| 4227 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4228 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST, |
| 4229 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4230 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4231 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4232 | .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist |
| 4233 | }, |
| 4234 | { |
| 4235 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4236 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE, |
| 4237 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4238 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4239 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4240 | .doit = wlan_hdd_cfg80211_extscan_set_significant_change |
| 4241 | }, |
| 4242 | { |
| 4243 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4244 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE, |
| 4245 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4246 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4247 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4248 | .doit = wlan_hdd_cfg80211_extscan_reset_significant_change |
| 4249 | }, |
| 4250 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4251 | /*EXT TDLS*/ |
| 4252 | { |
| 4253 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4254 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE, |
| 4255 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4256 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4257 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4258 | .doit = wlan_hdd_cfg80211_exttdls_enable |
| 4259 | }, |
| 4260 | { |
| 4261 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4262 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE, |
| 4263 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4264 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 4265 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 4266 | .doit = wlan_hdd_cfg80211_exttdls_disable |
| 4267 | }, |
| 4268 | { |
| 4269 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 4270 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS, |
| 4271 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 4272 | WIPHY_VENDOR_CMD_NEED_NETDEV, |
| 4273 | .doit = wlan_hdd_cfg80211_exttdls_get_status |
| 4274 | }, |
| 4275 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4276 | }; |
| 4277 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 4278 | /* vendor specific events */ |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4279 | static const |
| 4280 | struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 4281 | { |
| 4282 | #ifdef FEATURE_WLAN_CH_AVOID |
| 4283 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4284 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4285 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 4286 | }, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4287 | #endif /* FEATURE_WLAN_CH_AVOID Index = 0*/ |
| 4288 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 4289 | { |
| 4290 | /* Index = 1*/ |
| 4291 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4292 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET |
| 4293 | }, |
| 4294 | { |
| 4295 | /* Index = 2*/ |
| 4296 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4297 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET |
| 4298 | }, |
| 4299 | { |
| 4300 | /* Index = 3*/ |
| 4301 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4302 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR |
| 4303 | }, |
| 4304 | { |
| 4305 | /* Index = 4*/ |
| 4306 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4307 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS |
| 4308 | }, |
| 4309 | { |
| 4310 | /* Index = 5*/ |
| 4311 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4312 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS |
| 4313 | }, |
| 4314 | { |
| 4315 | /* Index = 6*/ |
| 4316 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4317 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS |
| 4318 | }, |
| 4319 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 4320 | #ifdef WLAN_FEATURE_EXTSCAN |
| 4321 | { |
| 4322 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4323 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START |
| 4324 | }, |
| 4325 | { |
| 4326 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4327 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP |
| 4328 | }, |
| 4329 | { |
| 4330 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4331 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES |
| 4332 | }, |
| 4333 | { |
| 4334 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4335 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS |
| 4336 | }, |
| 4337 | { |
| 4338 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4339 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE |
| 4340 | }, |
| 4341 | { |
| 4342 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4343 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT |
| 4344 | }, |
| 4345 | { |
| 4346 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4347 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT |
| 4348 | }, |
| 4349 | { |
| 4350 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4351 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND |
| 4352 | }, |
| 4353 | { |
| 4354 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4355 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST |
| 4356 | }, |
| 4357 | { |
| 4358 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4359 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST |
| 4360 | }, |
| 4361 | { |
| 4362 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4363 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE |
| 4364 | }, |
| 4365 | { |
| 4366 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4367 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE |
| 4368 | }, |
| 4369 | { |
| 4370 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4371 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE |
| 4372 | }, |
| 4373 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 4374 | /*EXT TDLS*/ |
| 4375 | { |
| 4376 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 4377 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE |
| 4378 | }, |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 4379 | }; |
| 4380 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4381 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4382 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4383 | * This function is called by hdd_wlan_startup() |
| 4384 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4385 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4386 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4387 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4388 | { |
| 4389 | struct wiphy *wiphy; |
| 4390 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4391 | /* |
| 4392 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4393 | */ |
| 4394 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 4395 | |
| 4396 | if (!wiphy) |
| 4397 | { |
| 4398 | /* Print error and jump into err label and free the memory */ |
| 4399 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 4400 | return NULL; |
| 4401 | } |
| 4402 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4403 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4404 | return wiphy; |
| 4405 | } |
| 4406 | |
| 4407 | /* |
| 4408 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4409 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4410 | * private ioctl to change the band value |
| 4411 | */ |
| 4412 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 4413 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 4414 | int i, j; |
| 4415 | eNVChannelEnabledType channelEnabledState; |
| 4416 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4417 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4418 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 4419 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4420 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 4421 | |
| 4422 | if (NULL == wiphy->bands[i]) |
| 4423 | { |
| 4424 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 4425 | __func__, i); |
| 4426 | continue; |
| 4427 | } |
| 4428 | |
| 4429 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 4430 | { |
| 4431 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 4432 | |
| 4433 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 4434 | band->channels[j].hw_value); |
| 4435 | |
| 4436 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 4437 | { |
| 4438 | // Enable Social channels for P2P |
| 4439 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 4440 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 4441 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 4442 | else |
| 4443 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 4444 | continue; |
| 4445 | } |
| 4446 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 4447 | { |
| 4448 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 4449 | continue; |
| 4450 | } |
| 4451 | |
| 4452 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 4453 | NV_CHANNEL_INVALID == channelEnabledState) |
| 4454 | { |
| 4455 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 4456 | } |
| 4457 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 4458 | { |
| 4459 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 4460 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 4461 | } |
| 4462 | else |
| 4463 | { |
| 4464 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 4465 | |IEEE80211_CHAN_RADAR); |
| 4466 | } |
| 4467 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4468 | } |
| 4469 | return 0; |
| 4470 | } |
| 4471 | /* |
| 4472 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4473 | * This function is called by hdd_wlan_startup() |
| 4474 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4475 | * This function is used to initialize and register wiphy structure. |
| 4476 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4477 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4478 | struct wiphy *wiphy, |
| 4479 | hdd_config_t *pCfg |
| 4480 | ) |
| 4481 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 4482 | int i, j; |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 4483 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4484 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4485 | ENTER(); |
| 4486 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4487 | /* Now bind the underlying wlan device with wiphy */ |
| 4488 | set_wiphy_dev(wiphy, dev); |
| 4489 | |
| 4490 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4491 | |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4492 | #ifndef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 4493 | /* the flag for the other case would be initialzed in |
| 4494 | vos_init_wiphy_from_nv_bin */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 4495 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4496 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 4497 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4498 | /* This will disable updating of NL channels from passive to |
| 4499 | * active if a beacon is received on passive channel. */ |
| 4500 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Amar Singhal | f007319 | 2013-09-20 12:34:56 -0700 | [diff] [blame] | 4501 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4502 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 4503 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4504 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4505 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 4506 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 4507 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4508 | | WIPHY_FLAG_OFFCHAN_TX; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4509 | wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4510 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 4511 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4512 | #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] | 4513 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 4514 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 4515 | || pCfg->isFastRoamIniFeatureEnabled |
| 4516 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4517 | #ifdef FEATURE_WLAN_ESE |
| 4518 | || pCfg->isEseIniFeatureEnabled |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 4519 | #endif |
| 4520 | ) |
| 4521 | { |
| 4522 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 4523 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 4524 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 4525 | #ifdef FEATURE_WLAN_TDLS |
| 4526 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 4527 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 4528 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 4529 | #ifdef FEATURE_WLAN_SCAN_PNO |
Hardik Kantilal Patel | 3dfd879 | 2013-11-13 20:34:57 +0530 | [diff] [blame] | 4530 | if (pCfg->configPNOScanSupport) |
| 4531 | { |
| 4532 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 4533 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
| 4534 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 4535 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
| 4536 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 4537 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 4538 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4539 | #ifdef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 4540 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 4541 | driver can still register regulatory callback and |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4542 | it will get regulatory settings in wiphy->band[], but |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 4543 | driver need to determine what to do with both |
| 4544 | regulatory settings */ |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4545 | |
| 4546 | wiphy->reg_notifier = wlan_hdd_linux_reg_notifier; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 4547 | #else |
| 4548 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 4549 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4550 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4551 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 4552 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 4553 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4554 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 4555 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 4556 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4557 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4558 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4559 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4560 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 4561 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4562 | | BIT(NL80211_IFTYPE_AP); |
| 4563 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 4564 | if( pCfg->advertiseConcurrentOperation ) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 4565 | { |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 4566 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 4567 | if( pCfg->enableMCC ) |
| 4568 | { |
| 4569 | /* Currently, supports up to two channels */ |
| 4570 | wlan_hdd_iface_combination.num_different_channels = 2; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 4571 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 4572 | if( !pCfg->allowMCCGODiffBI ) |
| 4573 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 4574 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 4575 | } |
| 4576 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 4577 | wiphy->n_iface_combinations = 1; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 4578 | #endif |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 4579 | } |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 4580 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4581 | /* Before registering we need to update the ht capabilitied based |
| 4582 | * on ini values*/ |
| 4583 | if( !pCfg->ShortGI20MhzEnable ) |
| 4584 | { |
| 4585 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 4586 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 4587 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 4588 | } |
| 4589 | |
| 4590 | if( !pCfg->ShortGI40MhzEnable ) |
| 4591 | { |
| 4592 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 4593 | } |
| 4594 | |
| 4595 | if( !pCfg->nChannelBondingMode5GHz ) |
| 4596 | { |
| 4597 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 4598 | } |
| 4599 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 4600 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 4601 | if (true == hdd_is_5g_supported(pHddCtx)) |
| 4602 | { |
| 4603 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 4604 | } |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 4605 | |
| 4606 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 4607 | { |
| 4608 | |
| 4609 | if (NULL == wiphy->bands[i]) |
| 4610 | { |
| 4611 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 4612 | __func__, i); |
| 4613 | continue; |
| 4614 | } |
| 4615 | |
| 4616 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 4617 | { |
| 4618 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 4619 | |
| 4620 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 4621 | { |
| 4622 | // Enable social channels for P2P |
| 4623 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 4624 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 4625 | else |
| 4626 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 4627 | continue; |
| 4628 | } |
| 4629 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 4630 | { |
| 4631 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 4632 | continue; |
| 4633 | } |
| 4634 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4635 | } |
| 4636 | /*Initialise the supported cipher suite details*/ |
| 4637 | wiphy->cipher_suites = hdd_cipher_suites; |
| 4638 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 4639 | |
| 4640 | /*signal strength in mBm (100*dBm) */ |
| 4641 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 4642 | |
| 4643 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Sushant Kaushik | 4f640e4 | 2014-07-08 12:27:09 +0530 | [diff] [blame] | 4644 | wiphy->max_remain_on_channel_duration = 5000; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4645 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4646 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 4647 | wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands); |
| 4648 | wiphy->vendor_commands = hdd_wiphy_vendor_commands; |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 4649 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 4650 | wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 4651 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4652 | EXIT(); |
| 4653 | return 0; |
| 4654 | } |
| 4655 | |
| 4656 | /* In this function we are registering wiphy. */ |
| 4657 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 4658 | { |
| 4659 | ENTER(); |
| 4660 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4661 | if (0 > wiphy_register(wiphy)) |
| 4662 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4663 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4664 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 4665 | return -EIO; |
| 4666 | } |
| 4667 | |
| 4668 | EXIT(); |
| 4669 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4670 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4671 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4672 | /* In this function we are updating channel list when, |
| 4673 | regulatory domain is FCC and country code is US. |
| 4674 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 4675 | As per FCC smart phone is not a indoor device. |
| 4676 | GO should not opeate on indoor channels */ |
| 4677 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 4678 | { |
| 4679 | int j; |
| 4680 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4681 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 4682 | //Default counrtycode from NV at the time of wiphy initialization. |
| 4683 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 4684 | &defaultCountryCode[0])) |
| 4685 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 4686 | hddLog(LOGE, FL("Failed to get default country code from NV")); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4687 | } |
| 4688 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 4689 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 4690 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 4691 | { |
| 4692 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 4693 | return; |
| 4694 | } |
| 4695 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 4696 | { |
| 4697 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 4698 | // Mark UNII -1 band channel as passive |
| 4699 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 4700 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 4701 | } |
| 4702 | } |
| 4703 | } |
| 4704 | |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 4705 | /* This function registers for all frame which supplicant is interested in */ |
| 4706 | void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4707 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4708 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4709 | /* Register for all P2P action, public action etc frames */ |
| 4710 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 4711 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4712 | ENTER(); |
| 4713 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4714 | /* Right now we are registering these frame when driver is getting |
| 4715 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 4716 | frame register ops, we will move this code as a part of that */ |
| 4717 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4718 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4719 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 4720 | |
| 4721 | /* GAS Initial Response */ |
| 4722 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4723 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4724 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4725 | /* GAS Comeback Request */ |
| 4726 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4727 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 4728 | |
| 4729 | /* GAS Comeback Response */ |
| 4730 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4731 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 4732 | |
| 4733 | /* P2P Public Action */ |
| 4734 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4735 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4736 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 4737 | |
| 4738 | /* P2P Action */ |
| 4739 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4740 | (v_U8_t*)P2P_ACTION_FRAME, |
| 4741 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 4742 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 4743 | /* WNM BSS Transition Request frame */ |
| 4744 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4745 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 4746 | WNM_BSS_ACTION_FRAME_SIZE ); |
Leela Venkata Kiran Kumar Reddy Chirala | e8e62c8 | 2013-10-29 18:23:26 -0700 | [diff] [blame] | 4747 | |
| 4748 | /* WNM-Notification */ |
| 4749 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4750 | (v_U8_t*)WNM_NOTIFICATION_FRAME, |
| 4751 | WNM_NOTIFICATION_FRAME_SIZE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4752 | } |
| 4753 | |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 4754 | void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4755 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4756 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4757 | /* Register for all P2P action, public action etc frames */ |
| 4758 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 4759 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4760 | ENTER(); |
| 4761 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4762 | /* Right now we are registering these frame when driver is getting |
| 4763 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 4764 | frame register ops, we will move this code as a part of that */ |
| 4765 | /* GAS Initial Request */ |
| 4766 | |
| 4767 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4768 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 4769 | |
| 4770 | /* GAS Initial Response */ |
| 4771 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4772 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4773 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4774 | /* GAS Comeback Request */ |
| 4775 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4776 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 4777 | |
| 4778 | /* GAS Comeback Response */ |
| 4779 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4780 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 4781 | |
| 4782 | /* P2P Public Action */ |
| 4783 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4784 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4785 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 4786 | |
| 4787 | /* P2P Action */ |
| 4788 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4789 | (v_U8_t*)P2P_ACTION_FRAME, |
| 4790 | P2P_ACTION_FRAME_SIZE ); |
Leela Venkata Kiran Kumar Reddy Chirala | e8e62c8 | 2013-10-29 18:23:26 -0700 | [diff] [blame] | 4791 | /* WNM-Notification */ |
| 4792 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 4793 | (v_U8_t*)WNM_NOTIFICATION_FRAME, |
| 4794 | WNM_NOTIFICATION_FRAME_SIZE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4795 | } |
| 4796 | |
| 4797 | #ifdef FEATURE_WLAN_WAPI |
| 4798 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 4799 | const u8 *mac_addr, u8 *key , int key_Len) |
| 4800 | { |
| 4801 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4802 | tCsrRoamSetKey setKey; |
| 4803 | v_BOOL_t isConnected = TRUE; |
| 4804 | int status = 0; |
| 4805 | v_U32_t roamId= 0xFF; |
| 4806 | tANI_U8 *pKeyPtr = NULL; |
| 4807 | int n = 0; |
| 4808 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 4809 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)", |
| 4810 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 4811 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4812 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 4813 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4814 | setKey.keyId = key_index; // Store Key ID |
| 4815 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 4816 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 4817 | setKey.paeRole = 0 ; // the PAE role |
| 4818 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 4819 | { |
| 4820 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 4821 | } |
| 4822 | else |
| 4823 | { |
| 4824 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 4825 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 4826 | } |
| 4827 | setKey.keyLength = key_Len; |
| 4828 | pKeyPtr = setKey.Key; |
| 4829 | memcpy( pKeyPtr, key, key_Len); |
| 4830 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4831 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4832 | __func__, key_Len); |
| 4833 | for (n = 0 ; n < key_Len; n++) |
| 4834 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 4835 | __func__,n,setKey.Key[n]); |
| 4836 | |
| 4837 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 4838 | if ( isConnected ) |
| 4839 | { |
| 4840 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4841 | pAdapter->sessionId, &setKey, &roamId ); |
| 4842 | } |
| 4843 | if ( status != 0 ) |
| 4844 | { |
| 4845 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4846 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 4847 | __LINE__, status ); |
| 4848 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 4849 | } |
| 4850 | } |
| 4851 | #endif /* FEATURE_WLAN_WAPI*/ |
| 4852 | |
| 4853 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4854 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4855 | beacon_data_t **ppBeacon, |
| 4856 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4857 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4858 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4859 | beacon_data_t **ppBeacon, |
| 4860 | struct cfg80211_beacon_data *params, |
| 4861 | int dtim_period) |
| 4862 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4863 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4864 | int size; |
| 4865 | beacon_data_t *beacon = NULL; |
| 4866 | beacon_data_t *old = NULL; |
| 4867 | int head_len,tail_len; |
| 4868 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4869 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4870 | if (params->head && !params->head_len) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4871 | { |
| 4872 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4873 | FL("head_len is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4874 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4875 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4876 | |
| 4877 | old = pAdapter->sessionCtx.ap.beacon; |
| 4878 | |
| 4879 | if (!params->head && !old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4880 | { |
| 4881 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4882 | FL("session(%d) old and new heads points to NULL"), |
| 4883 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4884 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4885 | } |
| 4886 | |
| 4887 | if (params->tail && !params->tail_len) |
| 4888 | { |
| 4889 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4890 | FL("tail_len is zero but tail is not NULL")); |
| 4891 | return -EINVAL; |
| 4892 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4893 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4894 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 4895 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 4896 | if (!params->dtim_period) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4897 | { |
| 4898 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4899 | FL("dtim period is 0")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4900 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4901 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4902 | #endif |
| 4903 | |
| 4904 | if(params->head) |
| 4905 | head_len = params->head_len; |
| 4906 | else |
| 4907 | head_len = old->head_len; |
| 4908 | |
| 4909 | if(params->tail || !old) |
| 4910 | tail_len = params->tail_len; |
| 4911 | else |
| 4912 | tail_len = old->tail_len; |
| 4913 | |
| 4914 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 4915 | |
| 4916 | beacon = kzalloc(size, GFP_KERNEL); |
| 4917 | |
| 4918 | if( beacon == NULL ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4919 | { |
| 4920 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4921 | FL("Mem allocation for beacon failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4922 | return -ENOMEM; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4923 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4924 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4925 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4926 | if(params->dtim_period || !old ) |
| 4927 | beacon->dtim_period = params->dtim_period; |
| 4928 | else |
| 4929 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4930 | #else |
| 4931 | if(dtim_period || !old ) |
| 4932 | beacon->dtim_period = dtim_period; |
| 4933 | else |
| 4934 | beacon->dtim_period = old->dtim_period; |
| 4935 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4936 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4937 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 4938 | beacon->tail = beacon->head + head_len; |
| 4939 | beacon->head_len = head_len; |
| 4940 | beacon->tail_len = tail_len; |
| 4941 | |
| 4942 | if(params->head) { |
| 4943 | memcpy (beacon->head,params->head,beacon->head_len); |
| 4944 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4945 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4946 | if(old) |
| 4947 | memcpy (beacon->head,old->head,beacon->head_len); |
| 4948 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4949 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4950 | if(params->tail) { |
| 4951 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 4952 | } |
| 4953 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4954 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4955 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 4956 | } |
| 4957 | |
| 4958 | *ppBeacon = beacon; |
| 4959 | |
| 4960 | kfree(old); |
| 4961 | |
| 4962 | return 0; |
| 4963 | |
| 4964 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4965 | |
| 4966 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 4967 | { |
| 4968 | int left = length; |
| 4969 | v_U8_t *ptr = pIes; |
| 4970 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4972 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4973 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4974 | elem_id = ptr[0]; |
| 4975 | elem_len = ptr[1]; |
| 4976 | left -= 2; |
| 4977 | if(elem_len > left) |
| 4978 | { |
| 4979 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 4980 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4981 | eid,elem_len,left); |
| 4982 | return NULL; |
| 4983 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4984 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4985 | { |
| 4986 | return ptr; |
| 4987 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4988 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4989 | left -= elem_len; |
| 4990 | ptr += (elem_len + 2); |
| 4991 | } |
| 4992 | return NULL; |
| 4993 | } |
| 4994 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4995 | /* Check if rate is 11g rate or not */ |
| 4996 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 4997 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 4998 | 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] | 4999 | u8 i; |
| 5000 | for (i = 0; i < 8; i++) |
| 5001 | { |
| 5002 | if(rate == gRateArray[i]) |
| 5003 | return TRUE; |
| 5004 | } |
| 5005 | return FALSE; |
| 5006 | } |
| 5007 | |
| 5008 | /* Check for 11g rate and set proper 11g only mode */ |
| 5009 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 5010 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 5011 | { |
| 5012 | u8 i, num_rates = pIe[0]; |
| 5013 | |
| 5014 | pIe += 1; |
| 5015 | for ( i = 0; i < num_rates; i++) |
| 5016 | { |
| 5017 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 5018 | { |
| 5019 | /* If rate set have 11g rate than change the mode to 11G */ |
| 5020 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 5021 | if (pIe[i] & BASIC_RATE_MASK) |
| 5022 | { |
| 5023 | /* If we have 11g rate as basic rate, it means mode |
| 5024 | is 11g only mode. |
| 5025 | */ |
| 5026 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 5027 | *pCheckRatesfor11g = FALSE; |
| 5028 | } |
| 5029 | } |
| 5030 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 5031 | { |
| 5032 | *require_ht = TRUE; |
| 5033 | } |
| 5034 | } |
| 5035 | return; |
| 5036 | } |
| 5037 | |
| 5038 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 5039 | { |
| 5040 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 5041 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 5042 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 5043 | u8 checkRatesfor11g = TRUE; |
| 5044 | u8 require_ht = FALSE; |
| 5045 | u8 *pIe=NULL; |
| 5046 | |
| 5047 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 5048 | |
| 5049 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 5050 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 5051 | if (pIe != NULL) |
| 5052 | { |
| 5053 | pIe += 1; |
| 5054 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 5055 | &pConfig->SapHw_mode); |
| 5056 | } |
| 5057 | |
| 5058 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 5059 | WLAN_EID_EXT_SUPP_RATES); |
| 5060 | if (pIe != NULL) |
| 5061 | { |
| 5062 | |
| 5063 | pIe += 1; |
| 5064 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 5065 | &pConfig->SapHw_mode); |
| 5066 | } |
| 5067 | |
| 5068 | if( pConfig->channel > 14 ) |
| 5069 | { |
| 5070 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 5071 | } |
| 5072 | |
| 5073 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 5074 | WLAN_EID_HT_CAPABILITY); |
| 5075 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5076 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5077 | { |
| 5078 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 5079 | if(require_ht) |
| 5080 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 5081 | } |
| 5082 | } |
| 5083 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5084 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 5085 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 5086 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 5087 | v_U16_t ielen = 0; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5088 | v_U8_t *pIe = NULL; |
| 5089 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 5090 | |
| 5091 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 5092 | pBeacon->tail, pBeacon->tail_len); |
| 5093 | |
| 5094 | if (pIe) |
| 5095 | { |
| 5096 | ielen = pIe[1] + 2; |
| 5097 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 5098 | { |
| 5099 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 5100 | } |
| 5101 | else |
| 5102 | { |
| 5103 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 5104 | return -EINVAL; |
| 5105 | } |
| 5106 | *total_ielen += ielen; |
| 5107 | } |
| 5108 | return 0; |
| 5109 | } |
| 5110 | |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 5111 | static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter, |
| 5112 | v_U8_t *genie, v_U8_t *total_ielen) |
| 5113 | { |
| 5114 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 5115 | int left = pBeacon->tail_len; |
| 5116 | v_U8_t *ptr = pBeacon->tail; |
| 5117 | v_U8_t elem_id, elem_len; |
| 5118 | v_U16_t ielen = 0; |
| 5119 | |
| 5120 | if ( NULL == ptr || 0 == left ) |
| 5121 | return; |
| 5122 | |
| 5123 | while (left >= 2) |
| 5124 | { |
| 5125 | elem_id = ptr[0]; |
| 5126 | elem_len = ptr[1]; |
| 5127 | left -= 2; |
| 5128 | if (elem_len > left) |
| 5129 | { |
| 5130 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 5131 | "****Invalid IEs eid = %d elem_len=%d left=%d*****", |
| 5132 | elem_id, elem_len, left); |
| 5133 | return; |
| 5134 | } |
| 5135 | if (IE_EID_VENDOR == elem_id) |
| 5136 | { |
| 5137 | /* skipping the VSIE's which we don't want to include or |
| 5138 | * it will be included by existing code |
| 5139 | */ |
| 5140 | if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) && |
| 5141 | #ifdef WLAN_FEATURE_WFD |
| 5142 | (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) && |
| 5143 | #endif |
| 5144 | (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 5145 | (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 5146 | (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) && |
| 5147 | (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 5148 | (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0)) |
| 5149 | { |
| 5150 | ielen = ptr[1] + 2; |
| 5151 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 5152 | { |
| 5153 | vos_mem_copy(&genie[*total_ielen], ptr, ielen); |
| 5154 | *total_ielen += ielen; |
| 5155 | } |
| 5156 | else |
| 5157 | { |
| 5158 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 5159 | "IE Length is too big " |
| 5160 | "IEs eid=%d elem_len=%d total_ie_lent=%d", |
| 5161 | elem_id, elem_len, *total_ielen); |
| 5162 | } |
| 5163 | } |
| 5164 | } |
| 5165 | |
| 5166 | left -= elem_len; |
| 5167 | ptr += (elem_len + 2); |
| 5168 | } |
| 5169 | return; |
| 5170 | } |
| 5171 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5172 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5173 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 5174 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5175 | #else |
| 5176 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 5177 | struct cfg80211_beacon_data *params) |
| 5178 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5179 | { |
| 5180 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5181 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5182 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5183 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5184 | |
| 5185 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 5186 | |
| 5187 | if(genie == NULL) { |
| 5188 | |
| 5189 | return -ENOMEM; |
| 5190 | } |
| 5191 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5192 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 5193 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5194 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5195 | hddLog(LOGE, |
| 5196 | FL("Adding WPS IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5197 | ret = -EINVAL; |
| 5198 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5199 | } |
| 5200 | |
| 5201 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5202 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 5203 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 5204 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5205 | hddLog(LOGE, |
| 5206 | FL("Adding WFD IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5207 | ret = -EINVAL; |
| 5208 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5209 | } |
| 5210 | #endif |
| 5211 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5212 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 5213 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5214 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5215 | hddLog(LOGE, |
| 5216 | FL("Adding P2P IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5217 | ret = -EINVAL; |
| 5218 | goto done; |
| 5219 | } |
| 5220 | |
| 5221 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 5222 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 5223 | wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5224 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5225 | |
| 5226 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5227 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 5228 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 5229 | { |
| 5230 | hddLog(LOGE, |
| 5231 | "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] | 5232 | ret = -EINVAL; |
| 5233 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5234 | } |
| 5235 | |
| 5236 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5237 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 5238 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 5239 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 5240 | ==eHAL_STATUS_FAILURE) |
| 5241 | { |
| 5242 | hddLog(LOGE, |
| 5243 | "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] | 5244 | ret = -EINVAL; |
| 5245 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5246 | } |
| 5247 | |
| 5248 | // Added for ProResp IE |
| 5249 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 5250 | { |
| 5251 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 5252 | u8 probe_rsp_ie_len[3] = {0}; |
| 5253 | u8 counter = 0; |
| 5254 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 5255 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 5256 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 5257 | Store More then 255 bytes into One Variable. |
| 5258 | */ |
| 5259 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 5260 | { |
| 5261 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 5262 | { |
| 5263 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 5264 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 5265 | } |
| 5266 | else |
| 5267 | { |
| 5268 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 5269 | rem_probe_resp_ie_len = 0; |
| 5270 | } |
| 5271 | } |
| 5272 | |
| 5273 | rem_probe_resp_ie_len = 0; |
| 5274 | |
| 5275 | if (probe_rsp_ie_len[0] > 0) |
| 5276 | { |
| 5277 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5278 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 5279 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 5280 | probe_rsp_ie_len[0], NULL, |
| 5281 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5282 | { |
| 5283 | hddLog(LOGE, |
| 5284 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5285 | ret = -EINVAL; |
| 5286 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5287 | } |
| 5288 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 5289 | } |
| 5290 | |
| 5291 | if (probe_rsp_ie_len[1] > 0) |
| 5292 | { |
| 5293 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5294 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 5295 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 5296 | probe_rsp_ie_len[1], NULL, |
| 5297 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5298 | { |
| 5299 | hddLog(LOGE, |
| 5300 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5301 | ret = -EINVAL; |
| 5302 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5303 | } |
| 5304 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 5305 | } |
| 5306 | |
| 5307 | if (probe_rsp_ie_len[2] > 0) |
| 5308 | { |
| 5309 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5310 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 5311 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 5312 | probe_rsp_ie_len[2], NULL, |
| 5313 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5314 | { |
| 5315 | hddLog(LOGE, |
| 5316 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5317 | ret = -EINVAL; |
| 5318 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5319 | } |
| 5320 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 5321 | } |
| 5322 | |
| 5323 | if (probe_rsp_ie_len[1] == 0 ) |
| 5324 | { |
| 5325 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5326 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 5327 | eANI_BOOLEAN_FALSE) ) |
| 5328 | { |
| 5329 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5330 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5331 | } |
| 5332 | } |
| 5333 | |
| 5334 | if (probe_rsp_ie_len[2] == 0 ) |
| 5335 | { |
| 5336 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5337 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 5338 | eANI_BOOLEAN_FALSE) ) |
| 5339 | { |
| 5340 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5341 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5342 | } |
| 5343 | } |
| 5344 | |
| 5345 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5346 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 5347 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 5348 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 5349 | == eHAL_STATUS_FAILURE) |
| 5350 | { |
| 5351 | hddLog(LOGE, |
| 5352 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5353 | ret = -EINVAL; |
| 5354 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5355 | } |
| 5356 | } |
| 5357 | else |
| 5358 | { |
| 5359 | // Reset WNI_CFG_PROBE_RSP Flags |
| 5360 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 5361 | |
| 5362 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5363 | "%s: No Probe Response IE received in set beacon", |
| 5364 | __func__); |
| 5365 | } |
| 5366 | |
| 5367 | // Added for AssocResp IE |
| 5368 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 5369 | { |
| 5370 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5371 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 5372 | params->assocresp_ies_len, NULL, |
| 5373 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5374 | { |
| 5375 | hddLog(LOGE, |
| 5376 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5377 | ret = -EINVAL; |
| 5378 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5379 | } |
| 5380 | |
| 5381 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5382 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 5383 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 5384 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 5385 | == eHAL_STATUS_FAILURE) |
| 5386 | { |
| 5387 | hddLog(LOGE, |
| 5388 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5389 | ret = -EINVAL; |
| 5390 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5391 | } |
| 5392 | } |
| 5393 | else |
| 5394 | { |
| 5395 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5396 | "%s: No Assoc Response IE received in set beacon", |
| 5397 | __func__); |
| 5398 | |
| 5399 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 5400 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 5401 | eANI_BOOLEAN_FALSE) ) |
| 5402 | { |
| 5403 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5404 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5405 | } |
| 5406 | } |
| 5407 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5408 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5409 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 5410 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5411 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5412 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5413 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5414 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 5415 | * called by wlan_hdd_cfg80211_start_bss() and |
| 5416 | * wlan_hdd_cfg80211_set_channel() |
| 5417 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5418 | * channel list. |
| 5419 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5420 | 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] | 5421 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5422 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5423 | v_U32_t num_ch = 0; |
| 5424 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5425 | u32 indx = 0; |
| 5426 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 5427 | v_U8_t fValidChannel = FALSE, count = 0; |
| 5428 | 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] | 5429 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5430 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 5431 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 5432 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5433 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 5434 | /* Validate the channel */ |
| 5435 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5436 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 5437 | if ( channel == rfChannels[count].channelNum ) |
| 5438 | { |
| 5439 | fValidChannel = TRUE; |
| 5440 | break; |
| 5441 | } |
| 5442 | } |
| 5443 | if (fValidChannel != TRUE) |
| 5444 | { |
| 5445 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5446 | "%s: Invalid Channel [%d]", __func__, channel); |
| 5447 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | } |
| 5449 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 5450 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5451 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 5452 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 5453 | valid_ch, &num_ch)) |
| 5454 | { |
| 5455 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5456 | "%s: failed to get valid channel list", __func__); |
| 5457 | return VOS_STATUS_E_FAILURE; |
| 5458 | } |
| 5459 | for (indx = 0; indx < num_ch; indx++) |
| 5460 | { |
| 5461 | if (channel == valid_ch[indx]) |
| 5462 | { |
| 5463 | break; |
| 5464 | } |
| 5465 | } |
| 5466 | |
Rashmi Ramanna | 3b59e12 | 2014-04-10 14:45:13 +0530 | [diff] [blame] | 5467 | if (indx >= num_ch) |
| 5468 | { |
| 5469 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 5470 | { |
| 5471 | eCsrBand band; |
| 5472 | unsigned int freq; |
| 5473 | |
| 5474 | sme_GetFreqBand(hHal, &band); |
| 5475 | |
| 5476 | if (eCSR_BAND_5G == band) |
| 5477 | { |
| 5478 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 5479 | if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 5480 | { |
| 5481 | freq = ieee80211_channel_to_frequency(channel, |
| 5482 | IEEE80211_BAND_2GHZ); |
| 5483 | } |
| 5484 | else |
| 5485 | { |
| 5486 | freq = ieee80211_channel_to_frequency(channel, |
| 5487 | IEEE80211_BAND_5GHZ); |
| 5488 | } |
| 5489 | #else |
| 5490 | freq = ieee80211_channel_to_frequency(channel); |
| 5491 | #endif |
| 5492 | if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq)) |
| 5493 | return VOS_STATUS_SUCCESS; |
| 5494 | } |
| 5495 | } |
| 5496 | |
| 5497 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5498 | "%s: Invalid Channel [%d]", __func__, channel); |
| 5499 | return VOS_STATUS_E_FAILURE; |
| 5500 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5501 | } |
Rashmi Ramanna | 3b59e12 | 2014-04-10 14:45:13 +0530 | [diff] [blame] | 5502 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5503 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5504 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5505 | } |
| 5506 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5507 | /** |
| 5508 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 5509 | * This function is used to set the channel number |
| 5510 | */ |
| 5511 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 5512 | struct ieee80211_channel *chan, |
| 5513 | enum nl80211_channel_type channel_type |
| 5514 | ) |
| 5515 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5516 | hdd_adapter_t *pAdapter = NULL; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5517 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 5518 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5519 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5520 | hdd_context_t *pHddCtx; |
| 5521 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5522 | |
| 5523 | ENTER(); |
| 5524 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5525 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5526 | if( NULL == dev ) |
| 5527 | { |
| 5528 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5529 | "%s: Called with dev = NULL.", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5530 | return -ENODEV; |
| 5531 | } |
| 5532 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 5533 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5534 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 5535 | TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId, |
| 5536 | channel_type )); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5537 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 5538 | "%s: device_mode = %s (%d) freq = %d", __func__, |
| 5539 | hdd_device_modetoString(pAdapter->device_mode), |
| 5540 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5541 | |
| 5542 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5543 | status = wlan_hdd_validate_context(pHddCtx); |
| 5544 | |
| 5545 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5546 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5547 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5548 | "%s: HDD context is not valid", __func__); |
| 5549 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5550 | } |
| 5551 | |
| 5552 | /* |
| 5553 | * Do freq to chan conversion |
| 5554 | * TODO: for 11a |
| 5555 | */ |
| 5556 | |
| 5557 | channel = ieee80211_frequency_to_channel(freq); |
| 5558 | |
| 5559 | /* Check freq range */ |
| 5560 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 5561 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 5562 | { |
| 5563 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5564 | "%s: Channel [%d] is outside valid range from %d to %d", |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5565 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 5566 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 5567 | return -EINVAL; |
| 5568 | } |
| 5569 | |
| 5570 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 5571 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 5572 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 5573 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5574 | { |
| 5575 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 5576 | { |
| 5577 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5578 | "%s: Invalid Channel [%d]", __func__, channel); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5579 | return -EINVAL; |
| 5580 | } |
| 5581 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 5582 | "%s: set channel to [%d] for device mode =%d", |
| 5583 | __func__, channel,pAdapter->device_mode); |
| 5584 | } |
| 5585 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5586 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5587 | ) |
| 5588 | { |
| 5589 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5590 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 5591 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5592 | |
| 5593 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 5594 | { |
| 5595 | /* Link is up then return cant set channel*/ |
| 5596 | hddLog( VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5597 | "%s: IBSS Associated, can't set the channel", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5598 | return -EINVAL; |
| 5599 | } |
| 5600 | |
| 5601 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5602 | pHddStaCtx->conn_info.operationChannel = channel; |
| 5603 | pRoamProfile->ChannelInfo.ChannelList = |
| 5604 | &pHddStaCtx->conn_info.operationChannel; |
| 5605 | } |
| 5606 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5607 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5608 | ) |
| 5609 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 5610 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 5611 | { |
| 5612 | if(VOS_STATUS_SUCCESS != |
| 5613 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 5614 | { |
| 5615 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5616 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 5617 | return -EINVAL; |
| 5618 | } |
| 5619 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 5620 | } |
| 5621 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5622 | { |
| 5623 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 5624 | |
| 5625 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 5626 | channel set by supplicant |
| 5627 | */ |
| 5628 | if ( cfg_param->apAutoChannelSelection ) |
| 5629 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 5630 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 5631 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5632 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 5633 | "%s: set channel to auto channel (0) for device mode =%s (%d)", |
| 5634 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 5635 | pAdapter->device_mode); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5636 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 5637 | else |
| 5638 | { |
| 5639 | if(VOS_STATUS_SUCCESS != |
| 5640 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 5641 | { |
| 5642 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5643 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 5644 | return -EINVAL; |
| 5645 | } |
| 5646 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 5647 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5648 | } |
| 5649 | } |
| 5650 | else |
| 5651 | { |
| 5652 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5653 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 5654 | return -EINVAL; |
| 5655 | } |
| 5656 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5657 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 5658 | } |
| 5659 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5660 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 5661 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 5662 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5663 | #else |
| 5664 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 5665 | struct cfg80211_beacon_data *params, |
| 5666 | const u8 *ssid, size_t ssid_len, |
| 5667 | enum nl80211_hidden_ssid hidden_ssid) |
| 5668 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5669 | { |
| 5670 | tsap_Config_t *pConfig; |
| 5671 | beacon_data_t *pBeacon = NULL; |
| 5672 | struct ieee80211_mgmt *pMgmt_frame; |
| 5673 | v_U8_t *pIe=NULL; |
| 5674 | v_U16_t capab_info; |
| 5675 | eCsrAuthType RSNAuthType; |
| 5676 | eCsrEncryptionType RSNEncryptType; |
| 5677 | eCsrEncryptionType mcRSNEncryptType; |
| 5678 | int status = VOS_STATUS_SUCCESS; |
| 5679 | tpWLAN_SAPEventCB pSapEventCallback; |
| 5680 | hdd_hostapd_state_t *pHostapdState; |
| 5681 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 5682 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 5683 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5684 | struct qc_mac_acl_entry *acl_entry = NULL; |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 5685 | hdd_config_t *iniConfig; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5686 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 5687 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Chet Lanctot | 4014244 | 2014-05-20 13:39:25 -0700 | [diff] [blame] | 5688 | v_BOOL_t MFPCapable = VOS_FALSE; |
| 5689 | v_BOOL_t MFPRequired = VOS_FALSE; |
Abhishek Singh | f0ac175 | 2014-03-05 17:47:09 +0530 | [diff] [blame] | 5690 | eHddDot11Mode sapDot11Mode = |
| 5691 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5692 | |
| 5693 | ENTER(); |
| 5694 | |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 5695 | iniConfig = pHddCtx->cfg_ini; |
| 5696 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5697 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 5698 | |
| 5699 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 5700 | |
| 5701 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 5702 | |
| 5703 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 5704 | |
| 5705 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 5706 | |
| 5707 | //channel is already set in the set_channel Call back |
| 5708 | //pConfig->channel = pCommitConfig->channel; |
| 5709 | |
| 5710 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5711 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5712 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 5713 | |
| 5714 | pConfig->dtim_period = pBeacon->dtim_period; |
| 5715 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5716 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5717 | pConfig->dtim_period); |
| 5718 | |
| 5719 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 5720 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5721 | { |
| 5722 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5723 | WLAN_EID_COUNTRY); |
Kiet Lam | 083504c | 2013-11-25 14:17:45 +0530 | [diff] [blame] | 5724 | if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0) |
| 5725 | { |
| 5726 | tANI_BOOLEAN restartNeeded; |
| 5727 | pConfig->ieee80211d = 1; |
| 5728 | vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3); |
| 5729 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 5730 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
| 5731 | } |
| 5732 | else if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5733 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5734 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5735 | pConfig->ieee80211d = 1; |
| 5736 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 5737 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 5738 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5739 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5740 | else |
| 5741 | { |
| 5742 | pConfig->ieee80211d = 0; |
| 5743 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 5744 | /* |
| 5745 | * If auto channel is configured i.e. channel is 0, |
| 5746 | * so skip channel validation. |
| 5747 | */ |
| 5748 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 5749 | { |
| 5750 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 5751 | { |
| 5752 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5753 | "%s: Invalid Channel [%d]", __func__, pConfig->channel); |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 5754 | return -EINVAL; |
| 5755 | } |
| 5756 | } |
| 5757 | else |
| 5758 | { |
| 5759 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 5760 | { |
| 5761 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 5762 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 5763 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 5764 | } |
| 5765 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 5766 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5767 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5768 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5769 | { |
| 5770 | pConfig->ieee80211d = 0; |
| 5771 | } |
| 5772 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 5773 | |
| 5774 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5775 | |
| 5776 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5777 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 5778 | |
| 5779 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 5780 | |
| 5781 | /*Set wps station to configured*/ |
| 5782 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 5783 | |
| 5784 | if(pIe) |
| 5785 | { |
| 5786 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 5787 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5788 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5789 | return -EINVAL; |
| 5790 | } |
| 5791 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 5792 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5793 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5794 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 5795 | * WPS state |
| 5796 | */ |
| 5797 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 5798 | { |
| 5799 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 5800 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 5801 | { |
| 5802 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 5803 | } |
| 5804 | } |
| 5805 | } |
| 5806 | else |
| 5807 | { |
| 5808 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 5809 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5810 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5811 | |
c_hpothu | fe599e9 | 2014-06-16 11:38:55 +0530 | [diff] [blame] | 5812 | pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE; |
| 5813 | pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE; |
| 5814 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType = |
| 5815 | eCSR_ENCRYPT_TYPE_NONE; |
| 5816 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5817 | pConfig->RSNWPAReqIELength = 0; |
| 5818 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5819 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5820 | WLAN_EID_RSN); |
| 5821 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5822 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5823 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 5824 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 5825 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5826 | /* The actual processing may eventually be more extensive than |
| 5827 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5828 | * by the app. |
| 5829 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5830 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5831 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 5832 | &RSNEncryptType, |
| 5833 | &mcRSNEncryptType, |
| 5834 | &RSNAuthType, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 5835 | &MFPCapable, |
| 5836 | &MFPRequired, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5837 | pConfig->pRSNWPAReqIE[1]+2, |
| 5838 | pConfig->pRSNWPAReqIE ); |
| 5839 | |
| 5840 | if( VOS_STATUS_SUCCESS == status ) |
| 5841 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5842 | /* Now copy over all the security attributes you have |
| 5843 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5844 | * */ |
| 5845 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 5846 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 5847 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 5848 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5849 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5850 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5851 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 5852 | } |
| 5853 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5854 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5855 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 5856 | pBeacon->tail, pBeacon->tail_len); |
| 5857 | |
| 5858 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 5859 | { |
| 5860 | if (pConfig->pRSNWPAReqIE) |
| 5861 | { |
| 5862 | /*Mixed mode WPA/WPA2*/ |
| 5863 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 5864 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 5865 | } |
| 5866 | else |
| 5867 | { |
| 5868 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 5869 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 5870 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5871 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5872 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 5873 | &RSNEncryptType, |
| 5874 | &mcRSNEncryptType, |
| 5875 | &RSNAuthType, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 5876 | &MFPCapable, |
| 5877 | &MFPRequired, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5878 | pConfig->pRSNWPAReqIE[1]+2, |
| 5879 | pConfig->pRSNWPAReqIE ); |
| 5880 | |
| 5881 | if( VOS_STATUS_SUCCESS == status ) |
| 5882 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5883 | /* Now copy over all the security attributes you have |
| 5884 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5885 | * */ |
| 5886 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 5887 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 5888 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 5889 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5890 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5891 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5892 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 5893 | } |
| 5894 | } |
| 5895 | } |
| 5896 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 5897 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 5898 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 5899 | return -EINVAL; |
| 5900 | } |
| 5901 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5902 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 5903 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5904 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5905 | if (params->ssid != NULL) |
| 5906 | { |
| 5907 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 5908 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 5909 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 5910 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 5911 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5912 | #else |
| 5913 | if (ssid != NULL) |
| 5914 | { |
| 5915 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 5916 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 5917 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 5918 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 5919 | } |
| 5920 | #endif |
| 5921 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5922 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5923 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5924 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5925 | /* default value */ |
| 5926 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 5927 | pConfig->num_accept_mac = 0; |
| 5928 | pConfig->num_deny_mac = 0; |
| 5929 | |
| 5930 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 5931 | pBeacon->tail, pBeacon->tail_len); |
| 5932 | |
| 5933 | /* pIe for black list is following form: |
| 5934 | type : 1 byte |
| 5935 | length : 1 byte |
| 5936 | OUI : 4 bytes |
| 5937 | acl type : 1 byte |
| 5938 | no of mac addr in black list: 1 byte |
| 5939 | 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] | 5940 | */ |
| 5941 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5942 | { |
| 5943 | pConfig->SapMacaddr_acl = pIe[6]; |
| 5944 | pConfig->num_deny_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5945 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5946 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 5947 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 5948 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5949 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 5950 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 5951 | { |
| 5952 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 5953 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5954 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5955 | } |
| 5956 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 5957 | pBeacon->tail, pBeacon->tail_len); |
| 5958 | |
| 5959 | /* pIe for white list is following form: |
| 5960 | type : 1 byte |
| 5961 | length : 1 byte |
| 5962 | OUI : 4 bytes |
| 5963 | acl type : 1 byte |
| 5964 | no of mac addr in white list: 1 byte |
| 5965 | 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] | 5966 | */ |
| 5967 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5968 | { |
| 5969 | pConfig->SapMacaddr_acl = pIe[6]; |
| 5970 | pConfig->num_accept_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5971 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5972 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 5973 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 5974 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5975 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 5976 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 5977 | { |
| 5978 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 5979 | acl_entry++; |
| 5980 | } |
| 5981 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 5982 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5983 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 5984 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5985 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 5986 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 5987 | * This is valid only if mode is set to 11n in hostapd, either AUTO or |
| 5988 | * 11ac in .ini and 11ac is supported by both host and firmware. |
| 5989 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) |
| 5990 | */ |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 5991 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 5992 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Abhishek Singh | f0ac175 | 2014-03-05 17:47:09 +0530 | [diff] [blame] | 5993 | (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) || |
| 5994 | ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) || |
| 5995 | ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) && |
| 5996 | (sme_IsFeatureSupportedByDriver(DOT11AC)) && |
| 5997 | (sme_IsFeatureSupportedByFW(DOT11AC)) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5998 | { |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 5999 | v_U32_t operatingBand = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6000 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 6001 | ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand); |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 6002 | |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 6003 | /* If ACS disable and selected channel <= 14 |
| 6004 | * OR |
| 6005 | * ACS enabled and ACS operating band is choosen as 2.4 |
| 6006 | * AND |
| 6007 | * VHT in 2.4G Disabled |
| 6008 | * THEN |
| 6009 | * Fallback to 11N mode |
| 6010 | */ |
| 6011 | if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END) |
| 6012 | || (AUTO_CHANNEL_SELECT == pConfig->channel && |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 6013 | operatingBand == RF_SUBBAND_2_4_GHZ)) && |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 6014 | iniConfig->enableVhtFor24GHzBand == FALSE) |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 6015 | { |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 6016 | hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"), |
| 6017 | operatingBand, pConfig->channel); |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 6018 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 6019 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6020 | } |
| 6021 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6022 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 6023 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 6024 | { |
| 6025 | sme_SelectCBMode(hHal, |
| 6026 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 6027 | pConfig->channel); |
| 6028 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6029 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 6030 | pConfig->ht_capab = |
| 6031 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 6032 | |
| 6033 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 6034 | { |
| 6035 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 6036 | return -EINVAL; |
| 6037 | } |
| 6038 | |
| 6039 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6040 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6041 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 6042 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6043 | pConfig->obssProtEnabled = |
| 6044 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6045 | |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 6046 | #ifdef WLAN_FEATURE_11W |
| 6047 | pConfig->mfpCapable = MFPCapable; |
| 6048 | pConfig->mfpRequired = MFPRequired; |
| 6049 | hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"), |
| 6050 | pConfig->mfpCapable, pConfig->mfpRequired); |
| 6051 | #endif |
| 6052 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6053 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6054 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6055 | hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"), |
| 6056 | pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int, |
| 6057 | (int)pConfig->channel); |
| 6058 | hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"), |
| 6059 | pConfig->SapHw_mode, pConfig->privacy, |
| 6060 | pConfig->authType); |
| 6061 | hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"), |
| 6062 | (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable); |
| 6063 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"), |
| 6064 | pConfig->protEnabled, pConfig->obssProtEnabled); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6065 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6066 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6067 | { |
| 6068 | //Bss already started. just return. |
| 6069 | //TODO Probably it should update some beacon params. |
| 6070 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 6071 | EXIT(); |
| 6072 | return 0; |
| 6073 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6074 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6075 | if (vos_max_concurrent_connections_reached()) { |
| 6076 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 6077 | return -EINVAL; |
| 6078 | } |
| 6079 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6080 | pConfig->persona = pHostapdAdapter->device_mode; |
| 6081 | |
| 6082 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 6083 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 6084 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 6085 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6086 | hddLog(LOGE,FL("SAP Start Bss fail")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6087 | return -EINVAL; |
| 6088 | } |
| 6089 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6090 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6091 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 6092 | |
| 6093 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6094 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6095 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6096 | { |
| 6097 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6098 | ("ERROR: HDD vos wait for single_event failed!!")); |
Tushnim Bhattacharyya | ad37df1 | 2013-10-02 12:01:33 -0700 | [diff] [blame] | 6099 | smeGetCommandQStatus(hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6100 | VOS_ASSERT(0); |
| 6101 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6102 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6103 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6104 | wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6105 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 6106 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 6107 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 6108 | { |
| 6109 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 6110 | { |
| 6111 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 6112 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 6113 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 6114 | } |
| 6115 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 6116 | { |
| 6117 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 6118 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 6119 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 6120 | } |
| 6121 | } |
| 6122 | #endif |
| 6123 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6124 | pHostapdState->bCommit = TRUE; |
| 6125 | EXIT(); |
| 6126 | |
| 6127 | return 0; |
| 6128 | } |
| 6129 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6130 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6131 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 6132 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6133 | struct beacon_parameters *params) |
| 6134 | { |
| 6135 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6136 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6137 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6138 | |
| 6139 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6140 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6141 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6142 | TRACE_CODE_HDD_CFG80211_ADD_BEACON, |
| 6143 | pAdapter->sessionId, params->interval)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6144 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)", |
| 6145 | hdd_device_modetoString(pAdapter->device_mode), |
| 6146 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6147 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6148 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6149 | status = wlan_hdd_validate_context(pHddCtx); |
| 6150 | |
| 6151 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6152 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6153 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6154 | "%s: HDD context is not valid", __func__); |
| 6155 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6156 | } |
| 6157 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6158 | if (vos_max_concurrent_connections_reached()) { |
| 6159 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 6160 | return -EINVAL; |
| 6161 | } |
| 6162 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6163 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6164 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6165 | ) |
| 6166 | { |
| 6167 | beacon_data_t *old,*new; |
| 6168 | |
| 6169 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6171 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6172 | { |
| 6173 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 6174 | FL("already beacon info added to session(%d)"), |
| 6175 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6176 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6177 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6178 | |
| 6179 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 6180 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6181 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6182 | { |
| 6183 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6184 | "%s:Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6185 | return -EINVAL; |
| 6186 | } |
| 6187 | |
| 6188 | pAdapter->sessionCtx.ap.beacon = new; |
| 6189 | |
| 6190 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 6191 | } |
| 6192 | |
| 6193 | EXIT(); |
| 6194 | return status; |
| 6195 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6196 | |
| 6197 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6198 | struct net_device *dev, |
| 6199 | struct beacon_parameters *params) |
| 6200 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6201 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6202 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6203 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6204 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6205 | |
| 6206 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6207 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6208 | TRACE_CODE_HDD_CFG80211_SET_BEACON, |
| 6209 | pAdapter->sessionId, pHddStaCtx->conn_info.authType)); |
| 6210 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 6211 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6212 | pAdapter->device_mode); |
| 6213 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6214 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6215 | status = wlan_hdd_validate_context(pHddCtx); |
| 6216 | |
| 6217 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6218 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6219 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6220 | "%s: HDD context is not valid", __func__); |
| 6221 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6222 | } |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6223 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6224 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6225 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6226 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6227 | { |
| 6228 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6229 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6230 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6231 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6232 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6233 | { |
| 6234 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6235 | FL("session(%d) old and new heads points to NULL"), |
| 6236 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6237 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6238 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6239 | |
| 6240 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 6241 | |
| 6242 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6243 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6244 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6245 | return -EINVAL; |
| 6246 | } |
| 6247 | |
| 6248 | pAdapter->sessionCtx.ap.beacon = new; |
| 6249 | |
| 6250 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 6251 | } |
| 6252 | |
| 6253 | EXIT(); |
| 6254 | return status; |
| 6255 | } |
| 6256 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6257 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 6258 | |
| 6259 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6260 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 6261 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6262 | #else |
| 6263 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 6264 | struct net_device *dev) |
| 6265 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6266 | { |
| 6267 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6268 | hdd_context_t *pHddCtx = NULL; |
| 6269 | hdd_scaninfo_t *pScanInfo = NULL; |
| 6270 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6271 | VOS_STATUS status; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6272 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6273 | |
| 6274 | ENTER(); |
| 6275 | |
| 6276 | if (NULL == pAdapter) |
| 6277 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6278 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6279 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6280 | return -ENODEV; |
| 6281 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6282 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6283 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6284 | TRACE_CODE_HDD_CFG80211_STOP_AP, |
| 6285 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6286 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6287 | status = wlan_hdd_validate_context(pHddCtx); |
| 6288 | |
| 6289 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6290 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6292 | "%s: HDD context is not valid", __func__); |
| 6293 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 6294 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6295 | |
| 6296 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6297 | if (NULL == staAdapter) |
| 6298 | { |
| 6299 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6300 | if (NULL == staAdapter) |
| 6301 | { |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 6302 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6303 | "%s: HDD adapter context for STA/P2P-CLI is Null", |
| 6304 | __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6305 | } |
| 6306 | } |
| 6307 | |
| 6308 | pScanInfo = &pHddCtx->scan_info; |
| 6309 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6310 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 6311 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6312 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6313 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6314 | ret = wlan_hdd_scan_abort(pAdapter); |
| 6315 | |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 6316 | if (ret < 0) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6317 | { |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6318 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6319 | FL("Timeout occurred while waiting for abortscan %ld"), ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6320 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6321 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6322 | { |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6324 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 6325 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6326 | VOS_ASSERT(pScanInfo->mScanPending); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6327 | return -EAGAIN; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6328 | } |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 6329 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6330 | } |
| 6331 | |
Arun Kumar Khandavalli | a3bd800 | 2014-01-17 16:21:19 +0530 | [diff] [blame] | 6332 | hdd_hostapd_stop(dev); |
| 6333 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6334 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6335 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6336 | ) |
| 6337 | { |
| 6338 | beacon_data_t *old; |
| 6339 | |
| 6340 | old = pAdapter->sessionCtx.ap.beacon; |
| 6341 | |
| 6342 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6343 | { |
| 6344 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6345 | FL("session(%d) beacon data points to NULL"), |
| 6346 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6347 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6348 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6349 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6350 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6351 | |
| 6352 | mutex_lock(&pHddCtx->sap_lock); |
| 6353 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 6354 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 6355 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6356 | { |
| 6357 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 6358 | |
| 6359 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 6360 | |
| 6361 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 6362 | { |
| 6363 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6364 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6365 | VOS_ASSERT(0); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6366 | } |
| 6367 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6368 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6369 | /* BSS stopped, clear the active sessions for this device mode */ |
| 6370 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6371 | } |
| 6372 | mutex_unlock(&pHddCtx->sap_lock); |
| 6373 | |
| 6374 | if(status != VOS_STATUS_SUCCESS) |
| 6375 | { |
| 6376 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6377 | "%s:Error!!! Stopping the BSS",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6378 | return -EINVAL; |
| 6379 | } |
| 6380 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 6381 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6382 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 6383 | ==eHAL_STATUS_FAILURE) |
| 6384 | { |
| 6385 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6386 | "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] | 6387 | } |
| 6388 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 6389 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6390 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 6391 | eANI_BOOLEAN_FALSE) ) |
| 6392 | { |
| 6393 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6394 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6395 | } |
| 6396 | |
| 6397 | // Reset WNI_CFG_PROBE_RSP Flags |
| 6398 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 6399 | |
| 6400 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 6401 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 6402 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 6403 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 6404 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 6405 | { |
| 6406 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 6407 | "GO got removed"); |
| 6408 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 6409 | } |
| 6410 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6411 | } |
| 6412 | EXIT(); |
| 6413 | return status; |
| 6414 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6415 | |
| 6416 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 6417 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6418 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 6419 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6420 | struct cfg80211_ap_settings *params) |
| 6421 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6422 | hdd_adapter_t *pAdapter; |
| 6423 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6424 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6425 | |
| 6426 | ENTER(); |
| 6427 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6428 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 6429 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6430 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6431 | "%s: Device is Null", __func__); |
| 6432 | return -ENODEV; |
| 6433 | } |
| 6434 | |
| 6435 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6436 | if (NULL == pAdapter) |
| 6437 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6438 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6439 | "%s: HDD adapter is Null", __func__); |
| 6440 | return -ENODEV; |
| 6441 | } |
| 6442 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6443 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6444 | TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId, |
| 6445 | params-> beacon_interval)); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6446 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 6447 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6448 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6449 | "%s: HDD adapter magic is invalid", __func__); |
| 6450 | return -ENODEV; |
| 6451 | } |
| 6452 | |
| 6453 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6454 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6455 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6456 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6457 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6458 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6459 | "%s: HDD context is not valid", __func__); |
| 6460 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6461 | } |
| 6462 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6463 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)", |
| 6464 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6465 | pAdapter->device_mode); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6466 | |
| 6467 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6468 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6469 | ) |
| 6470 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6471 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6472 | |
| 6473 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6474 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6475 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6476 | { |
| 6477 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 6478 | FL("already beacon info added to session(%d)"), |
| 6479 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6480 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6481 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6482 | |
| 6483 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 6484 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6485 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6486 | { |
| 6487 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 6488 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6489 | return -EINVAL; |
| 6490 | } |
| 6491 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 6492 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6493 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 6494 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 6495 | params->channel, params->channel_type); |
| 6496 | #else |
| 6497 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 6498 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 6499 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6500 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 6501 | params->ssid_len, params->hidden_ssid); |
| 6502 | } |
| 6503 | |
| 6504 | EXIT(); |
| 6505 | return status; |
| 6506 | } |
| 6507 | |
| 6508 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6509 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6510 | struct net_device *dev, |
| 6511 | struct cfg80211_beacon_data *params) |
| 6512 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6513 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6514 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6515 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6516 | |
| 6517 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6518 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6519 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6520 | TRACE_CODE_HDD_CFG80211_CHANGE_BEACON, |
| 6521 | pAdapter->sessionId, pAdapter->device_mode)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6522 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6523 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6524 | |
| 6525 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6526 | status = wlan_hdd_validate_context(pHddCtx); |
| 6527 | |
| 6528 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 6529 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6530 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6531 | "%s: HDD context is not valid", __func__); |
| 6532 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 6533 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6534 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6535 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6536 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6537 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6538 | { |
| 6539 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6540 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6541 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6542 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6543 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6544 | { |
| 6545 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6546 | FL("session(%d) beacon data points to NULL"), |
| 6547 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6548 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6549 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6550 | |
| 6551 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 6552 | |
| 6553 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6554 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6555 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6556 | return -EINVAL; |
| 6557 | } |
| 6558 | |
| 6559 | pAdapter->sessionCtx.ap.beacon = new; |
| 6560 | |
| 6561 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 6562 | } |
| 6563 | |
| 6564 | EXIT(); |
| 6565 | return status; |
| 6566 | } |
| 6567 | |
| 6568 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 6569 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6570 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 6571 | static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6572 | struct net_device *dev, |
| 6573 | struct bss_parameters *params) |
| 6574 | { |
| 6575 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6576 | |
| 6577 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 6578 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6579 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6580 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
| 6581 | pAdapter->sessionId, params->ap_isolate)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6582 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 6583 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6584 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6585 | |
| 6586 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6587 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6588 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6589 | { |
| 6590 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 6591 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6592 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6593 | { |
| 6594 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6595 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6596 | } |
| 6597 | |
| 6598 | EXIT(); |
| 6599 | return 0; |
| 6600 | } |
| 6601 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 6602 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 6603 | struct net_device *dev, |
| 6604 | struct bss_parameters *params) |
| 6605 | { |
| 6606 | int ret; |
| 6607 | |
| 6608 | vos_ssr_protect(__func__); |
| 6609 | ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
| 6610 | vos_ssr_unprotect(__func__); |
| 6611 | |
| 6612 | return ret; |
| 6613 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6614 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 6615 | * to wait for contry code completion |
| 6616 | */ |
| 6617 | void* wlan_hdd_change_country_code_cb(void *pAdapter) |
| 6618 | { |
| 6619 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 6620 | complete(&call_back_pAdapter->change_country_code); |
| 6621 | return NULL; |
| 6622 | } |
| 6623 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6624 | /* |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 6625 | * FUNCTION: __wlan_hdd_cfg80211_change_iface |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6626 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 6627 | */ |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 6628 | int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6629 | struct net_device *ndev, |
| 6630 | enum nl80211_iftype type, |
| 6631 | u32 *flags, |
| 6632 | struct vif_params *params |
| 6633 | ) |
| 6634 | { |
| 6635 | struct wireless_dev *wdev; |
| 6636 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 6637 | hdd_context_t *pHddCtx; |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 6638 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6639 | tCsrRoamProfile *pRoamProfile = NULL; |
| 6640 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6641 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6642 | eMib_dot11DesiredBssType connectedBssType; |
| 6643 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6644 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6645 | |
| 6646 | ENTER(); |
| 6647 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6648 | if (!pAdapter) |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 6649 | { |
| 6650 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6651 | "%s: Adapter context is null", __func__); |
| 6652 | return VOS_STATUS_E_FAILURE; |
| 6653 | } |
| 6654 | |
| 6655 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6656 | if (!pHddCtx) |
| 6657 | { |
| 6658 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6659 | "%s: HDD context is null", __func__); |
| 6660 | return VOS_STATUS_E_FAILURE; |
| 6661 | } |
| 6662 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6663 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6664 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
| 6665 | pAdapter->sessionId, type)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6666 | status = wlan_hdd_validate_context(pHddCtx); |
| 6667 | |
| 6668 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6669 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6670 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6671 | "%s: HDD context is not valid", __func__); |
| 6672 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6673 | } |
| 6674 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6675 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 6676 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6677 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6678 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6679 | if (vos_max_concurrent_connections_reached()) { |
| 6680 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 6681 | return -EINVAL; |
| 6682 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6683 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6684 | wdev = ndev->ieee80211_ptr; |
| 6685 | |
| 6686 | #ifdef WLAN_BTAMP_FEATURE |
| 6687 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 6688 | (NL80211_IFTYPE_ADHOC == type)|| |
| 6689 | (NL80211_IFTYPE_AP == type)|| |
| 6690 | (NL80211_IFTYPE_P2P_GO == type)) |
| 6691 | { |
| 6692 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 6693 | // stop AMP traffic |
| 6694 | status = WLANBAP_StopAmp(); |
| 6695 | if(VOS_STATUS_SUCCESS != status ) |
| 6696 | { |
| 6697 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 6698 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6699 | "%s: Failed to stop AMP", __func__); |
| 6700 | return -EINVAL; |
| 6701 | } |
| 6702 | } |
| 6703 | #endif //WLAN_BTAMP_FEATURE |
| 6704 | /* Reset the current device mode bit mask*/ |
| 6705 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6706 | |
| 6707 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6708 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6709 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6710 | ) |
| 6711 | { |
| 6712 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 6713 | if (!pWextState) |
| 6714 | { |
| 6715 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6716 | "%s: pWextState is null", __func__); |
| 6717 | return VOS_STATUS_E_FAILURE; |
| 6718 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6719 | pRoamProfile = &pWextState->roamProfile; |
| 6720 | LastBSSType = pRoamProfile->BSSType; |
| 6721 | |
| 6722 | switch (type) |
| 6723 | { |
| 6724 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6725 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6726 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6727 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 6728 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6729 | #ifdef WLAN_FEATURE_11AC |
| 6730 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 6731 | { |
| 6732 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 6733 | } |
| 6734 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6735 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6736 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6737 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 6738 | //Check for sub-string p2p to confirm its a p2p interface |
| 6739 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6740 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 6741 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 6742 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 6743 | } |
| 6744 | else |
| 6745 | { |
| 6746 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6747 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 6748 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 6749 | #ifdef FEATURE_WLAN_TDLS |
| 6750 | /* The open adapter for the p2p shall skip initializations in |
| 6751 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 6752 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 6753 | * tdls_init when the change_iface sets the device mode to |
| 6754 | * WLAN_HDD_P2P_CLIENT. |
| 6755 | */ |
| 6756 | |
| 6757 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 6758 | { |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 6759 | if (0 != wlan_hdd_sta_tdls_init (pAdapter)) |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 6760 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6761 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6762 | "%s: tdls initialization failed", __func__); |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 6763 | return -EINVAL; |
| 6764 | } |
| 6765 | } |
| 6766 | #endif |
| 6767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6768 | break; |
| 6769 | case NL80211_IFTYPE_ADHOC: |
| 6770 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6771 | "%s: setting interface Type to ADHOC", __func__); |
| 6772 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 6773 | pRoamProfile->phyMode = |
| 6774 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 6775 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6776 | wdev->iftype = type; |
| 6777 | break; |
| 6778 | |
| 6779 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6780 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6781 | { |
| 6782 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 6783 | "%s: setting interface Type to %s", __func__, |
| 6784 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 6785 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 6786 | //Cancel any remain on channel for GO mode |
| 6787 | if (NL80211_IFTYPE_P2P_GO == type) |
| 6788 | { |
| 6789 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 6790 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 6791 | if (NL80211_IFTYPE_AP == type) |
| 6792 | { |
| 6793 | /* As Loading WLAN Driver one interface being created for p2p device |
| 6794 | * address. This will take one HW STA and the max number of clients |
| 6795 | * that can connect to softAP will be reduced by one. so while changing |
| 6796 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 6797 | * interface as it is not required in SoftAP mode. |
| 6798 | */ |
| 6799 | |
| 6800 | // Get P2P Adapter |
| 6801 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 6802 | |
| 6803 | if (pP2pAdapter) |
| 6804 | { |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6805 | hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 6806 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 6807 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 6808 | } |
| 6809 | } |
Swaroop Golti | a2e3221 | 2014-04-09 23:37:33 +0530 | [diff] [blame] | 6810 | //Disable IMPS & BMPS for SAP/GO |
| 6811 | if(VOS_STATUS_E_FAILURE == |
| 6812 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 6813 | { |
| 6814 | //Fail to Exit BMPS |
| 6815 | VOS_ASSERT(0); |
| 6816 | } |
Deepthi Gowri | 500fc47 | 2014-08-11 19:53:10 +0530 | [diff] [blame] | 6817 | |
| 6818 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
| 6819 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6820 | #ifdef FEATURE_WLAN_TDLS |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 6821 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6822 | /* A Mutex Lock is introduced while changing the mode to |
| 6823 | * protect the concurrent access for the Adapters by TDLS |
| 6824 | * module. |
| 6825 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6826 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6827 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6828 | //De-init the adapter. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6829 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 6830 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6831 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 6832 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6833 | #ifdef FEATURE_WLAN_TDLS |
| 6834 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6835 | #endif |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 6836 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 6837 | (pConfig->apRandomBssidEnabled)) |
| 6838 | { |
| 6839 | /* To meet Android requirements create a randomized |
| 6840 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 6841 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 6842 | ndev->dev_addr[0] = 0x02; |
| 6843 | ndev->dev_addr[1] = 0x1A; |
| 6844 | ndev->dev_addr[2] = 0x11; |
| 6845 | ndev->dev_addr[3] |= 0xF0; |
| 6846 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 6847 | VOS_MAC_ADDR_SIZE); |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 6848 | pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n", |
| 6849 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 6850 | } |
| 6851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6852 | hdd_set_ap_ops( pAdapter->dev ); |
| 6853 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6854 | /* This is for only SAP mode where users can |
| 6855 | * control country through ini. |
| 6856 | * P2P GO follows station country code |
| 6857 | * acquired during the STA scanning. */ |
| 6858 | if((NL80211_IFTYPE_AP == type) && |
| 6859 | (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)) |
| 6860 | { |
| 6861 | int status = 0; |
| 6862 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO, |
| 6863 | "%s: setting country code from INI ", __func__); |
| 6864 | init_completion(&pAdapter->change_country_code); |
| 6865 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 6866 | (void *)(tSmeChangeCountryCallback) |
| 6867 | wlan_hdd_change_country_code_cb, |
| 6868 | pConfig->apCntryCode, pAdapter, |
| 6869 | pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 6870 | eSIR_FALSE, |
| 6871 | eSIR_TRUE); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6872 | if (eHAL_STATUS_SUCCESS == status) |
| 6873 | { |
| 6874 | /* Wait for completion */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6875 | ret = wait_for_completion_interruptible_timeout( |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6876 | &pAdapter->change_country_code, |
| 6877 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6878 | if (ret <= 0) |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6879 | { |
| 6880 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6881 | FL("SME Timed out while setting country code %ld"), |
| 6882 | ret); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 6883 | |
| 6884 | if (pHddCtx->isLogpInProgress) |
| 6885 | { |
| 6886 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6887 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 6888 | return -EAGAIN; |
| 6889 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6890 | } |
| 6891 | } |
| 6892 | else |
| 6893 | { |
| 6894 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6895 | "%s: SME Change Country code failed",__func__); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 6896 | return -EINVAL; |
| 6897 | } |
| 6898 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6899 | status = hdd_init_ap_mode(pAdapter); |
| 6900 | if(status != VOS_STATUS_SUCCESS) |
| 6901 | { |
| 6902 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6903 | "%s: Error initializing the ap mode", __func__); |
| 6904 | return -EINVAL; |
| 6905 | } |
| 6906 | hdd_set_conparam(1); |
| 6907 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6908 | /*interface type changed update in wiphy structure*/ |
| 6909 | if(wdev) |
| 6910 | { |
| 6911 | wdev->iftype = type; |
| 6912 | pHddCtx->change_iface = type; |
| 6913 | } |
| 6914 | else |
| 6915 | { |
| 6916 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6917 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 6918 | return -EINVAL; |
| 6919 | } |
| 6920 | goto done; |
| 6921 | } |
| 6922 | |
| 6923 | default: |
| 6924 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 6925 | __func__); |
| 6926 | return -EOPNOTSUPP; |
| 6927 | } |
| 6928 | } |
| 6929 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6930 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6931 | ) |
| 6932 | { |
| 6933 | switch(type) |
| 6934 | { |
| 6935 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6936 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6937 | case NL80211_IFTYPE_ADHOC: |
Deepthi Gowri | 500fc47 | 2014-08-11 19:53:10 +0530 | [diff] [blame] | 6938 | |
| 6939 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6940 | #ifdef FEATURE_WLAN_TDLS |
| 6941 | |
| 6942 | /* A Mutex Lock is introduced while changing the mode to |
| 6943 | * protect the concurrent access for the Adapters by TDLS |
| 6944 | * module. |
| 6945 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6946 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6947 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6948 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6949 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 6950 | //Check for sub-string p2p to confirm its a p2p interface |
| 6951 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 6952 | { |
| 6953 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 6954 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 6955 | } |
| 6956 | else |
| 6957 | { |
| 6958 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6959 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 6960 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6961 | hdd_set_conparam(0); |
| 6962 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6963 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 6964 | hdd_set_station_ops( pAdapter->dev ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6965 | #ifdef FEATURE_WLAN_TDLS |
| 6966 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6967 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6968 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6969 | if( VOS_STATUS_SUCCESS != status ) |
| 6970 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6971 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 6972 | * This is the right place to enable back bmps_imps() |
| 6973 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6974 | if (pHddCtx->hdd_wlan_suspended) |
| 6975 | { |
| 6976 | hdd_set_pwrparams(pHddCtx); |
| 6977 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6978 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6979 | goto done; |
| 6980 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6981 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6982 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6983 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 6984 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6985 | goto done; |
| 6986 | default: |
| 6987 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 6988 | __func__); |
| 6989 | return -EOPNOTSUPP; |
| 6990 | |
| 6991 | } |
| 6992 | |
| 6993 | } |
| 6994 | else |
| 6995 | { |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6996 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))", |
| 6997 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6998 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6999 | return -EOPNOTSUPP; |
| 7000 | } |
| 7001 | |
| 7002 | |
| 7003 | if(pRoamProfile) |
| 7004 | { |
| 7005 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 7006 | { |
| 7007 | /*interface type changed update in wiphy structure*/ |
| 7008 | wdev->iftype = type; |
| 7009 | |
| 7010 | /*the BSS mode changed, We need to issue disconnect |
| 7011 | if connected or in IBSS disconnect state*/ |
| 7012 | if ( hdd_connGetConnectedBssType( |
| 7013 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 7014 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 7015 | { |
| 7016 | /*need to issue a disconnect to CSR.*/ |
| 7017 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 7018 | if( eHAL_STATUS_SUCCESS == |
| 7019 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7020 | pAdapter->sessionId, |
| 7021 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 7022 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7023 | ret = wait_for_completion_interruptible_timeout( |
| 7024 | &pAdapter->disconnect_comp_var, |
| 7025 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7026 | if (ret <= 0) |
| 7027 | { |
| 7028 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7029 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 7030 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7031 | } |
| 7032 | } |
| 7033 | } |
| 7034 | } |
| 7035 | |
| 7036 | done: |
| 7037 | /*set bitmask based on updated value*/ |
| 7038 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 7039 | |
| 7040 | /* Only STA mode support TM now |
| 7041 | * all other mode, TM feature should be disabled */ |
| 7042 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 7043 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 7044 | { |
| 7045 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 7046 | } |
| 7047 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7048 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7049 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 7050 | (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7051 | { |
| 7052 | //we are ok to do AMP |
| 7053 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 7054 | } |
| 7055 | #endif //WLAN_BTAMP_FEATURE |
| 7056 | EXIT(); |
| 7057 | return 0; |
| 7058 | } |
| 7059 | |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 7060 | /* |
| 7061 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 7062 | * wrapper function to protect the actual implementation from SSR. |
| 7063 | */ |
| 7064 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 7065 | struct net_device *ndev, |
| 7066 | enum nl80211_iftype type, |
| 7067 | u32 *flags, |
| 7068 | struct vif_params *params |
| 7069 | ) |
| 7070 | { |
| 7071 | int ret; |
| 7072 | |
| 7073 | vos_ssr_protect(__func__); |
| 7074 | ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params); |
| 7075 | vos_ssr_unprotect(__func__); |
| 7076 | |
| 7077 | return ret; |
| 7078 | } |
| 7079 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7080 | #ifdef FEATURE_WLAN_TDLS |
| 7081 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 7082 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 7083 | { |
| 7084 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7085 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 7086 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7087 | hddTdlsPeer_t *pTdlsPeer; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7088 | long ret; |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 7089 | tANI_U16 numCurrTdlsPeers; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7090 | |
| 7091 | ENTER(); |
| 7092 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 7093 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7094 | { |
| 7095 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7096 | "Invalid arguments"); |
| 7097 | return -EINVAL; |
| 7098 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7099 | |
| 7100 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 7101 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 7102 | { |
| 7103 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7104 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7105 | MAC_ADDRESS_STR " Request declined.", |
| 7106 | __func__, MAC_ADDR_ARRAY(mac)); |
| 7107 | return -ENOTSUPP; |
| 7108 | } |
| 7109 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7110 | if (pHddCtx->isLogpInProgress) |
| 7111 | { |
| 7112 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7113 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7114 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 7115 | mac, |
| 7116 | eTDLS_LINK_IDLE, |
| 7117 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7118 | return -EBUSY; |
| 7119 | } |
| 7120 | |
Naresh Jayaram | 9c6f446 | 2014-02-13 12:20:31 +0530 | [diff] [blame] | 7121 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7122 | |
| 7123 | if ( NULL == pTdlsPeer ) { |
| 7124 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7125 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 7126 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 7127 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7128 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7129 | |
| 7130 | /* in add station, we accept existing valid staId if there is */ |
| 7131 | if ((0 == update) && |
| 7132 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 7133 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7134 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7135 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7136 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7137 | " link_status %d. staId %d. add station ignored.", |
| 7138 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 7139 | return 0; |
| 7140 | } |
| 7141 | /* in change station, we accept only when staId is valid */ |
| 7142 | if ((1 == update) && |
| 7143 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 7144 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 7145 | { |
| 7146 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7147 | "%s: " MAC_ADDRESS_STR |
| 7148 | " link status %d. staId %d. change station %s.", |
| 7149 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 7150 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 7151 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7152 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7153 | |
| 7154 | /* when others are on-going, we want to change link_status to idle */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 7155 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7156 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7157 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7158 | "%s: " MAC_ADDRESS_STR |
| 7159 | " TDLS setup is ongoing. Request declined.", |
| 7160 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7161 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7162 | } |
| 7163 | |
| 7164 | /* first to check if we reached to maximum supported TDLS peer. |
| 7165 | TODO: for now, return -EPERM looks working fine, |
| 7166 | but need to check if any other errno fit into this category.*/ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 7167 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 7168 | if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7169 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7170 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7171 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 7172 | " TDLS Max peer already connected. Request declined." |
| 7173 | " Num of peers (%d), Max allowed (%d).", |
| 7174 | __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers, |
| 7175 | HDD_MAX_NUM_TDLS_STA); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7176 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7177 | } |
| 7178 | else |
| 7179 | { |
| 7180 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 7181 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7182 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7183 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7185 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 7186 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7187 | return -EPERM; |
| 7188 | } |
| 7189 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7190 | if (0 == update) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7191 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 7192 | mac, |
| 7193 | eTDLS_LINK_CONNECTING, |
| 7194 | eTDLS_LINK_SUCCESS); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7195 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 7196 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 7197 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7198 | { |
| 7199 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7200 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 7201 | if(StaParams->htcap_present) |
| 7202 | { |
| 7203 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7204 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 7205 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7206 | "ht_capa->extended_capabilities: %0x", |
| 7207 | StaParams->HTCap.extendedHtCapInfo); |
| 7208 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7209 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7210 | "params->capability: %0x",StaParams->capability); |
| 7211 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7212 | "params->ext_capab_len: %0x",StaParams->extn_capability[0]); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 7213 | if(StaParams->vhtcap_present) |
| 7214 | { |
| 7215 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7216 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 7217 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 7218 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 7219 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7220 | { |
| 7221 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7222 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7223 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 7224 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7225 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 7226 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 7227 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 7228 | else if ((1 == update) && (NULL == StaParams)) |
| 7229 | { |
| 7230 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7231 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 7232 | return -EPERM; |
| 7233 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7234 | |
| 7235 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 7236 | |
| 7237 | if (!update) |
| 7238 | { |
| 7239 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7240 | pAdapter->sessionId, mac); |
| 7241 | } |
| 7242 | else |
| 7243 | { |
| 7244 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7245 | pAdapter->sessionId, mac, StaParams); |
| 7246 | } |
| 7247 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7248 | ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7249 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 7250 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7251 | if (ret <= 0) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7252 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7253 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7254 | "%s: timeout waiting for tdls add station indication %ld", |
| 7255 | __func__, ret); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7256 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7257 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7258 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7259 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 7260 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7261 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7262 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7263 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7264 | } |
| 7265 | |
| 7266 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7267 | |
| 7268 | error: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 7269 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 7270 | mac, |
| 7271 | eTDLS_LINK_IDLE, |
| 7272 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7273 | return -EPERM; |
| 7274 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7275 | } |
| 7276 | #endif |
| 7277 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7278 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 7279 | struct net_device *dev, |
| 7280 | u8 *mac, |
| 7281 | struct station_parameters *params) |
| 7282 | { |
| 7283 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 7284 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7285 | hdd_context_t *pHddCtx; |
| 7286 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7287 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 7288 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7289 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7290 | tANI_U8 isBufSta = 0; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 7291 | tANI_U8 isOffChannelSupported = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 7292 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7293 | ENTER(); |
| 7294 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7295 | if ((NULL == pAdapter)) |
| 7296 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 7297 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7298 | "invalid adapter "); |
| 7299 | return -EINVAL; |
| 7300 | } |
| 7301 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7302 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 7303 | TRACE_CODE_HDD_CHANGE_STATION, |
| 7304 | pAdapter->sessionId, params->listen_interval)); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7305 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7306 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7307 | |
| 7308 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 7309 | { |
| 7310 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7311 | "invalid HDD state or HDD station context"); |
| 7312 | return -EINVAL; |
| 7313 | } |
| 7314 | |
| 7315 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7316 | { |
| 7317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7318 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 7319 | return -EAGAIN; |
| 7320 | } |
| 7321 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7322 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 7323 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7324 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 7325 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7326 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7327 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7328 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7329 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7330 | WLANTL_STA_AUTHENTICATED); |
| 7331 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7332 | if (status != VOS_STATUS_SUCCESS) |
| 7333 | { |
| 7334 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7335 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 7336 | return -EINVAL; |
| 7337 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7338 | } |
| 7339 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 7340 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 7341 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7342 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7343 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7344 | StaParams.capability = params->capability; |
| 7345 | StaParams.uapsd_queues = params->uapsd_queues; |
| 7346 | StaParams.max_sp = params->max_sp; |
| 7347 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 7348 | /* Convert (first channel , number of channels) tuple to |
| 7349 | * the total list of channels. This goes with the assumption |
| 7350 | * that if the first channel is < 14, then the next channels |
| 7351 | * are an incremental of 1 else an incremental of 4 till the number |
| 7352 | * of channels. |
| 7353 | */ |
| 7354 | if (0 != params->supported_channels_len) { |
| 7355 | int i = 0,j = 0,k = 0, no_of_channels = 0 ; |
| 7356 | for ( i = 0 ; i < params->supported_channels_len ; i+=2) |
| 7357 | { |
| 7358 | int wifi_chan_index; |
| 7359 | StaParams.supported_channels[j] = params->supported_channels[i]; |
| 7360 | wifi_chan_index = |
| 7361 | ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 ); |
| 7362 | no_of_channels = params->supported_channels[i+1]; |
| 7363 | for(k=1; k <= no_of_channels; k++) |
| 7364 | { |
| 7365 | StaParams.supported_channels[j+1] = |
| 7366 | StaParams.supported_channels[j] + wifi_chan_index; |
| 7367 | j+=1; |
| 7368 | } |
| 7369 | } |
| 7370 | StaParams.supported_channels_len = j; |
| 7371 | } |
| 7372 | vos_mem_copy(StaParams.supported_oper_classes, |
| 7373 | params->supported_oper_classes, |
| 7374 | params->supported_oper_classes_len); |
| 7375 | StaParams.supported_oper_classes_len = |
| 7376 | params->supported_oper_classes_len; |
| 7377 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7378 | if (0 != params->ext_capab_len) |
| 7379 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 7380 | sizeof(StaParams.extn_capability)); |
| 7381 | |
| 7382 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 7383 | { |
| 7384 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7385 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 7386 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7387 | |
| 7388 | StaParams.supported_rates_len = params->supported_rates_len; |
| 7389 | |
| 7390 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 7391 | * The supported_rates array , for all the structures propogating till Add Sta |
| 7392 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 7393 | * modified to send more rates. |
| 7394 | */ |
| 7395 | |
| 7396 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 7397 | */ |
| 7398 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 7399 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 7400 | |
| 7401 | if (0 != StaParams.supported_rates_len) { |
| 7402 | int i = 0; |
| 7403 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 7404 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7405 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7406 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 7407 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7408 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7409 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 7410 | } |
| 7411 | |
| 7412 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 7413 | { |
| 7414 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7415 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 7416 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7417 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7418 | if (0 != params->ext_capab_len ) { |
| 7419 | /*Define A Macro : TODO Sunil*/ |
| 7420 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 7421 | isBufSta = 1; |
| 7422 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 7423 | /* TDLS Channel Switching Support */ |
| 7424 | if ((1<<6) & StaParams.extn_capability[3]) { |
| 7425 | isOffChannelSupported = 1; |
| 7426 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7427 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 7428 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, |
| 7429 | &StaParams, isBufSta, |
| 7430 | isOffChannelSupported); |
| 7431 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7432 | if (VOS_STATUS_SUCCESS != status) { |
| 7433 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7434 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 7435 | return -EINVAL; |
| 7436 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7437 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 7438 | |
| 7439 | if (VOS_STATUS_SUCCESS != status) { |
| 7440 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7441 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 7442 | return -EINVAL; |
| 7443 | } |
| 7444 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 7445 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 7446 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7447 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7448 | return status; |
| 7449 | } |
| 7450 | |
| 7451 | /* |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7452 | * FUNCTION: __wlan_hdd_cfg80211_add_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7453 | * This function is used to initialize the key information |
| 7454 | */ |
| 7455 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7456 | static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7457 | struct net_device *ndev, |
| 7458 | u8 key_index, bool pairwise, |
| 7459 | const u8 *mac_addr, |
| 7460 | struct key_params *params |
| 7461 | ) |
| 7462 | #else |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7463 | static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7464 | struct net_device *ndev, |
| 7465 | u8 key_index, const u8 *mac_addr, |
| 7466 | struct key_params *params |
| 7467 | ) |
| 7468 | #endif |
| 7469 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7470 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7471 | tCsrRoamSetKey setKey; |
| 7472 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7473 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7474 | v_U32_t roamId= 0xFF; |
| 7475 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7476 | hdd_hostapd_state_t *pHostapdState; |
| 7477 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7478 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7479 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7480 | |
| 7481 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 7482 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7483 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 7484 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
| 7485 | pAdapter->sessionId, params->key_len)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7486 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7487 | status = wlan_hdd_validate_context(pHddCtx); |
| 7488 | |
| 7489 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7490 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7491 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7492 | "%s: HDD context is not valid", __func__); |
| 7493 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7494 | } |
| 7495 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 7496 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 7497 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 7498 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7499 | |
| 7500 | if (CSR_MAX_NUM_KEY <= key_index) |
| 7501 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7502 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7503 | key_index); |
| 7504 | |
| 7505 | return -EINVAL; |
| 7506 | } |
| 7507 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7508 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 7509 | { |
| 7510 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 7511 | params->key_len); |
| 7512 | |
| 7513 | return -EINVAL; |
| 7514 | } |
| 7515 | |
| 7516 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7517 | "%s: called with key index = %d & key length %d", |
| 7518 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7519 | |
| 7520 | /*extract key idx, key len and key*/ |
| 7521 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 7522 | setKey.keyId = key_index; |
| 7523 | setKey.keyLength = params->key_len; |
| 7524 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 7525 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7526 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7527 | { |
| 7528 | case WLAN_CIPHER_SUITE_WEP40: |
| 7529 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 7530 | break; |
| 7531 | |
| 7532 | case WLAN_CIPHER_SUITE_WEP104: |
| 7533 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 7534 | break; |
| 7535 | |
| 7536 | case WLAN_CIPHER_SUITE_TKIP: |
| 7537 | { |
| 7538 | u8 *pKey = &setKey.Key[0]; |
| 7539 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 7540 | |
| 7541 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 7542 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7543 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7544 | |
| 7545 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7546 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7547 | |--------------|----------|----------| |
| 7548 | <---16bytes---><--8bytes--><--8bytes--> |
| 7549 | |
| 7550 | */ |
| 7551 | /*Sme expects the 32 bytes key to be in the below order |
| 7552 | |
| 7553 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7554 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7555 | |--------------|----------|----------| |
| 7556 | <---16bytes---><--8bytes--><--8bytes--> |
| 7557 | */ |
| 7558 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7559 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7560 | |
| 7561 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7562 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7563 | |
| 7564 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7565 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7566 | |
| 7567 | |
| 7568 | break; |
| 7569 | } |
| 7570 | |
| 7571 | case WLAN_CIPHER_SUITE_CCMP: |
| 7572 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 7573 | break; |
| 7574 | |
| 7575 | #ifdef FEATURE_WLAN_WAPI |
| 7576 | case WLAN_CIPHER_SUITE_SMS4: |
| 7577 | { |
| 7578 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 7579 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 7580 | params->key, params->key_len); |
| 7581 | return 0; |
| 7582 | } |
| 7583 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 7584 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7585 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7586 | case WLAN_CIPHER_SUITE_KRK: |
| 7587 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 7588 | break; |
| 7589 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 7590 | |
| 7591 | #ifdef WLAN_FEATURE_11W |
| 7592 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 7593 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 7594 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 7595 | #endif |
| 7596 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7597 | default: |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7598 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7599 | __func__, params->cipher); |
| 7600 | return -EOPNOTSUPP; |
| 7601 | } |
| 7602 | |
| 7603 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 7604 | __func__, setKey.encType); |
| 7605 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 7606 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7607 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7608 | (!pairwise) |
| 7609 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7610 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7611 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 7612 | ) |
| 7613 | { |
| 7614 | /* set group key*/ |
| 7615 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7616 | "%s- %d: setting Broadcast key", |
| 7617 | __func__, __LINE__); |
| 7618 | setKey.keyDirection = eSIR_RX_ONLY; |
| 7619 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 7620 | } |
| 7621 | else |
| 7622 | { |
| 7623 | /* set pairwise key*/ |
| 7624 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7625 | "%s- %d: setting pairwise key", |
| 7626 | __func__, __LINE__); |
| 7627 | setKey.keyDirection = eSIR_TX_RX; |
| 7628 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 7629 | } |
| 7630 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 7631 | { |
| 7632 | setKey.keyDirection = eSIR_TX_RX; |
| 7633 | /*Set the group key*/ |
| 7634 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7635 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7636 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 7637 | if ( 0 != status ) |
| 7638 | { |
| 7639 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7640 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 7641 | return -EINVAL; |
| 7642 | } |
| 7643 | /*Save the keys here and call sme_RoamSetKey for setting |
| 7644 | the PTK after peer joins the IBSS network*/ |
| 7645 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 7646 | &setKey, sizeof(tCsrRoamSetKey)); |
| 7647 | return status; |
| 7648 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7649 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 7650 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 7651 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7652 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7653 | if( pHostapdState->bssState == BSS_START ) |
| 7654 | { |
c_hpothu | 7c55da6 | 2014-01-23 18:34:02 +0530 | [diff] [blame] | 7655 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7656 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 7657 | |
| 7658 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 7659 | { |
| 7660 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7661 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 7662 | __LINE__, vos_status ); |
| 7663 | |
| 7664 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 7665 | |
| 7666 | return -EINVAL; |
| 7667 | } |
| 7668 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7669 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 7670 | |
| 7671 | if ( status != eHAL_STATUS_SUCCESS ) |
| 7672 | { |
| 7673 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7674 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 7675 | __LINE__, status ); |
| 7676 | } |
| 7677 | } |
| 7678 | |
| 7679 | /* Saving WEP keys */ |
| 7680 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 7681 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 7682 | { |
| 7683 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 7684 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7685 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 7686 | } |
| 7687 | else |
| 7688 | { |
| 7689 | //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] | 7690 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7691 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 7692 | } |
| 7693 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7694 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 7695 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7696 | { |
| 7697 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7698 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7699 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 7700 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7701 | if (!pairwise) |
| 7702 | #else |
| 7703 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 7704 | #endif |
| 7705 | { |
| 7706 | /* set group key*/ |
| 7707 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 7708 | { |
| 7709 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7710 | "%s- %d: Perform Set key Complete", |
| 7711 | __func__, __LINE__); |
| 7712 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 7713 | } |
| 7714 | } |
| 7715 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7716 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 7717 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 7718 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 7719 | |
| 7720 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 7721 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7722 | params->key, params->key_len); |
| 7723 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 7724 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7725 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 7726 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7727 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7728 | "%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] | 7729 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 7730 | setKey.peerMac[2], setKey.peerMac[3], |
| 7731 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7732 | setKey.keyDirection); |
| 7733 | |
| 7734 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 7735 | |
| 7736 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 7737 | { |
| 7738 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7739 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 7740 | __LINE__, vos_status ); |
| 7741 | |
| 7742 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 7743 | |
| 7744 | return -EINVAL; |
| 7745 | |
| 7746 | } |
| 7747 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7748 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 7749 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 7750 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 7751 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7752 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 7753 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7754 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 7755 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 7756 | "%s: Update PreAuth Key success", __func__); |
| 7757 | return 0; |
| 7758 | } |
| 7759 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 7760 | { |
| 7761 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7762 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 7763 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7764 | } |
| 7765 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7766 | |
| 7767 | /* issue set key request to SME*/ |
| 7768 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7769 | pAdapter->sessionId, &setKey, &roamId ); |
| 7770 | |
| 7771 | if ( 0 != status ) |
| 7772 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7773 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7774 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 7775 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 7776 | return -EINVAL; |
| 7777 | } |
| 7778 | |
| 7779 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7780 | /* in case of IBSS as there was no information available about WEP keys during |
| 7781 | * 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] | 7782 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7783 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 7784 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 7785 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7786 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 7787 | ) |
| 7788 | && |
| 7789 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 7790 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 7791 | ) |
| 7792 | ) |
| 7793 | { |
| 7794 | setKey.keyDirection = eSIR_RX_ONLY; |
| 7795 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 7796 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7797 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7798 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7799 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 7800 | setKey.peerMac[2], setKey.peerMac[3], |
| 7801 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7802 | setKey.keyDirection); |
| 7803 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7804 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7805 | pAdapter->sessionId, &setKey, &roamId ); |
| 7806 | |
| 7807 | if ( 0 != status ) |
| 7808 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7809 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7810 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7811 | __func__, status); |
| 7812 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 7813 | return -EINVAL; |
| 7814 | } |
| 7815 | } |
| 7816 | } |
| 7817 | |
| 7818 | return 0; |
| 7819 | } |
| 7820 | |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7821 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7822 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
| 7823 | struct net_device *ndev, |
| 7824 | u8 key_index, bool pairwise, |
| 7825 | const u8 *mac_addr, |
| 7826 | struct key_params *params |
| 7827 | ) |
| 7828 | #else |
| 7829 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
| 7830 | struct net_device *ndev, |
| 7831 | u8 key_index, const u8 *mac_addr, |
| 7832 | struct key_params *params |
| 7833 | ) |
| 7834 | #endif |
| 7835 | { |
| 7836 | int ret; |
| 7837 | vos_ssr_protect(__func__); |
| 7838 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7839 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise, |
| 7840 | mac_addr, params); |
| 7841 | #else |
| 7842 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr, |
| 7843 | params); |
| 7844 | #endif |
| 7845 | vos_ssr_unprotect(__func__); |
| 7846 | |
| 7847 | return ret; |
| 7848 | } |
| 7849 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7850 | /* |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7851 | * FUNCTION: __wlan_hdd_cfg80211_get_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7852 | * This function is used to get the key information |
| 7853 | */ |
| 7854 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7855 | static int __wlan_hdd_cfg80211_get_key( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7856 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7857 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7858 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7859 | const u8 *mac_addr, void *cookie, |
| 7860 | void (*callback)(void *cookie, struct key_params*) |
| 7861 | ) |
| 7862 | #else |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7863 | static int __wlan_hdd_cfg80211_get_key( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7864 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7865 | struct net_device *ndev, |
| 7866 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 7867 | void (*callback)(void *cookie, struct key_params*) |
| 7868 | ) |
| 7869 | #endif |
| 7870 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7871 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 7872 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7873 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7874 | struct key_params params; |
| 7875 | |
| 7876 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7877 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 7878 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 7879 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 7880 | pAdapter->device_mode); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 7881 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7882 | memset(¶ms, 0, sizeof(params)); |
| 7883 | |
| 7884 | if (CSR_MAX_NUM_KEY <= key_index) |
| 7885 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7886 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7887 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7888 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7889 | |
| 7890 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 7891 | { |
| 7892 | case eCSR_ENCRYPT_TYPE_NONE: |
| 7893 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 7894 | break; |
| 7895 | |
| 7896 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 7897 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 7898 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 7899 | break; |
| 7900 | |
| 7901 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 7902 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 7903 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 7904 | break; |
| 7905 | |
| 7906 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 7907 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 7908 | break; |
| 7909 | |
| 7910 | case eCSR_ENCRYPT_TYPE_AES: |
| 7911 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 7912 | break; |
| 7913 | |
| 7914 | default: |
| 7915 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 7916 | break; |
| 7917 | } |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 7918 | |
c_hpothu | aaf1969 | 2014-05-17 17:01:48 +0530 | [diff] [blame] | 7919 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 7920 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
| 7921 | pAdapter->sessionId, params.cipher)); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 7922 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7923 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 7924 | params.seq_len = 0; |
| 7925 | params.seq = NULL; |
| 7926 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 7927 | callback(cookie, ¶ms); |
| 7928 | return 0; |
| 7929 | } |
| 7930 | |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 7931 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7932 | static int wlan_hdd_cfg80211_get_key( |
| 7933 | struct wiphy *wiphy, |
| 7934 | struct net_device *ndev, |
| 7935 | u8 key_index, bool pairwise, |
| 7936 | const u8 *mac_addr, void *cookie, |
| 7937 | void (*callback)(void *cookie, struct key_params*) |
| 7938 | ) |
| 7939 | #else |
| 7940 | static int wlan_hdd_cfg80211_get_key( |
| 7941 | struct wiphy *wiphy, |
| 7942 | struct net_device *ndev, |
| 7943 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 7944 | void (*callback)(void *cookie, struct key_params*) |
| 7945 | ) |
| 7946 | #endif |
| 7947 | { |
| 7948 | int ret; |
| 7949 | |
| 7950 | vos_ssr_protect(__func__); |
| 7951 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7952 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise, |
| 7953 | mac_addr, cookie, callback); |
| 7954 | #else |
| 7955 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr, |
| 7956 | callback); |
| 7957 | #endif |
| 7958 | vos_ssr_unprotect(__func__); |
| 7959 | |
| 7960 | return ret; |
| 7961 | } |
| 7962 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7963 | /* |
| 7964 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 7965 | * This function is used to delete the key information |
| 7966 | */ |
| 7967 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7968 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7969 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7970 | u8 key_index, |
| 7971 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7972 | const u8 *mac_addr |
| 7973 | ) |
| 7974 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7975 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7976 | struct net_device *ndev, |
| 7977 | u8 key_index, |
| 7978 | const u8 *mac_addr |
| 7979 | ) |
| 7980 | #endif |
| 7981 | { |
| 7982 | int status = 0; |
| 7983 | |
| 7984 | //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] | 7985 | //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] | 7986 | //it is observed that this is invalidating peer |
| 7987 | //key index whenever re-key is done. This is affecting data link. |
| 7988 | //It should be ok to ignore del_key. |
| 7989 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7990 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 7991 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7992 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 7993 | tCsrRoamSetKey setKey; |
| 7994 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7995 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7996 | ENTER(); |
| 7997 | |
| 7998 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 7999 | __func__,pAdapter->device_mode); |
| 8000 | |
| 8001 | if (CSR_MAX_NUM_KEY <= key_index) |
| 8002 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8003 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8004 | key_index); |
| 8005 | |
| 8006 | return -EINVAL; |
| 8007 | } |
| 8008 | |
| 8009 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 8010 | setKey.keyId = key_index; |
| 8011 | |
| 8012 | if (mac_addr) |
| 8013 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 8014 | else |
| 8015 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 8016 | |
| 8017 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 8018 | |
| 8019 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8020 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8021 | ) |
| 8022 | { |
| 8023 | |
| 8024 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8025 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8026 | if( pHostapdState->bssState == BSS_START) |
| 8027 | { |
| 8028 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8029 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8030 | if ( status != eHAL_STATUS_SUCCESS ) |
| 8031 | { |
| 8032 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8033 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 8034 | __LINE__, status ); |
| 8035 | } |
| 8036 | } |
| 8037 | } |
| 8038 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8039 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8040 | ) |
| 8041 | { |
| 8042 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8043 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8044 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 8045 | |
| 8046 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8047 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8048 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 8049 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8050 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8051 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 8052 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8053 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8054 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8055 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8056 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8057 | if ( 0 != status ) |
| 8058 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8059 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8060 | "%s: sme_RoamSetKey failure, returned %d", |
| 8061 | __func__, status); |
| 8062 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 8063 | return -EINVAL; |
| 8064 | } |
| 8065 | } |
| 8066 | } |
| 8067 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8068 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8069 | return status; |
| 8070 | } |
| 8071 | |
| 8072 | /* |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 8073 | * FUNCTION: __wlan_hdd_cfg80211_set_default_key |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8074 | * This function is used to set the default tx key index |
| 8075 | */ |
| 8076 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 8077 | static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8078 | struct net_device *ndev, |
| 8079 | u8 key_index, |
| 8080 | bool unicast, bool multicast) |
| 8081 | #else |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 8082 | static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8083 | struct net_device *ndev, |
| 8084 | u8 key_index) |
| 8085 | #endif |
| 8086 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8087 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8088 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8089 | hdd_wext_state_t *pWextState; |
| 8090 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8091 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8092 | |
| 8093 | ENTER(); |
| 8094 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8095 | if ((NULL == pAdapter)) |
| 8096 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 8097 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8098 | "invalid adapter"); |
| 8099 | return -EINVAL; |
| 8100 | } |
| 8101 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8102 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8103 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
| 8104 | pAdapter->sessionId, key_index)); |
| 8105 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8106 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 8107 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8108 | |
| 8109 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 8110 | { |
| 8111 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8112 | "invalid Wext state or HDD context"); |
| 8113 | return -EINVAL; |
| 8114 | } |
| 8115 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8116 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8117 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8119 | if (CSR_MAX_NUM_KEY <= key_index) |
| 8120 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8121 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8122 | key_index); |
| 8123 | |
| 8124 | return -EINVAL; |
| 8125 | } |
| 8126 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8127 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8128 | status = wlan_hdd_validate_context(pHddCtx); |
| 8129 | |
| 8130 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8131 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8132 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8133 | "%s: HDD context is not valid", __func__); |
| 8134 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8135 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8136 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8137 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8138 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8139 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8140 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8141 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 8142 | pHddStaCtx->conn_info.ucEncryptionType) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8143 | (eCSR_ENCRYPT_TYPE_AES != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 8144 | pHddStaCtx->conn_info.ucEncryptionType) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8145 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8146 | { |
| 8147 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8148 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8149 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8150 | tCsrRoamSetKey setKey; |
| 8151 | v_U32_t roamId= 0xFF; |
| 8152 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8153 | |
| 8154 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8155 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8156 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8157 | Keys->defaultIndex = (u8)key_index; |
| 8158 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 8159 | setKey.keyId = key_index; |
| 8160 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8161 | |
| 8162 | vos_mem_copy(&setKey.Key[0], |
| 8163 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8164 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8165 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8166 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8167 | |
| 8168 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8169 | &pHddStaCtx->conn_info.bssId[0], |
| 8170 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8171 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 8172 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 8173 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 8174 | eCSR_ENCRYPT_TYPE_WEP104) |
| 8175 | { |
| 8176 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 8177 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 8178 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 8179 | type(104) and switching encryption type to 40*/ |
| 8180 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 8181 | eCSR_ENCRYPT_TYPE_WEP40; |
| 8182 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 8183 | eCSR_ENCRYPT_TYPE_WEP40; |
| 8184 | } |
| 8185 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8186 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8187 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8188 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8189 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8190 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8191 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8192 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8193 | if ( 0 != status ) |
| 8194 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8195 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8196 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8197 | status); |
| 8198 | return -EINVAL; |
| 8199 | } |
| 8200 | } |
| 8201 | } |
| 8202 | |
| 8203 | /* In SoftAp mode setting key direction for default mode */ |
| 8204 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 8205 | { |
| 8206 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 8207 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 8208 | (eCSR_ENCRYPT_TYPE_AES != |
| 8209 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 8210 | ) |
| 8211 | { |
| 8212 | /* Saving key direction for default key index to TX default */ |
| 8213 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 8214 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 8215 | } |
| 8216 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8217 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8218 | return status; |
| 8219 | } |
| 8220 | |
Mahesh A Saptasagar | 1a51bc0 | 2014-06-02 18:28:08 +0530 | [diff] [blame] | 8221 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 8222 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 8223 | struct net_device *ndev, |
| 8224 | u8 key_index, |
| 8225 | bool unicast, bool multicast) |
| 8226 | #else |
| 8227 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 8228 | struct net_device *ndev, |
| 8229 | u8 key_index) |
| 8230 | #endif |
| 8231 | { |
| 8232 | int ret; |
| 8233 | vos_ssr_protect(__func__); |
| 8234 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 8235 | ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast, |
| 8236 | multicast); |
| 8237 | #else |
| 8238 | ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index); |
| 8239 | #endif |
| 8240 | vos_ssr_unprotect(__func__); |
| 8241 | |
| 8242 | return ret; |
| 8243 | } |
| 8244 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8245 | /* |
| 8246 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 8247 | * This function is used to inform the BSS details to nl80211 interface. |
| 8248 | */ |
| 8249 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 8250 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 8251 | { |
| 8252 | struct net_device *dev = pAdapter->dev; |
| 8253 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 8254 | struct wiphy *wiphy = wdev->wiphy; |
| 8255 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 8256 | int chan_no; |
| 8257 | int ie_length; |
| 8258 | const char *ie; |
| 8259 | unsigned int freq; |
| 8260 | struct ieee80211_channel *chan; |
| 8261 | int rssi = 0; |
| 8262 | struct cfg80211_bss *bss = NULL; |
| 8263 | |
| 8264 | ENTER(); |
| 8265 | |
| 8266 | if( NULL == pBssDesc ) |
| 8267 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8268 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8269 | return bss; |
| 8270 | } |
| 8271 | |
| 8272 | chan_no = pBssDesc->channelId; |
| 8273 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 8274 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 8275 | |
| 8276 | if( NULL == ie ) |
| 8277 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8278 | 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] | 8279 | return bss; |
| 8280 | } |
| 8281 | |
| 8282 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 8283 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 8284 | { |
| 8285 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 8286 | } |
| 8287 | else |
| 8288 | { |
| 8289 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 8290 | } |
| 8291 | #else |
| 8292 | freq = ieee80211_channel_to_frequency(chan_no); |
| 8293 | #endif |
| 8294 | |
| 8295 | chan = __ieee80211_get_channel(wiphy, freq); |
| 8296 | |
Santhosh Kumar Padma | a45fdb1 | 2014-04-15 15:54:38 +0530 | [diff] [blame] | 8297 | if (!chan) { |
| 8298 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__); |
| 8299 | return NULL; |
| 8300 | } |
| 8301 | |
Abhishek Singh | aee4394 | 2014-06-16 18:55:47 +0530 | [diff] [blame] | 8302 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8303 | |
Abhishek Singh | aee4394 | 2014-06-16 18:55:47 +0530 | [diff] [blame] | 8304 | return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8305 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8306 | pBssDesc->capabilityInfo, |
| 8307 | pBssDesc->beaconInterval, ie, ie_length, |
Abhishek Singh | aee4394 | 2014-06-16 18:55:47 +0530 | [diff] [blame] | 8308 | rssi, GFP_KERNEL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8309 | } |
| 8310 | |
| 8311 | |
| 8312 | |
| 8313 | /* |
| 8314 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 8315 | * This function is used to inform the BSS details to nl80211 interface. |
| 8316 | */ |
| 8317 | struct cfg80211_bss* |
| 8318 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 8319 | tSirBssDescription *bss_desc |
| 8320 | ) |
| 8321 | { |
| 8322 | /* |
| 8323 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 8324 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 8325 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 8326 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 8327 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 8328 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 8329 | cfg80211_inform_bss_frame. |
| 8330 | */ |
| 8331 | struct net_device *dev = pAdapter->dev; |
| 8332 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 8333 | struct wiphy *wiphy = wdev->wiphy; |
| 8334 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 8335 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 8336 | qcom_ie_age *qie_age = NULL; |
| 8337 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 8338 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8339 | 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] | 8340 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8341 | const char *ie = |
| 8342 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 8343 | unsigned int freq; |
| 8344 | struct ieee80211_channel *chan; |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 8345 | struct ieee80211_mgmt *mgmt = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8346 | struct cfg80211_bss *bss_status = NULL; |
| 8347 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 8348 | int rssi = 0; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8349 | hdd_context_t *pHddCtx; |
| 8350 | int status; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8351 | #ifdef WLAN_OPEN_SOURCE |
| 8352 | struct timespec ts; |
| 8353 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8354 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8355 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8356 | status = wlan_hdd_validate_context(pHddCtx); |
| 8357 | |
| 8358 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8359 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8360 | { |
| 8361 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8362 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 8363 | return NULL; |
| 8364 | } |
| 8365 | |
| 8366 | |
| 8367 | if (0 != status) |
| 8368 | { |
| 8369 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8370 | "%s: HDD context is not valid", __func__); |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 8371 | return NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8372 | } |
| 8373 | |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 8374 | mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8375 | if (!mgmt) |
| 8376 | { |
| 8377 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8378 | "%s: memory allocation failed ", __func__); |
| 8379 | return NULL; |
| 8380 | } |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 8381 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8382 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8383 | |
| 8384 | #ifdef WLAN_OPEN_SOURCE |
| 8385 | /* Android does not want the timestamp from the frame. |
| 8386 | Instead it wants a monotonic increasing value */ |
| 8387 | get_monotonic_boottime(&ts); |
| 8388 | mgmt->u.probe_resp.timestamp = |
| 8389 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 8390 | #else |
| 8391 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8392 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 8393 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8394 | |
| 8395 | #endif |
| 8396 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8397 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 8398 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 8399 | |
| 8400 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 8401 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 8402 | /* Assuming this is the last IE, copy at the end */ |
| 8403 | ie_length -=sizeof(qcom_ie_age); |
| 8404 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 8405 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 8406 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 8407 | qie_age->oui_1 = QCOM_OUI1; |
| 8408 | qie_age->oui_2 = QCOM_OUI2; |
| 8409 | qie_age->oui_3 = QCOM_OUI3; |
| 8410 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 8411 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 8412 | #endif |
| 8413 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8414 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 8415 | if (bss_desc->fProbeRsp) |
| 8416 | { |
| 8417 | mgmt->frame_control |= |
| 8418 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 8419 | } |
| 8420 | else |
| 8421 | { |
| 8422 | mgmt->frame_control |= |
| 8423 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 8424 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8425 | |
| 8426 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8427 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8428 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 8429 | { |
| 8430 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 8431 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8432 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8433 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 8434 | |
| 8435 | { |
| 8436 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 8437 | } |
| 8438 | else |
| 8439 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 8440 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d", |
| 8441 | __func__, chan_no); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8442 | kfree(mgmt); |
| 8443 | return NULL; |
| 8444 | } |
| 8445 | #else |
| 8446 | freq = ieee80211_channel_to_frequency(chan_no); |
| 8447 | #endif |
| 8448 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 8449 | /*when the band is changed on the fly using the GUI, three things are done |
| 8450 | * 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) |
| 8451 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 8452 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 8453 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 8454 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 8455 | * 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 |
| 8456 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 8457 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 8458 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 8459 | * So drop the bss and continue to next bss. |
| 8460 | */ |
| 8461 | if(chan == NULL) |
| 8462 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 8463 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8464 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 8465 | return NULL; |
| 8466 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8467 | /*To keep the rssi icon of the connected AP in the scan window |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8468 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8469 | * */ |
| 8470 | if (( eConnectionState_Associated == |
| 8471 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 8472 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 8473 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 8474 | WNI_CFG_BSSID_LEN))) |
| 8475 | { |
| 8476 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 8477 | rssi = (pAdapter->rssi * 100); |
| 8478 | } |
| 8479 | else |
| 8480 | { |
| 8481 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 8482 | } |
| 8483 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 8484 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d" |
| 8485 | "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid), |
| 8486 | chan->center_freq, (int)(rssi/100)); |
| 8487 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8488 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 8489 | frame_len, rssi, GFP_KERNEL); |
| 8490 | kfree(mgmt); |
| 8491 | return bss_status; |
| 8492 | } |
| 8493 | |
| 8494 | /* |
| 8495 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 8496 | * This function is used to update the BSS data base of CFG8011 |
| 8497 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8498 | 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] | 8499 | tCsrRoamInfo *pRoamInfo |
| 8500 | ) |
| 8501 | { |
| 8502 | tCsrRoamConnectedProfile roamProfile; |
| 8503 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8504 | struct cfg80211_bss *bss = NULL; |
| 8505 | |
| 8506 | ENTER(); |
| 8507 | |
| 8508 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 8509 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 8510 | |
| 8511 | if (NULL != roamProfile.pBssDesc) |
| 8512 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8513 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8514 | &roamProfile); |
| 8515 | |
| 8516 | if (NULL == bss) |
| 8517 | { |
| 8518 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 8519 | __func__); |
| 8520 | } |
| 8521 | |
| 8522 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 8523 | } |
| 8524 | else |
| 8525 | { |
| 8526 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 8527 | __func__); |
| 8528 | } |
| 8529 | return bss; |
| 8530 | } |
| 8531 | |
| 8532 | /* |
| 8533 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 8534 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8535 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 8536 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8537 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8538 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 8539 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8540 | tCsrScanResultInfo *pScanResult; |
| 8541 | eHalStatus status = 0; |
| 8542 | tScanResultHandle pResult; |
| 8543 | struct cfg80211_bss *bss_status = NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8544 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8545 | |
| 8546 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 8547 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8548 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8549 | TRACE_CODE_HDD_CFG80211_UPDATE_BSS, |
| 8550 | NO_SESSION, pAdapter->sessionId)); |
| 8551 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8552 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8553 | |
| 8554 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8555 | { |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8556 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8557 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 8558 | return -EAGAIN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8559 | } |
| 8560 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8561 | |
| 8562 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8563 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 8564 | { |
| 8565 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8566 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 8567 | return VOS_STATUS_E_PERM; |
| 8568 | } |
| 8569 | |
| 8570 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8571 | /* |
| 8572 | * start getting scan results and populate cgf80211 BSS database |
| 8573 | */ |
| 8574 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 8575 | |
| 8576 | /* no scan results */ |
| 8577 | if (NULL == pResult) |
| 8578 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 8579 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d", |
| 8580 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8581 | return status; |
| 8582 | } |
| 8583 | |
| 8584 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 8585 | |
| 8586 | while (pScanResult) |
| 8587 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8588 | /* |
| 8589 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 8590 | * entry already exists in bss data base of cfg80211 for that |
| 8591 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 8592 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 8593 | * mgmt packet as input. As of now there is no possibility to get |
| 8594 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8595 | * ieee80211_mgmt(probe response) and passing to c |
| 8596 | * fg80211_inform_bss_frame. |
| 8597 | * */ |
| 8598 | |
| 8599 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 8600 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8601 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8602 | |
| 8603 | if (NULL == bss_status) |
| 8604 | { |
| 8605 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8606 | "%s: NULL returned by cfg80211_inform_bss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8607 | } |
| 8608 | else |
| 8609 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 8610 | cfg80211_put_bss( |
| 8611 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 8612 | wiphy, |
| 8613 | #endif |
| 8614 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8615 | } |
| 8616 | |
| 8617 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 8618 | } |
| 8619 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8620 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8621 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8622 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8623 | } |
| 8624 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8625 | void |
| 8626 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 8627 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8628 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 8629 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8630 | } /****** end hddPrintMacAddr() ******/ |
| 8631 | |
| 8632 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 8633 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8634 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8635 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8636 | "%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] | 8637 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 8638 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 8639 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8640 | } /****** end hddPrintPmkId() ******/ |
| 8641 | |
| 8642 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 8643 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 8644 | |
| 8645 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 8646 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 8647 | |
| 8648 | #define dump_bssid(bssid) \ |
| 8649 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8650 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 8651 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8652 | } |
| 8653 | |
| 8654 | #define dump_pmkid(pMac, pmkid) \ |
| 8655 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8656 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 8657 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8658 | } |
| 8659 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 8660 | #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] | 8661 | /* |
| 8662 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 8663 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 8664 | */ |
| 8665 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8666 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8667 | int index, bool preauth ) |
| 8668 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8669 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8670 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 8671 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8672 | |
| 8673 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8674 | 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] | 8675 | |
| 8676 | if( NULL == pRoamInfo ) |
| 8677 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8678 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8679 | return -EINVAL; |
| 8680 | } |
| 8681 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 8682 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 8683 | { |
| 8684 | dump_bssid(pRoamInfo->bssid); |
| 8685 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8686 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 8687 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8688 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8689 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8690 | } |
| 8691 | #endif //FEATURE_WLAN_LFR |
| 8692 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 8693 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 8694 | /* |
| 8695 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth |
| 8696 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 8697 | * |
| 8698 | */ |
| 8699 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
| 8700 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
| 8701 | tCsrRoamInfo *pRoamInfo) |
| 8702 | { |
| 8703 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 8704 | union iwreq_data wrqu; |
| 8705 | |
| 8706 | ENTER(); |
| 8707 | |
| 8708 | if (NULL == pAdapter) |
| 8709 | { |
| 8710 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 8711 | return VOS_STATUS_E_FAILURE; |
| 8712 | } |
| 8713 | |
| 8714 | /* create the event */ |
| 8715 | memset(&wrqu, 0, sizeof(wrqu)); |
| 8716 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 8717 | |
| 8718 | wrqu.data.pointer = metrics_notification; |
| 8719 | wrqu.data.length = scnprintf(metrics_notification, |
| 8720 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT " |
| 8721 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 8722 | |
| 8723 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 8724 | |
| 8725 | EXIT(); |
| 8726 | |
| 8727 | return VOS_STATUS_SUCCESS; |
| 8728 | } |
| 8729 | |
| 8730 | /* |
| 8731 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status |
| 8732 | * 802.11r/LFR metrics reporting function to report preauth completion |
| 8733 | * or failure |
| 8734 | */ |
| 8735 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status( |
| 8736 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status) |
| 8737 | { |
| 8738 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 8739 | union iwreq_data wrqu; |
| 8740 | |
| 8741 | ENTER(); |
| 8742 | |
| 8743 | if (NULL == pAdapter) |
| 8744 | { |
| 8745 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 8746 | return VOS_STATUS_E_FAILURE; |
| 8747 | } |
| 8748 | |
| 8749 | /* create the event */ |
| 8750 | memset(&wrqu, 0, sizeof(wrqu)); |
| 8751 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 8752 | |
| 8753 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 8754 | "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR, |
| 8755 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 8756 | |
| 8757 | if (1 == preauth_status) |
| 8758 | strncat(metrics_notification, " TRUE", 5); |
| 8759 | else |
| 8760 | strncat(metrics_notification, " FALSE", 6); |
| 8761 | |
| 8762 | wrqu.data.pointer = metrics_notification; |
| 8763 | wrqu.data.length = strlen(metrics_notification); |
| 8764 | |
| 8765 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 8766 | |
| 8767 | EXIT(); |
| 8768 | |
| 8769 | return VOS_STATUS_SUCCESS; |
| 8770 | } |
| 8771 | |
| 8772 | /* |
| 8773 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover |
| 8774 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 8775 | * |
| 8776 | */ |
| 8777 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter, |
| 8778 | tCsrRoamInfo *pRoamInfo) |
| 8779 | { |
| 8780 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 8781 | union iwreq_data wrqu; |
| 8782 | |
| 8783 | ENTER(); |
| 8784 | |
| 8785 | if (NULL == pAdapter) |
| 8786 | { |
| 8787 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 8788 | return VOS_STATUS_E_FAILURE; |
| 8789 | } |
| 8790 | |
| 8791 | /* create the event */ |
| 8792 | memset(&wrqu, 0, sizeof(wrqu)); |
| 8793 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 8794 | |
| 8795 | wrqu.data.pointer = metrics_notification; |
| 8796 | wrqu.data.length = scnprintf(metrics_notification, |
| 8797 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER " |
| 8798 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 8799 | |
| 8800 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 8801 | |
| 8802 | EXIT(); |
| 8803 | |
| 8804 | return VOS_STATUS_SUCCESS; |
| 8805 | } |
| 8806 | #endif |
| 8807 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8808 | /* |
| 8809 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 8810 | * scanning callback function, called after finishing scan |
| 8811 | * |
| 8812 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8813 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8814 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 8815 | { |
| 8816 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8817 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8818 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8819 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8820 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8821 | struct cfg80211_scan_request *req = NULL; |
| 8822 | int ret = 0; |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 8823 | bool aborted = false; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8824 | long waitRet = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8825 | |
| 8826 | ENTER(); |
| 8827 | |
| 8828 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8829 | "%s called with halHandle = %p, pContext = %p," |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8830 | "scanID = %d, returned status = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8831 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 8832 | |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 8833 | pScanInfo->mScanPendingCounter = 0; |
| 8834 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8835 | //Block on scan req completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8836 | waitRet = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8837 | &pScanInfo->scan_req_completion_event, |
| 8838 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8839 | if (waitRet <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8840 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8841 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8842 | "%s wait on scan_req_completion_event failed %ld",__func__, waitRet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8843 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8844 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8845 | } |
| 8846 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 8847 | if (pScanInfo->mScanPending != VOS_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8848 | { |
| 8849 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8850 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8851 | } |
| 8852 | |
| 8853 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8854 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8855 | { |
| 8856 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8857 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8858 | "scanId = %d", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8859 | (int) scanId); |
| 8860 | } |
| 8861 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8862 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8863 | pAdapter); |
| 8864 | |
| 8865 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8866 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8867 | |
| 8868 | |
| 8869 | /* If any client wait scan result through WEXT |
| 8870 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8871 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8872 | { |
| 8873 | /* The other scan request waiting for current scan finish |
| 8874 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8875 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8876 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8877 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8878 | } |
| 8879 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8880 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8881 | { |
| 8882 | struct net_device *dev = pAdapter->dev; |
| 8883 | union iwreq_data wrqu; |
| 8884 | int we_event; |
| 8885 | char *msg; |
| 8886 | |
| 8887 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 8888 | we_event = SIOCGIWSCAN; |
| 8889 | msg = NULL; |
| 8890 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 8891 | } |
| 8892 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8893 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8894 | |
| 8895 | /* Get the Scan Req */ |
| 8896 | req = pAdapter->request; |
| 8897 | |
| 8898 | if (!req) |
| 8899 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8900 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 8901 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8902 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8903 | } |
| 8904 | |
| 8905 | /* |
| 8906 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8907 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8908 | req->n_ssids = 0; |
| 8909 | req->n_channels = 0; |
| 8910 | req->ie = 0; |
| 8911 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8912 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8913 | /* Scan is no longer pending */ |
| 8914 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8915 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 8916 | /* |
| 8917 | * cfg80211_scan_done informing NL80211 about completion |
| 8918 | * of scanning |
| 8919 | */ |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 8920 | if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE) |
| 8921 | { |
| 8922 | aborted = true; |
| 8923 | } |
| 8924 | cfg80211_scan_done(req, aborted); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 8925 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8926 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8927 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 8928 | /* release the wake lock at the end of the scan*/ |
| 8929 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8930 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8931 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 8932 | * immediatly after the driver gets connect request(i.e after scan) |
| 8933 | * from supplicant, this result in app's is suspending and not able |
| 8934 | * to process the connect request to AP */ |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8935 | hdd_prevent_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8936 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 8937 | #ifdef FEATURE_WLAN_TDLS |
c_hpothu | 3c8f8e8 | 2014-06-02 18:01:50 +0530 | [diff] [blame] | 8938 | if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)) |
| 8939 | { |
| 8940 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 8941 | } |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 8942 | #endif |
| 8943 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8944 | EXIT(); |
| 8945 | return 0; |
| 8946 | } |
| 8947 | |
| 8948 | /* |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 8949 | * FUNCTION: hdd_isConnectionInProgress |
| 8950 | * Go through each adapter and check if Connection is in progress |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 8951 | * |
| 8952 | */ |
Ganesh Kondabattini | aeb7b77 | 2014-08-11 20:00:36 +0530 | [diff] [blame] | 8953 | v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx, v_BOOL_t isRoC ) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 8954 | { |
| 8955 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 8956 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 8957 | hdd_adapter_t *pAdapter = NULL; |
| 8958 | VOS_STATUS status = 0; |
| 8959 | v_U8_t staId = 0; |
| 8960 | v_U8_t *staMac = NULL; |
| 8961 | |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 8962 | if (TRUE == pHddCtx->btCoexModeSet) |
| 8963 | { |
| 8964 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 8965 | FL("BTCoex Mode operation in progress")); |
| 8966 | return VOS_TRUE; |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 8967 | } |
| 8968 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 8969 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8970 | |
| 8971 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 8972 | { |
| 8973 | pAdapter = pAdapterNode->pAdapter; |
| 8974 | |
| 8975 | if( pAdapter ) |
| 8976 | { |
| 8977 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8978 | "%s: Adapter with device mode %s (%d) exists", |
| 8979 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 8980 | pAdapter->device_mode); |
Ganesh Kondabattini | aeb7b77 | 2014-08-11 20:00:36 +0530 | [diff] [blame] | 8981 | if ((((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) || |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 8982 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 8983 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) && |
| 8984 | (eConnectionState_Connecting == |
| 8985 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 8986 | { |
| 8987 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8988 | "%s: %p(%d) Connection is in progress", __func__, |
| 8989 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
| 8990 | return VOS_TRUE; |
| 8991 | } |
Ganesh Kondabattini | aeb7b77 | 2014-08-11 20:00:36 +0530 | [diff] [blame] | 8992 | if (((!isRoC) && (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)) || |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8993 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 8994 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 8995 | { |
| 8996 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8997 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8998 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 8999 | { |
| 9000 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 9001 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9002 | "%s: client " MAC_ADDRESS_STR |
| 9003 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 9004 | MAC_ADDR_ARRAY(staMac)); |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 9005 | return VOS_TRUE; |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 9006 | } |
| 9007 | } |
| 9008 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 9009 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 9010 | { |
| 9011 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 9012 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9013 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 9014 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 9015 | { |
| 9016 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 9017 | |
| 9018 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9019 | "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the " |
| 9020 | "middle of WPS/EAPOL exchange.", __func__, |
| 9021 | MAC_ADDR_ARRAY(staMac)); |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 9022 | return VOS_TRUE; |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 9023 | } |
| 9024 | } |
| 9025 | } |
| 9026 | } |
| 9027 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9028 | pAdapterNode = pNext; |
| 9029 | } |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 9030 | return VOS_FALSE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9031 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 9032 | |
| 9033 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 9034 | * FUNCTION: __wlan_hdd_cfg80211_scan |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9035 | * this scan respond to scan trigger and update cfg80211 scan database |
| 9036 | * later, scan dump command can be used to recieve scan results |
| 9037 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 9038 | int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9039 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 9040 | struct net_device *dev, |
| 9041 | #endif |
| 9042 | struct cfg80211_scan_request *request) |
| 9043 | { |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 9044 | hdd_adapter_t *pAdapter = NULL; |
| 9045 | hdd_context_t *pHddCtx = NULL; |
| 9046 | hdd_wext_state_t *pwextBuf = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9047 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9048 | tCsrScanRequest scanRequest; |
| 9049 | tANI_U8 *channelList = NULL, i; |
| 9050 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9051 | int status; |
| 9052 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9053 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9054 | |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 9055 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 9056 | struct net_device *dev = NULL; |
| 9057 | if (NULL == request) |
| 9058 | { |
| 9059 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9060 | "%s: scan req param null", __func__); |
| 9061 | return -EINVAL; |
| 9062 | } |
| 9063 | dev = request->wdev->netdev; |
| 9064 | #endif |
| 9065 | |
| 9066 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 9067 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 9068 | pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9069 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9070 | ENTER(); |
| 9071 | |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9072 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 9073 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 9074 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 9075 | pAdapter->device_mode); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 9076 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9077 | status = wlan_hdd_validate_context(pHddCtx); |
| 9078 | |
| 9079 | if (0 != status) |
| 9080 | { |
| 9081 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9082 | "%s: HDD context is not valid", __func__); |
| 9083 | return status; |
| 9084 | } |
| 9085 | |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 9086 | if (NULL == pwextBuf) |
| 9087 | { |
| 9088 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n", |
| 9089 | __func__); |
| 9090 | return -EIO; |
| 9091 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9092 | cfg_param = pHddCtx->cfg_ini; |
| 9093 | pScanInfo = &pHddCtx->scan_info; |
| 9094 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9095 | #ifdef WLAN_BTAMP_FEATURE |
| 9096 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9097 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9098 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 9099 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9100 | "%s: No scanning when AMP is on", __func__); |
| 9101 | return -EOPNOTSUPP; |
| 9102 | } |
| 9103 | #endif |
| 9104 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9105 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9106 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9107 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 9108 | "%s: Not scanning on device_mode = %s (%d)", |
| 9109 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 9110 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9111 | return -EOPNOTSUPP; |
| 9112 | } |
| 9113 | |
| 9114 | if (TRUE == pScanInfo->mScanPending) |
| 9115 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 9116 | if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ ) |
| 9117 | { |
| 9118 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__); |
| 9119 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9120 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9121 | } |
| 9122 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9123 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9124 | //Channel and action frame is pending |
| 9125 | //Otherwise Cancel Remain On Channel and allow Scan |
| 9126 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9127 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9128 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 9129 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9130 | return -EBUSY; |
| 9131 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9132 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 9133 | /* if tdls disagree scan right now, return immediately. |
| 9134 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 9135 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 9136 | */ |
| 9137 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 9138 | wiphy, |
| 9139 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 9140 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 9141 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 9142 | request); |
| 9143 | if(status <= 0) |
| 9144 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9145 | if(!status) |
| 9146 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress." |
| 9147 | "scan rejected %d", __func__, status); |
| 9148 | else |
| 9149 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d", |
| 9150 | __func__, status); |
| 9151 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 9152 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9153 | } |
| 9154 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9155 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9156 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 9157 | { |
| 9158 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 9159 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9160 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9161 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9162 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 9163 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9164 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9165 | "%s: MAX TM Level Scan not allowed", __func__); |
| 9166 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9167 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9168 | } |
| 9169 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 9170 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 9171 | /* Check if scan is allowed at this point of time. |
| 9172 | */ |
Ganesh Kondabattini | aeb7b77 | 2014-08-11 20:00:36 +0530 | [diff] [blame] | 9173 | if (hdd_isConnectionInProgress(pHddCtx, VOS_FALSE)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 9174 | { |
| 9175 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 9176 | return -EBUSY; |
| 9177 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9178 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9179 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 9180 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9181 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
| 9182 | (int)request->n_ssids); |
| 9183 | |
| 9184 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 9185 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 9186 | * is not aging out the scan results. |
| 9187 | */ |
| 9188 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9189 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9190 | request->n_ssids = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9191 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9192 | |
| 9193 | if ((request->ssids) && (0 < request->n_ssids)) |
| 9194 | { |
| 9195 | tCsrSSIDInfo *SsidInfo; |
| 9196 | int j; |
| 9197 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 9198 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 9199 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 9200 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 9201 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 9202 | |
| 9203 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 9204 | { |
| 9205 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9206 | "%s: memory alloc failed SSIDInfo buffer", __func__); |
| 9207 | return -ENOMEM; |
| 9208 | } |
| 9209 | |
| 9210 | /* copy all the ssid's and their length */ |
| 9211 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 9212 | { |
| 9213 | /* get the ssid length */ |
| 9214 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 9215 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 9216 | SsidInfo->SSID.length); |
| 9217 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 9218 | hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s", |
| 9219 | j, SsidInfo->SSID.ssId); |
| 9220 | } |
| 9221 | /* set the scan type to active */ |
| 9222 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 9223 | } |
| 9224 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9225 | { |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 9226 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9227 | TRACE_CODE_HDD_CFG80211_SCAN, |
| 9228 | pAdapter->sessionId, 0)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9229 | /* set the scan type to active */ |
| 9230 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9231 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9232 | else |
| 9233 | { |
| 9234 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 9235 | scanRequest.scanType = pScanInfo->scan_mode; |
| 9236 | } |
| 9237 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
| 9238 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9239 | |
| 9240 | /* set BSSType to default type */ |
| 9241 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 9242 | |
| 9243 | /*TODO: scan the requested channels only*/ |
| 9244 | |
| 9245 | /*Right now scanning all the channels */ |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9246 | if (MAX_CHANNEL < request->n_channels) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9247 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9248 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 9249 | "No of Scan Channels exceeded limit: %d", request->n_channels); |
| 9250 | request->n_channels = MAX_CHANNEL; |
| 9251 | } |
| 9252 | |
| 9253 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9254 | "No of Scan Channels: %d", request->n_channels); |
| 9255 | |
| 9256 | |
| 9257 | if( request->n_channels ) |
| 9258 | { |
| 9259 | char chList [(request->n_channels*5)+1]; |
| 9260 | int len; |
| 9261 | channelList = vos_mem_malloc( request->n_channels ); |
| 9262 | if( NULL == channelList ) |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 9263 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9264 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9265 | "%s: memory alloc failed channelList", __func__); |
| 9266 | status = -ENOMEM; |
| 9267 | goto free_mem; |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 9268 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9269 | |
| 9270 | for( i = 0, len = 0; i < request->n_channels ; i++ ) |
| 9271 | { |
| 9272 | channelList[i] = request->channels[i]->hw_value; |
| 9273 | len += snprintf(chList+len, 5, "%d ", channelList[i]); |
| 9274 | } |
| 9275 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9276 | hddLog(VOS_TRACE_LEVEL_INFO, |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9277 | "Channel-List: %s ", chList); |
| 9278 | } |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 9279 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9280 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 9281 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 9282 | |
| 9283 | /* set requestType to full scan */ |
| 9284 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 9285 | |
| 9286 | /* Flush the scan results(only p2p beacons) for STA scan and P2P |
| 9287 | * search (Flush on both full scan and social scan but not on single |
| 9288 | * channel scan).P2P search happens on 3 social channels (1, 6, 11) |
| 9289 | */ |
| 9290 | |
| 9291 | /* Supplicant does single channel scan after 8-way handshake |
| 9292 | * and in that case driver shoudnt flush scan results. If |
| 9293 | * driver flushes the scan results here and unfortunately if |
| 9294 | * the AP doesnt respond to our probe req then association |
| 9295 | * fails which is not desired |
| 9296 | */ |
| 9297 | |
| 9298 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 9299 | { |
| 9300 | hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results"); |
| 9301 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 9302 | pAdapter->sessionId ); |
| 9303 | } |
| 9304 | |
| 9305 | if( request->ie_len ) |
| 9306 | { |
| 9307 | /* save this for future association (join requires this) */ |
| 9308 | /*TODO: Array needs to be converted to dynamic allocation, |
| 9309 | * as multiple ie.s can be sent in cfg80211_scan_request structure |
| 9310 | * CR 597966 |
| 9311 | */ |
| 9312 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 9313 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 9314 | pScanInfo->scanAddIE.length = request->ie_len; |
| 9315 | |
| 9316 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 9317 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 9318 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9319 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9320 | if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9321 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9322 | pwextBuf->roamProfile.nAddIEScanLength = request->ie_len; |
| 9323 | memcpy( pwextBuf->roamProfile.addIEScan, |
| 9324 | request->ie, request->ie_len); |
| 9325 | } |
| 9326 | else |
| 9327 | { |
| 9328 | hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:" |
| 9329 | "%zu", request->ie_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9330 | } |
| 9331 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9332 | } |
| 9333 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 9334 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 9335 | |
| 9336 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 9337 | request->ie_len); |
| 9338 | if (pP2pIe != NULL) |
| 9339 | { |
| 9340 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 9341 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 9342 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 9343 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9344 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9345 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 9346 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 9347 | "Go nego completed to Connection is started"); |
| 9348 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 9349 | "for 8way Handshake"); |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9350 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9351 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 9352 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9353 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9354 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 9355 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 9356 | "Disconnected state to Connection is started"); |
| 9357 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 9358 | "for 4way Handshake"); |
| 9359 | } |
| 9360 | #endif |
| 9361 | |
| 9362 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 9363 | if(TRUE == request->no_cck) |
| 9364 | { |
| 9365 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9366 | "%s: This is a P2P Search", __func__); |
| 9367 | scanRequest.p2pSearch = 1; |
| 9368 | |
| 9369 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 9370 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9371 | /* set requestType to P2P Discovery */ |
| 9372 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
| 9373 | } |
| 9374 | |
| 9375 | /* |
| 9376 | Skip Dfs Channel in case of P2P Search |
| 9377 | if it is set in ini file |
| 9378 | */ |
| 9379 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 9380 | { |
| 9381 | scanRequest.skipDfsChnlInP2pSearch = 1; |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 9382 | } |
| 9383 | else |
| 9384 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 9385 | scanRequest.skipDfsChnlInP2pSearch = 0; |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 9386 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9387 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 9388 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9389 | } |
| 9390 | } |
| 9391 | |
| 9392 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 9393 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 9394 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 9395 | * address the following issues. |
| 9396 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 9397 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 9398 | * for long time, this result in apps running at full power for long time. |
| 9399 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 9400 | * be stuck in full power because of resume BMPS |
| 9401 | */ |
| 9402 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9403 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9404 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 9405 | "requestType %d, scanType %d, minChnTime %d, maxChnTime %d," |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 9406 | "p2pSearch %d, skipDfsChnlInP2pSearch %d", |
| 9407 | scanRequest.requestType, scanRequest.scanType, |
| 9408 | scanRequest.minChnTime, scanRequest.maxChnTime, |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9409 | scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch); |
| 9410 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9411 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9412 | pAdapter->sessionId, &scanRequest, &scanId, |
| 9413 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9414 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9415 | if (eHAL_STATUS_SUCCESS != status) |
| 9416 | { |
| 9417 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9418 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 9419 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 9420 | if(eHAL_STATUS_RESOURCES == status) |
| 9421 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 9422 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress." |
| 9423 | "So defer the scan by informing busy",__func__); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 9424 | status = -EBUSY; |
| 9425 | } else { |
| 9426 | status = -EIO; |
| 9427 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 9428 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9429 | goto free_mem; |
| 9430 | } |
| 9431 | |
| 9432 | pScanInfo->mScanPending = TRUE; |
| 9433 | pAdapter->request = request; |
| 9434 | pScanInfo->scanId = scanId; |
| 9435 | |
| 9436 | complete(&pScanInfo->scan_req_completion_event); |
| 9437 | |
| 9438 | free_mem: |
| 9439 | if( scanRequest.SSIDs.SSIDList ) |
| 9440 | { |
| 9441 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 9442 | } |
| 9443 | |
| 9444 | if( channelList ) |
| 9445 | vos_mem_free( channelList ); |
| 9446 | |
| 9447 | EXIT(); |
| 9448 | |
| 9449 | return status; |
| 9450 | } |
| 9451 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 9452 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 9453 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 9454 | struct net_device *dev, |
| 9455 | #endif |
| 9456 | struct cfg80211_scan_request *request) |
| 9457 | { |
| 9458 | int ret; |
| 9459 | |
| 9460 | vos_ssr_protect(__func__); |
| 9461 | ret = __wlan_hdd_cfg80211_scan(wiphy, |
| 9462 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 9463 | dev, |
| 9464 | #endif |
| 9465 | request); |
| 9466 | vos_ssr_unprotect(__func__); |
| 9467 | |
| 9468 | return ret; |
| 9469 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 9470 | |
| 9471 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 9472 | { |
| 9473 | v_U8_t iniDot11Mode = |
| 9474 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 9475 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 9476 | |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 9477 | hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"), |
| 9478 | iniDot11Mode); |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 9479 | switch ( iniDot11Mode ) |
| 9480 | { |
| 9481 | case eHDD_DOT11_MODE_AUTO: |
| 9482 | case eHDD_DOT11_MODE_11ac: |
| 9483 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 9484 | #ifdef WLAN_FEATURE_11AC |
Abhishek Singh | 4b1d235 | 2014-08-01 21:59:28 +0530 | [diff] [blame] | 9485 | if ( sme_IsFeatureSupportedByDriver(DOT11AC) && |
| 9486 | sme_IsFeatureSupportedByFW(DOT11AC) ) |
| 9487 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 9488 | else |
| 9489 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 9490 | #else |
| 9491 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 9492 | #endif |
| 9493 | break; |
| 9494 | case eHDD_DOT11_MODE_11n: |
| 9495 | case eHDD_DOT11_MODE_11n_ONLY: |
| 9496 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 9497 | break; |
| 9498 | default: |
| 9499 | hddDot11Mode = iniDot11Mode; |
| 9500 | break; |
| 9501 | } |
| 9502 | /* This call decides required channel bonding mode */ |
| 9503 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 9504 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 9505 | operationChannel); |
| 9506 | } |
| 9507 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9508 | /* |
| 9509 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9510 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9511 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9512 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9513 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9514 | { |
| 9515 | int status = 0; |
| 9516 | hdd_wext_state_t *pWextState; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 9517 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9518 | v_U32_t roamId; |
| 9519 | tCsrRoamProfile *pRoamProfile; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9520 | eCsrAuthType RSNAuthType; |
| 9521 | |
| 9522 | ENTER(); |
| 9523 | |
| 9524 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 9525 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9526 | |
| 9527 | status = wlan_hdd_validate_context(pHddCtx); |
| 9528 | if (status) |
| 9529 | { |
| 9530 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9531 | "%s: HDD context is not valid!", __func__); |
| 9532 | return status; |
| 9533 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9534 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9535 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 9536 | { |
| 9537 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 9538 | return -EINVAL; |
| 9539 | } |
| 9540 | |
| 9541 | pRoamProfile = &pWextState->roamProfile; |
| 9542 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9543 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9544 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9545 | hdd_station_ctx_t *pHddStaCtx; |
| 9546 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9547 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9548 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9549 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 9550 | { |
| 9551 | /*QoS not enabled in cfg file*/ |
| 9552 | pRoamProfile->uapsd_mask = 0; |
| 9553 | } |
| 9554 | else |
| 9555 | { |
| 9556 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9557 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9558 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 9559 | } |
| 9560 | |
| 9561 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 9562 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 9563 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9564 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9565 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 9566 | ssid, ssid_len); |
| 9567 | |
| 9568 | if (bssid) |
| 9569 | { |
| 9570 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 9571 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 9572 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9573 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 9574 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9575 | case of join failure we should send valid BSSID to supplicant |
| 9576 | */ |
| 9577 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 9578 | WNI_CFG_BSSID_LEN); |
| 9579 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 9580 | else |
| 9581 | { |
| 9582 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 9583 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9584 | |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 9585 | hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"), |
| 9586 | pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9587 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 9588 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9589 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9590 | /*set gen ie*/ |
| 9591 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 9592 | /*set auth*/ |
| 9593 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 9594 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9595 | #ifdef FEATURE_WLAN_WAPI |
| 9596 | if (pAdapter->wapi_info.nWapiMode) |
| 9597 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9598 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9599 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 9600 | { |
| 9601 | case WAPI_AUTH_MODE_PSK: |
| 9602 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9603 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9604 | pAdapter->wapi_info.wapiAuthMode); |
| 9605 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 9606 | break; |
| 9607 | } |
| 9608 | case WAPI_AUTH_MODE_CERT: |
| 9609 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9610 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9611 | pAdapter->wapi_info.wapiAuthMode); |
| 9612 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 9613 | break; |
| 9614 | } |
| 9615 | } // End of switch |
| 9616 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 9617 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 9618 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9619 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9620 | pRoamProfile->AuthType.numEntries = 1; |
| 9621 | pRoamProfile->EncryptionType.numEntries = 1; |
| 9622 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 9623 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 9624 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 9625 | } |
| 9626 | } |
| 9627 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9628 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9629 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9630 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 9631 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 9632 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9633 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 9634 | sizeof (tSirGtkOffloadParams)); |
| 9635 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9636 | } |
| 9637 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9638 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 9639 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9640 | if( operatingChannel ) |
| 9641 | { |
| 9642 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 9643 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 9644 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 9645 | else |
| 9646 | { |
| 9647 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 9648 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 9649 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 9650 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 9651 | { |
| 9652 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 9653 | } |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 9654 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 9655 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 9656 | * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9657 | * If direct path, conn_state will be accordingly changed to NotConnected or Associated |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 9658 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 9659 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 9660 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 9661 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 9662 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 9663 | { |
| 9664 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9665 | "%s: Set HDD connState to eConnectionState_Connecting", |
| 9666 | __func__); |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 9667 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 9668 | eConnectionState_Connecting); |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 9669 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9670 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9671 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 9672 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 9673 | if ((eHAL_STATUS_SUCCESS != status) && |
| 9674 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 9675 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 9676 | |
| 9677 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 9678 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 9679 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 9680 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 9681 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 9682 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 9683 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 9684 | |
| 9685 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 9686 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 9687 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9688 | } |
| 9689 | else |
| 9690 | { |
| 9691 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 9692 | return -EINVAL; |
| 9693 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 9694 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9695 | return status; |
| 9696 | } |
| 9697 | |
| 9698 | /* |
| 9699 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 9700 | * This function is used to set the authentication type (OPEN/SHARED). |
| 9701 | * |
| 9702 | */ |
| 9703 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 9704 | enum nl80211_auth_type auth_type) |
| 9705 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9706 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9707 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9708 | |
| 9709 | ENTER(); |
| 9710 | |
| 9711 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9712 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9713 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9714 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 9715 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9716 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 9717 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 9718 | break; |
| 9719 | |
| 9720 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9721 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 9722 | case NL80211_AUTHTYPE_FT: |
| 9723 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9724 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9725 | "%s: set authentication type to OPEN", __func__); |
| 9726 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 9727 | break; |
| 9728 | |
| 9729 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9730 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9731 | "%s: set authentication type to SHARED", __func__); |
| 9732 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 9733 | break; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 9734 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9735 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9736 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9737 | "%s: set authentication type to CCKM WPA", __func__); |
| 9738 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 9739 | break; |
| 9740 | #endif |
| 9741 | |
| 9742 | |
| 9743 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9744 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9745 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9746 | auth_type); |
| 9747 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 9748 | return -EINVAL; |
| 9749 | } |
| 9750 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9751 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9752 | pHddStaCtx->conn_info.authType; |
| 9753 | return 0; |
| 9754 | } |
| 9755 | |
| 9756 | /* |
| 9757 | * FUNCTION: wlan_hdd_set_akm_suite |
| 9758 | * This function is used to set the key mgmt type(PSK/8021x). |
| 9759 | * |
| 9760 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9761 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9762 | u32 key_mgmt |
| 9763 | ) |
| 9764 | { |
| 9765 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9766 | ENTER(); |
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 | /*set key mgmt type*/ |
| 9769 | switch(key_mgmt) |
| 9770 | { |
| 9771 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 9772 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 9773 | case WLAN_AKM_SUITE_FT_PSK: |
| 9774 | #endif |
| 9775 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9776 | __func__); |
| 9777 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 9778 | break; |
| 9779 | |
| 9780 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 9781 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 9782 | case WLAN_AKM_SUITE_FT_8021X: |
| 9783 | #endif |
| 9784 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9785 | __func__); |
| 9786 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 9787 | break; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 9788 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9789 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 9790 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 9791 | case WLAN_AKM_SUITE_CCKM: |
| 9792 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 9793 | __func__); |
| 9794 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 9795 | break; |
| 9796 | #endif |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 9797 | #ifndef WLAN_AKM_SUITE_OSEN |
| 9798 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 9799 | case WLAN_AKM_SUITE_OSEN: |
| 9800 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN", |
| 9801 | __func__); |
| 9802 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 9803 | break; |
| 9804 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9805 | |
| 9806 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9807 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9808 | __func__, key_mgmt); |
| 9809 | return -EINVAL; |
| 9810 | |
| 9811 | } |
| 9812 | return 0; |
| 9813 | } |
| 9814 | |
| 9815 | /* |
| 9816 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9817 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9818 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 9819 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9820 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 9821 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9822 | bool ucast |
| 9823 | ) |
| 9824 | { |
| 9825 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9826 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9827 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9828 | |
| 9829 | ENTER(); |
| 9830 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9831 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9832 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9833 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9834 | __func__, cipher); |
| 9835 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 9836 | } |
| 9837 | else |
| 9838 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9840 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9841 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9842 | { |
| 9843 | case IW_AUTH_CIPHER_NONE: |
| 9844 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 9845 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9846 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9847 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 9848 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9849 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9850 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9851 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 9852 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9853 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9854 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9855 | case WLAN_CIPHER_SUITE_TKIP: |
| 9856 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 9857 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9858 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9859 | case WLAN_CIPHER_SUITE_CCMP: |
| 9860 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 9861 | break; |
| 9862 | #ifdef FEATURE_WLAN_WAPI |
| 9863 | case WLAN_CIPHER_SUITE_SMS4: |
| 9864 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 9865 | break; |
| 9866 | #endif |
| 9867 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 9868 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9869 | case WLAN_CIPHER_SUITE_KRK: |
| 9870 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 9871 | break; |
| 9872 | #endif |
| 9873 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9874 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9875 | __func__, cipher); |
| 9876 | return -EOPNOTSUPP; |
| 9877 | } |
| 9878 | } |
| 9879 | |
| 9880 | if (ucast) |
| 9881 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9882 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9883 | __func__, encryptionType); |
| 9884 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 9885 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9886 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9887 | encryptionType; |
| 9888 | } |
| 9889 | else |
| 9890 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9891 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9892 | __func__, encryptionType); |
| 9893 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 9894 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 9895 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 9896 | } |
| 9897 | |
| 9898 | return 0; |
| 9899 | } |
| 9900 | |
| 9901 | |
| 9902 | /* |
| 9903 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 9904 | * This function is used to parse WPA/RSN IE's. |
| 9905 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9906 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 9907 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9908 | size_t ie_len |
| 9909 | ) |
| 9910 | { |
| 9911 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9912 | u8 *genie = ie; |
| 9913 | v_U16_t remLen = ie_len; |
| 9914 | #ifdef FEATURE_WLAN_WAPI |
| 9915 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 9916 | u16 *tmp; |
| 9917 | v_U16_t akmsuiteCount; |
| 9918 | int *akmlist; |
| 9919 | #endif |
| 9920 | ENTER(); |
| 9921 | |
| 9922 | /* clear previous assocAddIE */ |
| 9923 | pWextState->assocAddIE.length = 0; |
| 9924 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 9925 | pWextState->roamProfile.bOSENAssociation = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9926 | |
| 9927 | while (remLen >= 2) |
| 9928 | { |
| 9929 | v_U16_t eLen = 0; |
| 9930 | v_U8_t elementId; |
| 9931 | elementId = *genie++; |
| 9932 | eLen = *genie++; |
| 9933 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9934 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9935 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9936 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9937 | |
| 9938 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9939 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9940 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 9941 | 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] | 9942 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9943 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9944 | "%s: Invalid WPA IE", __func__); |
| 9945 | return -EINVAL; |
| 9946 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9947 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9948 | { |
| 9949 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9950 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9951 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9953 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 9954 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 9955 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 9956 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9957 | VOS_ASSERT(0); |
| 9958 | return -ENOMEM; |
| 9959 | } |
| 9960 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 9961 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 9962 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9963 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9964 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 9965 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 9966 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 9967 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9968 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 9969 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9970 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 9971 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 9972 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 9973 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 9974 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 9975 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9976 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
Kiet Lam | 8da9899 | 2013-11-21 15:59:07 +0530 | [diff] [blame] | 9977 | P2P_OUI_TYPE_SIZE))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9978 | { |
| 9979 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9980 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9981 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9982 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9983 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 9984 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 9985 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 9986 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9987 | VOS_ASSERT(0); |
| 9988 | return -ENOMEM; |
| 9989 | } |
| 9990 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 9991 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 9992 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9993 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9994 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 9995 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 9996 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9997 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9998 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 9999 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10000 | /*Consider WFD IE, only for P2P Client */ |
| 10001 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 10002 | { |
| 10003 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10004 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10005 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10006 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10007 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 10008 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 10009 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 10010 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10011 | VOS_ASSERT(0); |
| 10012 | return -ENOMEM; |
| 10013 | } |
| 10014 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 10015 | // WPS IE + P2P IE + WFD IE |
| 10016 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 10017 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10018 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10019 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 10020 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 10021 | } |
| 10022 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10023 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10024 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 10025 | HS20_OUI_TYPE_SIZE)) ) |
| 10026 | { |
| 10027 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10028 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 10029 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10030 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 10031 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 10032 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 10033 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 10034 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 10035 | VOS_ASSERT(0); |
| 10036 | return -ENOMEM; |
| 10037 | } |
| 10038 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 10039 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10040 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 10041 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 10042 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 10043 | } |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 10044 | /* Appending OSEN Information Element in Assiciation Request */ |
| 10045 | else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 10046 | OSEN_OUI_TYPE_SIZE)) ) |
| 10047 | { |
| 10048 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
| 10049 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)", |
| 10050 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10051 | |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 10052 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 10053 | { |
| 10054 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 10055 | "Need bigger buffer space"); |
| 10056 | VOS_ASSERT(0); |
| 10057 | return -ENOMEM; |
| 10058 | } |
| 10059 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 10060 | pWextState->assocAddIE.length += eLen + 2; |
| 10061 | |
| 10062 | pWextState->roamProfile.bOSENAssociation = VOS_TRUE; |
| 10063 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 10064 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 10065 | } |
| 10066 | |
| 10067 | break; |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 10068 | if (WLAN_HDD_IBSS == pAdapter->device_mode) { |
| 10069 | |
| 10070 | /* populating as ADDIE in beacon frames */ |
| 10071 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10072 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2, |
| 10073 | NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS) |
| 10074 | { |
| 10075 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10076 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 10077 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 10078 | { |
| 10079 | hddLog(LOGE, |
| 10080 | "Coldn't pass " |
| 10081 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
| 10082 | } |
| 10083 | }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/ |
| 10084 | else |
| 10085 | hddLog(LOGE, |
| 10086 | "Could not pass on " |
| 10087 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
| 10088 | |
| 10089 | /* IBSS mode doesn't contain params->proberesp_ies still |
| 10090 | beaconIE's need to be populated in probe response frames */ |
| 10091 | if ( (NULL != (genie - 2)) && (0 != eLen + 2) ) |
| 10092 | { |
| 10093 | u16 rem_probe_resp_ie_len = eLen + 2; |
| 10094 | u8 probe_rsp_ie_len[3] = {0}; |
| 10095 | u8 counter = 0; |
| 10096 | |
| 10097 | /* Check Probe Resp Length if it is greater then 255 then |
| 10098 | Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 |
| 10099 | & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are |
| 10100 | not able Store More then 255 bytes into One Variable */ |
| 10101 | |
| 10102 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 10103 | { |
| 10104 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 10105 | { |
| 10106 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 10107 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 10108 | } |
| 10109 | else |
| 10110 | { |
| 10111 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 10112 | rem_probe_resp_ie_len = 0; |
| 10113 | } |
| 10114 | } |
| 10115 | |
| 10116 | rem_probe_resp_ie_len = 0; |
| 10117 | |
| 10118 | if (probe_rsp_ie_len[0] > 0) |
| 10119 | { |
| 10120 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10121 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 10122 | (tANI_U8*)(genie - 2), |
| 10123 | probe_rsp_ie_len[0], NULL, |
| 10124 | eANI_BOOLEAN_FALSE) |
| 10125 | == eHAL_STATUS_FAILURE) |
| 10126 | { |
| 10127 | hddLog(LOGE, |
| 10128 | "Could not pass" |
| 10129 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
| 10130 | } |
| 10131 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 10132 | } |
| 10133 | |
| 10134 | if (probe_rsp_ie_len[1] > 0) |
| 10135 | { |
| 10136 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10137 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 10138 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 10139 | probe_rsp_ie_len[1], NULL, |
| 10140 | eANI_BOOLEAN_FALSE) |
| 10141 | == eHAL_STATUS_FAILURE) |
| 10142 | { |
| 10143 | hddLog(LOGE, |
| 10144 | "Could not pass" |
| 10145 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
| 10146 | } |
| 10147 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 10148 | } |
| 10149 | |
| 10150 | if (probe_rsp_ie_len[2] > 0) |
| 10151 | { |
| 10152 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10153 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 10154 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 10155 | probe_rsp_ie_len[2], NULL, |
| 10156 | eANI_BOOLEAN_FALSE) |
| 10157 | == eHAL_STATUS_FAILURE) |
| 10158 | { |
| 10159 | hddLog(LOGE, |
| 10160 | "Could not pass" |
| 10161 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
| 10162 | } |
| 10163 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 10164 | } |
| 10165 | |
| 10166 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10167 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 10168 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 10169 | { |
| 10170 | hddLog(LOGE, |
| 10171 | "Could not pass" |
| 10172 | "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
| 10173 | } |
| 10174 | } |
| 10175 | else |
| 10176 | { |
| 10177 | // Reset WNI_CFG_PROBE_RSP Flags |
| 10178 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 10179 | |
| 10180 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10181 | "%s: No Probe Response IE received in set beacon", |
| 10182 | __func__); |
| 10183 | } |
| 10184 | } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10185 | break; |
| 10186 | case DOT11F_EID_RSN: |
| 10187 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 10188 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 10189 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 10190 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 10191 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 10192 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10193 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 10194 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10195 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10196 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10197 | 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] | 10198 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10199 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10200 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 10201 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 10202 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 10203 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10204 | VOS_ASSERT(0); |
| 10205 | return -ENOMEM; |
| 10206 | } |
| 10207 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 10208 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10209 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10210 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 10211 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 10212 | break; |
| 10213 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10214 | #ifdef FEATURE_WLAN_WAPI |
| 10215 | case WLAN_EID_WAPI: |
| 10216 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 10217 | hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10218 | pAdapter->wapi_info.nWapiMode); |
| 10219 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10220 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10221 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 10222 | tmp = tmp + 1; |
| 10223 | akmlist = (int *)(tmp); |
| 10224 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 10225 | { |
| 10226 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 10227 | } |
| 10228 | else |
| 10229 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10230 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10231 | VOS_ASSERT(0); |
| 10232 | return -EINVAL; |
| 10233 | } |
| 10234 | |
| 10235 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 10236 | { |
| 10237 | 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] | 10238 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10239 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10240 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10241 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10242 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10243 | 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] | 10244 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10245 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 10246 | } |
| 10247 | break; |
| 10248 | #endif |
| 10249 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10250 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10251 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 10252 | /* when Unknown IE is received we should break and continue |
| 10253 | * to the next IE in the buffer instead we were returning |
| 10254 | * so changing this to break */ |
| 10255 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10256 | } |
| 10257 | genie += eLen; |
| 10258 | remLen -= eLen; |
| 10259 | } |
| 10260 | EXIT(); |
| 10261 | return 0; |
| 10262 | } |
| 10263 | |
| 10264 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 10265 | * FUNCTION: hdd_isWPAIEPresent |
| 10266 | * Parse the received IE to find the WPA IE |
| 10267 | * |
| 10268 | */ |
| 10269 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 10270 | { |
| 10271 | v_U8_t eLen = 0; |
| 10272 | v_U16_t remLen = ie_len; |
| 10273 | v_U8_t elementId = 0; |
| 10274 | |
| 10275 | while (remLen >= 2) |
| 10276 | { |
| 10277 | elementId = *ie++; |
| 10278 | eLen = *ie++; |
| 10279 | remLen -= 2; |
| 10280 | if (eLen > remLen) |
| 10281 | { |
| 10282 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10283 | "%s: IE length is wrong %d", __func__, eLen); |
| 10284 | return FALSE; |
| 10285 | } |
| 10286 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 10287 | { |
| 10288 | /* OUI - 0x00 0X50 0XF2 |
| 10289 | WPA Information Element - 0x01 |
| 10290 | WPA version - 0x01*/ |
| 10291 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 10292 | return TRUE; |
| 10293 | } |
| 10294 | ie += eLen; |
| 10295 | remLen -= eLen; |
| 10296 | } |
| 10297 | return FALSE; |
| 10298 | } |
| 10299 | |
| 10300 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10301 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10302 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10303 | * parameters during connect operation. |
| 10304 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10305 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10306 | struct cfg80211_connect_params *req |
| 10307 | ) |
| 10308 | { |
| 10309 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10310 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10311 | ENTER(); |
| 10312 | |
| 10313 | /*set wpa version*/ |
| 10314 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 10315 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10316 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10317 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 10318 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10319 | { |
| 10320 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 10321 | } |
| 10322 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 10323 | { |
| 10324 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 10325 | } |
| 10326 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10327 | |
| 10328 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10329 | pWextState->wpaVersion); |
| 10330 | |
| 10331 | /*set authentication type*/ |
| 10332 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 10333 | |
| 10334 | if (0 > status) |
| 10335 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10336 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10337 | "%s: failed to set authentication type ", __func__); |
| 10338 | return status; |
| 10339 | } |
| 10340 | |
| 10341 | /*set key mgmt type*/ |
| 10342 | if (req->crypto.n_akm_suites) |
| 10343 | { |
| 10344 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 10345 | if (0 > status) |
| 10346 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10347 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10348 | __func__); |
| 10349 | return status; |
| 10350 | } |
| 10351 | } |
| 10352 | |
| 10353 | /*set pairwise cipher type*/ |
| 10354 | if (req->crypto.n_ciphers_pairwise) |
| 10355 | { |
| 10356 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 10357 | req->crypto.ciphers_pairwise[0], true); |
| 10358 | if (0 > status) |
| 10359 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10360 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10361 | "%s: failed to set unicast cipher type", __func__); |
| 10362 | return status; |
| 10363 | } |
| 10364 | } |
| 10365 | else |
| 10366 | { |
| 10367 | /*Reset previous cipher suite to none*/ |
| 10368 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 10369 | if (0 > status) |
| 10370 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10371 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10372 | "%s: failed to set unicast cipher type", __func__); |
| 10373 | return status; |
| 10374 | } |
| 10375 | } |
| 10376 | |
| 10377 | /*set group cipher type*/ |
| 10378 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 10379 | false); |
| 10380 | |
| 10381 | if (0 > status) |
| 10382 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10383 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10384 | __func__); |
| 10385 | return status; |
| 10386 | } |
| 10387 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 10388 | #ifdef WLAN_FEATURE_11W |
| 10389 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 10390 | #endif |
| 10391 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10392 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 10393 | if (req->ie_len) |
| 10394 | { |
| 10395 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 10396 | if ( 0 > status) |
| 10397 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10398 | 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] | 10399 | __func__); |
| 10400 | return status; |
| 10401 | } |
| 10402 | } |
| 10403 | |
| 10404 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10405 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10406 | { |
| 10407 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 10408 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 10409 | ) |
| 10410 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10411 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10412 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 10413 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10414 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10415 | __func__); |
| 10416 | return -EOPNOTSUPP; |
| 10417 | } |
| 10418 | else |
| 10419 | { |
| 10420 | u8 key_len = req->key_len; |
| 10421 | u8 key_idx = req->key_idx; |
| 10422 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10423 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10424 | && (CSR_MAX_NUM_KEY > key_idx) |
| 10425 | ) |
| 10426 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10427 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10428 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10429 | __func__, key_idx, key_len); |
| 10430 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10431 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10432 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10433 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10434 | (u8)key_len; |
| 10435 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 10436 | } |
| 10437 | } |
| 10438 | } |
| 10439 | } |
| 10440 | |
| 10441 | return status; |
| 10442 | } |
| 10443 | |
| 10444 | /* |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 10445 | * FUNCTION: wlan_hdd_try_disconnect |
| 10446 | * This function is used to disconnect from previous |
| 10447 | * connection |
| 10448 | */ |
| 10449 | static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter ) |
| 10450 | { |
| 10451 | long ret = 0; |
| 10452 | hdd_station_ctx_t *pHddStaCtx; |
| 10453 | eMib_dot11DesiredBssType connectedBssType; |
| 10454 | |
| 10455 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10456 | |
| 10457 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 10458 | |
| 10459 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 10460 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 10461 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
| 10462 | { |
| 10463 | /* Issue disconnect to CSR */ |
| 10464 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 10465 | if( eHAL_STATUS_SUCCESS == |
| 10466 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10467 | pAdapter->sessionId, |
| 10468 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 10469 | { |
| 10470 | ret = wait_for_completion_interruptible_timeout( |
| 10471 | &pAdapter->disconnect_comp_var, |
| 10472 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 10473 | if (0 >= ret) |
| 10474 | { |
| 10475 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 10476 | return -EALREADY; |
| 10477 | } |
| 10478 | } |
| 10479 | } |
| 10480 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 10481 | { |
| 10482 | ret = wait_for_completion_interruptible_timeout( |
| 10483 | &pAdapter->disconnect_comp_var, |
| 10484 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 10485 | if (0 >= ret) |
| 10486 | { |
| 10487 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 10488 | return -EALREADY; |
| 10489 | } |
| 10490 | } |
| 10491 | |
| 10492 | return 0; |
| 10493 | } |
| 10494 | |
| 10495 | /* |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10496 | * FUNCTION: __wlan_hdd_cfg80211_connect |
| 10497 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10498 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 10499 | static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10500 | struct net_device *ndev, |
| 10501 | struct cfg80211_connect_params *req |
| 10502 | ) |
| 10503 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10504 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10505 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10506 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
Sushant Kaushik | ba6764e | 2014-06-30 19:52:09 +0530 | [diff] [blame] | 10507 | hdd_context_t *pHddCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10508 | |
| 10509 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10510 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10511 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10512 | TRACE_CODE_HDD_CFG80211_CONNECT, |
| 10513 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10514 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10515 | "%s: device_mode = %s (%d)", __func__, |
| 10516 | hdd_device_modetoString(pAdapter->device_mode), |
| 10517 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10518 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10519 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 10520 | if (!pHddCtx) |
| 10521 | { |
| 10522 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10523 | "%s: HDD context is null", __func__); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10524 | return -EINVAL; |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 10525 | } |
| 10526 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10527 | status = wlan_hdd_validate_context(pHddCtx); |
| 10528 | |
| 10529 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10530 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10531 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10532 | "%s: HDD context is not valid", __func__); |
| 10533 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10534 | } |
| 10535 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10536 | if (vos_max_concurrent_connections_reached()) { |
| 10537 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 10538 | return -ECONNREFUSED; |
| 10539 | } |
| 10540 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10541 | #ifdef WLAN_BTAMP_FEATURE |
| 10542 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10543 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10544 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10545 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10546 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 10547 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10548 | } |
| 10549 | #endif |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 10550 | |
| 10551 | //If Device Mode is Station Concurrent Sessions Exit BMps |
| 10552 | //P2P Mode will be taken care in Open/close adapter |
| 10553 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10554 | (vos_concurrent_open_sessions_running())) { |
| 10555 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, |
| 10556 | WLAN_HDD_INFRA_STATION); |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 10557 | } |
| 10558 | |
| 10559 | /*Try disconnecting if already in connected state*/ |
| 10560 | status = wlan_hdd_try_disconnect(pAdapter); |
| 10561 | if ( 0 > status) |
| 10562 | { |
| 10563 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 10564 | " connection")); |
| 10565 | return -EALREADY; |
| 10566 | } |
| 10567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10568 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10569 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10570 | |
| 10571 | if ( 0 > status) |
| 10572 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10573 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10574 | __func__); |
| 10575 | return status; |
| 10576 | } |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 10577 | if ( req->channel ) |
| 10578 | { |
| 10579 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 10580 | req->ssid_len, req->bssid, |
| 10581 | req->channel->hw_value); |
| 10582 | } |
| 10583 | else |
| 10584 | { |
| 10585 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10586 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 10587 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10588 | |
| 10589 | if (0 > status) |
| 10590 | { |
| 10591 | //ReEnable BMPS if disabled |
| 10592 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 10593 | (NULL != pHddCtx)) |
| 10594 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10595 | if (pHddCtx->hdd_wlan_suspended) |
| 10596 | { |
| 10597 | hdd_set_pwrparams(pHddCtx); |
| 10598 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10599 | //ReEnable Bmps and Imps back |
| 10600 | hdd_enable_bmps_imps(pHddCtx); |
| 10601 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10602 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10603 | return status; |
| 10604 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10605 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10606 | EXIT(); |
| 10607 | return status; |
| 10608 | } |
| 10609 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 10610 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
| 10611 | struct net_device *ndev, |
| 10612 | struct cfg80211_connect_params *req) |
| 10613 | { |
| 10614 | int ret; |
| 10615 | vos_ssr_protect(__func__); |
| 10616 | ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
| 10617 | vos_ssr_unprotect(__func__); |
| 10618 | |
| 10619 | return ret; |
| 10620 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10621 | |
| 10622 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10623 | * FUNCTION: wlan_hdd_disconnect |
| 10624 | * This function is used to issue a disconnect request to SME |
| 10625 | */ |
| 10626 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 10627 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10628 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10629 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10630 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10631 | long ret; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10632 | |
| 10633 | status = wlan_hdd_validate_context(pHddCtx); |
| 10634 | |
| 10635 | if (0 != status) |
| 10636 | { |
| 10637 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10638 | "%s: HDD context is not valid", __func__); |
| 10639 | return status; |
| 10640 | } |
| 10641 | |
| 10642 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 10643 | |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 10644 | /* Need to apply spin lock before decreasing active sessions |
| 10645 | * as there can be chance for double decrement if context switch |
| 10646 | * Calls hdd_DisConnectHandler. |
| 10647 | */ |
| 10648 | |
| 10649 | spin_lock_bh(&pAdapter->lock_for_active_session); |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 10650 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 10651 | { |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 10652 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 10653 | } |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 10654 | hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting ); |
| 10655 | spin_unlock_bh(&pAdapter->lock_for_active_session); |
Agarwal Ashish | c65b5ca | 2014-07-28 21:02:57 +0530 | [diff] [blame] | 10656 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 10657 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 10658 | FL( "Set HDD connState to eConnectionState_Disconnecting" )); |
| 10659 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10660 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10661 | |
Mihir Shete | 182a0b2 | 2014-08-18 16:08:48 +0530 | [diff] [blame] | 10662 | /* |
| 10663 | * stop tx queues before deleting STA/BSS context from the firmware. |
| 10664 | * tx has to be disabled because the firmware can get busy dropping |
| 10665 | * the tx frames after BSS/STA has been deleted and will not send |
| 10666 | * back a response resulting in WDI timeout |
| 10667 | */ |
| 10668 | netif_tx_disable(pAdapter->dev); |
| 10669 | netif_carrier_off(pAdapter->dev); |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 10670 | |
Mihir Shete | 182a0b2 | 2014-08-18 16:08:48 +0530 | [diff] [blame] | 10671 | /*issue disconnect*/ |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10672 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10673 | pAdapter->sessionId, reason); |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10674 | if(eHAL_STATUS_CMD_NOT_QUEUED == status) |
| 10675 | { |
| 10676 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10677 | FL("status = %d, already disconnected"), |
| 10678 | (int)status ); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10679 | |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10680 | } |
| 10681 | else if ( 0 != status ) |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10682 | { |
| 10683 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10684 | "%s csrRoamDisconnect failure, returned %d", |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10685 | __func__, (int)status ); |
| 10686 | return -EINVAL; |
| 10687 | } |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10688 | ret = wait_for_completion_interruptible_timeout( |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10689 | &pAdapter->disconnect_comp_var, |
| 10690 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10691 | if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status )) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10692 | { |
| 10693 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 10694 | "%s: Failed to disconnect, timed out", __func__); |
| 10695 | return -ETIMEDOUT; |
| 10696 | } |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10697 | else if (ret == -ERESTARTSYS) |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 10698 | { |
| 10699 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10700 | "%s: Failed to disconnect, wait interrupted", __func__); |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10701 | return ret; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10702 | } |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 10703 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10704 | FL("Set HDD connState to eConnectionState_NotConnected")); |
| 10705 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 10706 | |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 10707 | return 0; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10708 | } |
| 10709 | |
| 10710 | |
| 10711 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 10712 | * FUNCTION: __wlan_hdd_cfg80211_disconnect |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10713 | * This function is used to issue a disconnect request to SME |
| 10714 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 10715 | static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10716 | struct net_device *dev, |
| 10717 | u16 reason |
| 10718 | ) |
| 10719 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10720 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10721 | tCsrRoamProfile *pRoamProfile = |
| 10722 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10723 | int status; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10724 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10725 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 10726 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 10727 | tANI_U8 staIdx; |
| 10728 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10729 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10730 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10731 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10732 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10733 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
| 10734 | pAdapter->sessionId, reason)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10735 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)", |
| 10736 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 10737 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10738 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10739 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 10740 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10741 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10742 | status = wlan_hdd_validate_context(pHddCtx); |
| 10743 | |
| 10744 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10745 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10746 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10747 | "%s: HDD context is not valid", __func__); |
| 10748 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10749 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10750 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10751 | if (NULL != pRoamProfile) |
| 10752 | { |
| 10753 | /*issue disconnect request to SME, if station is in connected state*/ |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 10754 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 10755 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10756 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10757 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10758 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 10759 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10760 | switch(reason) |
| 10761 | { |
| 10762 | case WLAN_REASON_MIC_FAILURE: |
| 10763 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 10764 | break; |
| 10765 | |
| 10766 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 10767 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 10768 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 10769 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 10770 | break; |
| 10771 | |
| 10772 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 10773 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
Abhishek Singh | c3269a5 | 2014-05-21 17:22:24 +0530 | [diff] [blame] | 10774 | case WLAN_REASON_DEAUTH_LEAVING: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10775 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 10776 | break; |
| 10777 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10778 | default: |
| 10779 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 10780 | break; |
| 10781 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 10782 | pScanInfo = &pHddCtx->scan_info; |
| 10783 | if (pScanInfo->mScanPending) |
| 10784 | { |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 10785 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 10786 | "Aborting Scan"); |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 10787 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 10788 | eCSR_SCAN_ABORT_DEFAULT); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 10789 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10790 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 10791 | #ifdef FEATURE_WLAN_TDLS |
| 10792 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10793 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 10794 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10795 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 10796 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 10797 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10798 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10799 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10800 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10801 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10802 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10803 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 10804 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10805 | pAdapter->sessionId, |
| 10806 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 10807 | } |
| 10808 | } |
| 10809 | #endif |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 10810 | hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10811 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 10812 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10813 | { |
| 10814 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10815 | "%s wlan_hdd_disconnect failure, returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10816 | __func__, (int)status ); |
| 10817 | return -EINVAL; |
| 10818 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10819 | } |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 10820 | else |
| 10821 | { |
| 10822 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API" |
| 10823 | "called while in %d state", __func__, |
| 10824 | pHddStaCtx->conn_info.connState); |
| 10825 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10826 | } |
| 10827 | else |
| 10828 | { |
| 10829 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 10830 | } |
| 10831 | |
| 10832 | return status; |
| 10833 | } |
| 10834 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 10835 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
| 10836 | struct net_device *dev, |
| 10837 | u16 reason |
| 10838 | ) |
| 10839 | { |
| 10840 | int ret; |
| 10841 | vos_ssr_protect(__func__); |
| 10842 | ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
| 10843 | vos_ssr_unprotect(__func__); |
| 10844 | |
| 10845 | return ret; |
| 10846 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 10847 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10848 | /* |
| 10849 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10850 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10851 | * settings in IBSS mode. |
| 10852 | */ |
| 10853 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10854 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10855 | struct cfg80211_ibss_params *params |
| 10856 | ) |
| 10857 | { |
| 10858 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10859 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10860 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 10861 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10862 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10863 | ENTER(); |
| 10864 | |
| 10865 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Ravi Joshi | b58ca0d | 2013-10-29 09:50:23 -0700 | [diff] [blame] | 10866 | vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10867 | |
| 10868 | if (params->ie_len && ( NULL != params->ie) ) |
| 10869 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 10870 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 10871 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10872 | { |
| 10873 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 10874 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 10875 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 10876 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10877 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 10878 | tDot11fIEWPA dot11WPAIE; |
| 10879 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 10880 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 10881 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 10882 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 10883 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 10884 | params->ie_len, DOT11F_EID_WPA); |
| 10885 | if ( NULL != ie ) |
| 10886 | { |
| 10887 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 10888 | // Unpack the WPA IE |
| 10889 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 10890 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 10891 | &ie[2+4], |
| 10892 | ie[1] - 4, |
| 10893 | &dot11WPAIE); |
| 10894 | /*Extract the multicast cipher, the encType for unicast |
| 10895 | cipher for wpa-none is none*/ |
| 10896 | encryptionType = |
| 10897 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 10898 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10899 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 10900 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10901 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 10902 | |
| 10903 | if (0 > status) |
| 10904 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10905 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10906 | __func__); |
| 10907 | return status; |
| 10908 | } |
| 10909 | } |
| 10910 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10911 | pWextState->roamProfile.AuthType.authType[0] = |
| 10912 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10913 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 10914 | |
| 10915 | if (params->privacy) |
| 10916 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10917 | /* Security enabled IBSS, At this time there is no information available |
| 10918 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10919 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10920 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10921 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10922 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10923 | *enable privacy bit in beacons */ |
| 10924 | |
| 10925 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 10926 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 10927 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 10928 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10929 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 10930 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 10931 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10932 | return status; |
| 10933 | } |
| 10934 | |
| 10935 | /* |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 10936 | * FUNCTION: __wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10937 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10938 | */ |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 10939 | static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10940 | struct net_device *dev, |
| 10941 | struct cfg80211_ibss_params *params |
| 10942 | ) |
| 10943 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10944 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10945 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10946 | tCsrRoamProfile *pRoamProfile; |
| 10947 | int status; |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 10948 | bool alloc_bssid = VOS_FALSE; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10949 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10950 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10951 | |
| 10952 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 10953 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10954 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10955 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
| 10956 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10957 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 10958 | "%s: device_mode = %s (%d)", __func__, |
| 10959 | hdd_device_modetoString(pAdapter->device_mode), |
| 10960 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10961 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10962 | status = wlan_hdd_validate_context(pHddCtx); |
| 10963 | |
| 10964 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10965 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10967 | "%s: HDD context is not valid", __func__); |
| 10968 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10969 | } |
| 10970 | |
| 10971 | if (NULL == pWextState) |
| 10972 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10973 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10974 | __func__); |
| 10975 | return -EIO; |
| 10976 | } |
| 10977 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10978 | if (vos_max_concurrent_connections_reached()) { |
| 10979 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 10980 | return -ECONNREFUSED; |
| 10981 | } |
| 10982 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 10983 | /*Try disconnecting if already in connected state*/ |
| 10984 | status = wlan_hdd_try_disconnect(pAdapter); |
| 10985 | if ( 0 > status) |
| 10986 | { |
| 10987 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 10988 | " IBSS connection")); |
| 10989 | return -EALREADY; |
| 10990 | } |
| 10991 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10992 | pRoamProfile = &pWextState->roamProfile; |
| 10993 | |
| 10994 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 10995 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10996 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10997 | "%s Interface type is not set to IBSS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10998 | return -EINVAL; |
| 10999 | } |
| 11000 | |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 11001 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 11002 | if (NULL != params->bssid) { |
| 11003 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 11004 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) { |
| 11005 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 11006 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 11007 | return -EIO; |
| 11008 | } |
| 11009 | } |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 11010 | else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0) |
| 11011 | { |
| 11012 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 11013 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 11014 | { |
| 11015 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 11016 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 11017 | return -EIO; |
| 11018 | } |
| 11019 | params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE)); |
| 11020 | if (!params->bssid) |
| 11021 | { |
| 11022 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 11023 | "%s:Failed memory allocation", __func__); |
| 11024 | return -EIO; |
| 11025 | } |
| 11026 | vos_mem_copy((v_U8_t *)params->bssid, |
| 11027 | (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0], |
| 11028 | VOS_MAC_ADDR_SIZE); |
| 11029 | alloc_bssid = VOS_TRUE; |
| 11030 | } |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 11031 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11032 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 11033 | if (NULL != |
| 11034 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 11035 | params->chandef.chan) |
| 11036 | #else |
| 11037 | params->channel) |
| 11038 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11039 | { |
| 11040 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11041 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 11042 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 11043 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 11044 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11045 | |
| 11046 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11047 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 11048 | ieee80211_frequency_to_channel( |
| 11049 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 11050 | params->chandef.chan->center_freq); |
| 11051 | #else |
| 11052 | params->channel->center_freq); |
| 11053 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11054 | |
| 11055 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 11056 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11057 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11058 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 11059 | __func__); |
| 11060 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11061 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11062 | |
| 11063 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11064 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11065 | if (channelNum == validChan[indx]) |
| 11066 | { |
| 11067 | break; |
| 11068 | } |
| 11069 | } |
| 11070 | if (indx >= numChans) |
| 11071 | { |
| 11072 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11073 | __func__, channelNum); |
| 11074 | return -EINVAL; |
| 11075 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11076 | /* Set the Operational Channel */ |
| 11077 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 11078 | channelNum); |
| 11079 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 11080 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 11081 | pRoamProfile->ChannelInfo.ChannelList = |
| 11082 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11083 | } |
| 11084 | |
| 11085 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11086 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11087 | if (status < 0) |
| 11088 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11089 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11090 | __func__); |
| 11091 | return status; |
| 11092 | } |
| 11093 | |
| 11094 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11095 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 11096 | params->ssid_len, params->bssid, |
| 11097 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11098 | |
| 11099 | if (0 > status) |
| 11100 | { |
| 11101 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 11102 | return status; |
| 11103 | } |
| 11104 | |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 11105 | if (NULL != params->bssid && |
| 11106 | pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 && |
| 11107 | alloc_bssid == VOS_TRUE) |
| 11108 | { |
| 11109 | vos_mem_free(params->bssid); |
| 11110 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11111 | return 0; |
| 11112 | } |
| 11113 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 11114 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
| 11115 | struct net_device *dev, |
| 11116 | struct cfg80211_ibss_params *params |
| 11117 | ) |
| 11118 | { |
| 11119 | int ret = 0; |
| 11120 | |
| 11121 | vos_ssr_protect(__func__); |
| 11122 | ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params); |
| 11123 | vos_ssr_unprotect(__func__); |
| 11124 | |
| 11125 | return ret; |
| 11126 | } |
| 11127 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11128 | /* |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 11129 | * FUNCTION: __wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11130 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11131 | */ |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 11132 | static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11133 | struct net_device *dev |
| 11134 | ) |
| 11135 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11136 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11137 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11138 | tCsrRoamProfile *pRoamProfile; |
| 11139 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11140 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11141 | |
| 11142 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 11143 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11144 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11145 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
| 11146 | pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11147 | status = wlan_hdd_validate_context(pHddCtx); |
| 11148 | |
| 11149 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11150 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11151 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11152 | "%s: HDD context is not valid", __func__); |
| 11153 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11154 | } |
| 11155 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 11156 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__, |
| 11157 | hdd_device_modetoString(pAdapter->device_mode), |
| 11158 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11159 | if (NULL == pWextState) |
| 11160 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 11161 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11162 | __func__); |
| 11163 | return -EIO; |
| 11164 | } |
| 11165 | |
| 11166 | pRoamProfile = &pWextState->roamProfile; |
| 11167 | |
| 11168 | /* Issue disconnect only if interface type is set to IBSS */ |
| 11169 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 11170 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11171 | 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] | 11172 | __func__); |
| 11173 | return -EINVAL; |
| 11174 | } |
| 11175 | |
| 11176 | /* Issue Disconnect request */ |
| 11177 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 11178 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 11179 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 11180 | |
| 11181 | return 0; |
| 11182 | } |
| 11183 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 11184 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
| 11185 | struct net_device *dev |
| 11186 | ) |
| 11187 | { |
| 11188 | int ret = 0; |
| 11189 | |
| 11190 | vos_ssr_protect(__func__); |
| 11191 | ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev); |
| 11192 | vos_ssr_unprotect(__func__); |
| 11193 | |
| 11194 | return ret; |
| 11195 | } |
| 11196 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11197 | /* |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 11198 | * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11199 | * This function is used to set the phy parameters |
| 11200 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 11201 | */ |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 11202 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11203 | u32 changed) |
| 11204 | { |
| 11205 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 11206 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11207 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11208 | |
| 11209 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11210 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11211 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 11212 | NO_SESSION, wiphy->rts_threshold)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11213 | status = wlan_hdd_validate_context(pHddCtx); |
| 11214 | |
| 11215 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11216 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11217 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11218 | "%s: HDD context is not valid", __func__); |
| 11219 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11220 | } |
| 11221 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11222 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 11223 | { |
| 11224 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 11225 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 11226 | wiphy->rts_threshold; |
| 11227 | |
| 11228 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11229 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11230 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11231 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11232 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11233 | __func__, rts_threshold); |
| 11234 | return -EINVAL; |
| 11235 | } |
| 11236 | |
| 11237 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 11238 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11239 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11240 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11241 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11242 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11243 | __func__, rts_threshold); |
| 11244 | return -EIO; |
| 11245 | } |
| 11246 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11247 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11248 | rts_threshold); |
| 11249 | } |
| 11250 | |
| 11251 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 11252 | { |
| 11253 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 11254 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 11255 | wiphy->frag_threshold; |
| 11256 | |
| 11257 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11258 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11259 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11260 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11261 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11262 | frag_threshold); |
| 11263 | return -EINVAL; |
| 11264 | } |
| 11265 | |
| 11266 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 11267 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11268 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11269 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11270 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11271 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11272 | __func__, frag_threshold); |
| 11273 | return -EIO; |
| 11274 | } |
| 11275 | |
| 11276 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 11277 | frag_threshold); |
| 11278 | } |
| 11279 | |
| 11280 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 11281 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 11282 | { |
| 11283 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 11284 | wiphy->retry_short : |
| 11285 | wiphy->retry_long; |
| 11286 | |
| 11287 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 11288 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 11289 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11290 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11291 | __func__, retry_value); |
| 11292 | return -EINVAL; |
| 11293 | } |
| 11294 | |
| 11295 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 11296 | { |
| 11297 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 11298 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11299 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11300 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11301 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11302 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11303 | __func__, retry_value); |
| 11304 | return -EIO; |
| 11305 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11306 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11307 | __func__, retry_value); |
| 11308 | } |
| 11309 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 11310 | { |
| 11311 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 11312 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11313 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11314 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11315 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11316 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11317 | __func__, retry_value); |
| 11318 | return -EIO; |
| 11319 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11320 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11321 | __func__, retry_value); |
| 11322 | } |
| 11323 | } |
| 11324 | |
| 11325 | return 0; |
| 11326 | } |
| 11327 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 11328 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 11329 | u32 changed) |
| 11330 | { |
| 11331 | int ret; |
| 11332 | |
| 11333 | vos_ssr_protect(__func__); |
| 11334 | ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
| 11335 | vos_ssr_unprotect(__func__); |
| 11336 | |
| 11337 | return ret; |
| 11338 | } |
| 11339 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11340 | /* |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 11341 | * FUNCTION: __wlan_hdd_cfg80211_set_txpower |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11342 | * This function is used to set the txpower |
| 11343 | */ |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 11344 | static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 11345 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 11346 | struct wireless_dev *wdev, |
| 11347 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11348 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11349 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11350 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11351 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11352 | #endif |
| 11353 | int dbm) |
| 11354 | { |
| 11355 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11356 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11357 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 11358 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11359 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11360 | |
| 11361 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11362 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11363 | TRACE_CODE_HDD_CFG80211_SET_TXPOWER, |
| 11364 | NO_SESSION, type )); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11365 | status = wlan_hdd_validate_context(pHddCtx); |
| 11366 | |
| 11367 | if (0 != status) |
| 11368 | { |
| 11369 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11370 | "%s: HDD context is not valid", __func__); |
| 11371 | return status; |
| 11372 | } |
| 11373 | |
| 11374 | hHal = pHddCtx->hHal; |
| 11375 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11376 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 11377 | dbm, ccmCfgSetCallback, |
| 11378 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11379 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11380 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11381 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 11382 | return -EIO; |
| 11383 | } |
| 11384 | |
| 11385 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 11386 | dbm); |
| 11387 | |
| 11388 | switch(type) |
| 11389 | { |
| 11390 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 11391 | /* Fall through */ |
| 11392 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 11393 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 11394 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11395 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 11396 | __func__); |
| 11397 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11398 | } |
| 11399 | break; |
| 11400 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11401 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11402 | __func__); |
| 11403 | return -EOPNOTSUPP; |
| 11404 | break; |
| 11405 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11406 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 11407 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11408 | return -EIO; |
| 11409 | } |
| 11410 | |
| 11411 | return 0; |
| 11412 | } |
| 11413 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 11414 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 11415 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 11416 | struct wireless_dev *wdev, |
| 11417 | #endif |
| 11418 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
| 11419 | enum tx_power_setting type, |
| 11420 | #else |
| 11421 | enum nl80211_tx_power_setting type, |
| 11422 | #endif |
| 11423 | int dbm) |
| 11424 | { |
| 11425 | int ret; |
| 11426 | vos_ssr_protect(__func__); |
| 11427 | ret = __wlan_hdd_cfg80211_set_txpower(wiphy, |
| 11428 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 11429 | wdev, |
| 11430 | #endif |
| 11431 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
| 11432 | type, |
| 11433 | #else |
| 11434 | type, |
| 11435 | #endif |
| 11436 | dbm); |
| 11437 | vos_ssr_unprotect(__func__); |
| 11438 | |
| 11439 | return ret; |
| 11440 | } |
| 11441 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11442 | /* |
| 11443 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 11444 | * This function is used to read the txpower |
| 11445 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 11446 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 11447 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 11448 | struct wireless_dev *wdev, |
| 11449 | #endif |
| 11450 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11451 | { |
| 11452 | |
| 11453 | hdd_adapter_t *pAdapter; |
| 11454 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11455 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11456 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11457 | ENTER(); |
| 11458 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11459 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11460 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11461 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11462 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11463 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11464 | "%s: HDD context is not valid", __func__); |
| 11465 | *dbm = 0; |
| 11466 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11467 | } |
| 11468 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11469 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 11470 | if (NULL == pAdapter) |
| 11471 | { |
| 11472 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 11473 | return -ENOENT; |
| 11474 | } |
| 11475 | |
| 11476 | wlan_hdd_get_classAstats(pAdapter); |
| 11477 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 11478 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11479 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11480 | return 0; |
| 11481 | } |
| 11482 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 11483 | static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11484 | u8* mac, struct station_info *sinfo) |
| 11485 | { |
| 11486 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 11487 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11488 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 11489 | tANI_U32 rate_flags; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11490 | |
| 11491 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 11492 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11493 | |
| 11494 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 11495 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 11496 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 11497 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 11498 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 11499 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 11500 | tANI_U16 maxRate = 0; |
| 11501 | tANI_U16 myRate; |
| 11502 | tANI_U16 currentRate = 0; |
| 11503 | tANI_U8 maxSpeedMCS = 0; |
| 11504 | tANI_U8 maxMCSIdx = 0; |
| 11505 | tANI_U8 rateFlag = 1; |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11506 | tANI_U8 i, j, rssidx, mode=0; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 11507 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11508 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11509 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11510 | #ifdef WLAN_FEATURE_11AC |
| 11511 | tANI_U32 vht_mcs_map; |
| 11512 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 11513 | #endif /* WLAN_FEATURE_11AC */ |
| 11514 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11515 | ENTER(); |
| 11516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11517 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 11518 | (0 == ssidlen)) |
| 11519 | { |
| 11520 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 11521 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 11522 | /*To keep GUI happy*/ |
| 11523 | return 0; |
| 11524 | } |
| 11525 | |
Mukul Sharma | 811205f | 2014-07-09 21:07:30 +0530 | [diff] [blame] | 11526 | if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) |
| 11527 | { |
| 11528 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11529 | "%s: Roaming in progress, so unable to proceed this request", __func__); |
| 11530 | return 0; |
| 11531 | } |
| 11532 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11533 | status = wlan_hdd_validate_context(pHddCtx); |
| 11534 | |
| 11535 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11536 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11537 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11538 | "%s: HDD context is not valid", __func__); |
| 11539 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11540 | } |
| 11541 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11542 | |
Kiet Lam | 3b17fc8 | 2013-09-27 05:24:08 +0530 | [diff] [blame] | 11543 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 11544 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 11545 | |
c_hpothu | 09f1954 | 2014-05-30 21:53:31 +0530 | [diff] [blame] | 11546 | wlan_hdd_get_station_stats(pAdapter); |
| 11547 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 11548 | |
| 11549 | /*overwrite rate_flags if MAX link-speed need to be reported*/ |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 11550 | if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) || |
| 11551 | (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed && |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11552 | sinfo->signal >= pCfg->linkSpeedRssiLow)) |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 11553 | { |
| 11554 | rate_flags = pAdapter->maxRateFlags; |
| 11555 | } |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 11556 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11557 | //convert to the UI units of 100kbps |
| 11558 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 11559 | |
| 11560 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11561 | 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] | 11562 | sinfo->signal, |
| 11563 | pCfg->reportMaxLinkSpeed, |
| 11564 | myRate, |
| 11565 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 11566 | (int) pCfg->linkSpeedRssiMid, |
| 11567 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11568 | (int) rate_flags, |
| 11569 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11570 | #endif //LINKSPEED_DEBUG_ENABLED |
| 11571 | |
| 11572 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 11573 | { |
| 11574 | // we do not want to necessarily report the current speed |
| 11575 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 11576 | { |
| 11577 | // report the max possible speed |
| 11578 | rssidx = 0; |
| 11579 | } |
| 11580 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 11581 | { |
| 11582 | // report the max possible speed with RSSI scaling |
| 11583 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 11584 | { |
| 11585 | // report the max possible speed |
| 11586 | rssidx = 0; |
| 11587 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 11588 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11589 | { |
| 11590 | // report middle speed |
| 11591 | rssidx = 1; |
| 11592 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 11593 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 11594 | { |
| 11595 | // report middle speed |
| 11596 | rssidx = 2; |
| 11597 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11598 | else |
| 11599 | { |
| 11600 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 11601 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11602 | } |
| 11603 | } |
| 11604 | else |
| 11605 | { |
| 11606 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 11607 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11608 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 11609 | __func__, pCfg->reportMaxLinkSpeed); |
| 11610 | rssidx = 0; |
| 11611 | } |
| 11612 | |
| 11613 | maxRate = 0; |
| 11614 | |
| 11615 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 11616 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 11617 | OperationalRates, &ORLeng)) |
| 11618 | { |
| 11619 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 11620 | /*To keep GUI happy*/ |
| 11621 | return 0; |
| 11622 | } |
| 11623 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11624 | for (i = 0; i < ORLeng; i++) |
| 11625 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11626 | 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] | 11627 | { |
| 11628 | /* Validate Rate Set */ |
| 11629 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 11630 | { |
| 11631 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 11632 | break; |
| 11633 | } |
| 11634 | } |
| 11635 | /* Update MAX rate */ |
| 11636 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 11637 | } |
| 11638 | |
| 11639 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 11640 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 11641 | ExtendedRates, &ERLeng)) |
| 11642 | { |
| 11643 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 11644 | /*To keep GUI happy*/ |
| 11645 | return 0; |
| 11646 | } |
| 11647 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11648 | for (i = 0; i < ERLeng; i++) |
| 11649 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11650 | 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] | 11651 | { |
| 11652 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 11653 | { |
| 11654 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 11655 | break; |
| 11656 | } |
| 11657 | } |
| 11658 | /* Update MAX rate */ |
| 11659 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 11660 | } |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11661 | |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 11662 | /* Get MCS Rate Set -- |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 11663 | Only if we are always reporting max speed (or) |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 11664 | if we have good rssi */ |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11665 | if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11666 | { |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11667 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 11668 | mode = 2; |
| 11669 | else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40)) |
| 11670 | mode = 1; |
| 11671 | else |
| 11672 | mode = 0; |
| 11673 | |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 11674 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 11675 | MCSRates, &MCSLeng)) |
| 11676 | { |
| 11677 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 11678 | /*To keep GUI happy*/ |
| 11679 | return 0; |
| 11680 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11681 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11682 | #ifdef WLAN_FEATURE_11AC |
| 11683 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11684 | 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] | 11685 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11686 | 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] | 11687 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11688 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11689 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11690 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11691 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11692 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11693 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11694 | maxMCSIdx = 7; |
| 11695 | } |
| 11696 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 11697 | { |
| 11698 | maxMCSIdx = 8; |
| 11699 | } |
| 11700 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 11701 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11702 | //VHT20 is supporting 0~8 |
| 11703 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 11704 | maxMCSIdx = 8; |
| 11705 | else |
| 11706 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11707 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11708 | |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11709 | if (0 != rssidx)/*check for scaled */ |
| 11710 | { |
| 11711 | //get middle rate MCS index if rssi=1/2 |
| 11712 | for (i=0; i <= maxMCSIdx; i++) |
| 11713 | { |
| 11714 | if (sinfo->signal <= rssiMcsTbl[mode][i]) |
| 11715 | { |
| 11716 | maxMCSIdx = i; |
| 11717 | break; |
| 11718 | } |
| 11719 | } |
| 11720 | } |
| 11721 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11722 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 11723 | { |
| 11724 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 11725 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 11726 | } |
| 11727 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 11728 | { |
| 11729 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 11730 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 11731 | } |
| 11732 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 11733 | { |
| 11734 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 11735 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 11736 | } |
| 11737 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11738 | maxSpeedMCS = 1; |
| 11739 | if (currentRate > maxRate) |
| 11740 | { |
| 11741 | maxRate = currentRate; |
| 11742 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11743 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11744 | } |
| 11745 | else |
| 11746 | #endif /* WLAN_FEATURE_11AC */ |
| 11747 | { |
| 11748 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 11749 | { |
| 11750 | rateFlag |= 1; |
| 11751 | } |
| 11752 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 11753 | { |
| 11754 | rateFlag |= 2; |
| 11755 | } |
| 11756 | |
Girish Gowli | 01abcee | 2014-07-31 20:18:55 +0530 | [diff] [blame] | 11757 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11758 | if (rssidx == 1 || rssidx == 2) |
| 11759 | { |
| 11760 | //get middle rate MCS index if rssi=1/2 |
| 11761 | for (i=0; i <= 7; i++) |
| 11762 | { |
| 11763 | if (sinfo->signal <= rssiMcsTbl[mode][i]) |
| 11764 | { |
| 11765 | temp = i+1; |
| 11766 | break; |
| 11767 | } |
| 11768 | } |
| 11769 | } |
c_hpothu | 79aab32 | 2014-07-14 21:11:01 +0530 | [diff] [blame] | 11770 | |
| 11771 | for (i = 0; i < MCSLeng; i++) |
| 11772 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11773 | for (j = 0; j < temp; j++) |
| 11774 | { |
| 11775 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 11776 | { |
| 11777 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 11778 | break; |
| 11779 | } |
| 11780 | } |
| 11781 | if ((j < temp) && (currentRate > maxRate)) |
| 11782 | { |
| 11783 | maxRate = currentRate; |
| 11784 | maxSpeedMCS = 1; |
| 11785 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 11786 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11787 | } |
| 11788 | } |
| 11789 | } |
| 11790 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11791 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 11792 | { |
| 11793 | maxRate = myRate; |
| 11794 | maxSpeedMCS = 1; |
| 11795 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 11796 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11797 | // 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] | 11798 | if ((maxRate < myRate) || (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11799 | { |
| 11800 | maxRate = myRate; |
| 11801 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 11802 | { |
| 11803 | maxSpeedMCS = 0; |
| 11804 | } |
| 11805 | else |
| 11806 | { |
| 11807 | maxSpeedMCS = 1; |
| 11808 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 11809 | } |
| 11810 | } |
| 11811 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11812 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11813 | { |
| 11814 | sinfo->txrate.legacy = maxRate; |
| 11815 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 11816 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 11817 | #endif //LINKSPEED_DEBUG_ENABLED |
| 11818 | } |
| 11819 | else |
| 11820 | { |
| 11821 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11822 | #ifdef WLAN_FEATURE_11AC |
| 11823 | sinfo->txrate.nss = 1; |
| 11824 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 11825 | { |
| 11826 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11827 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11828 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11829 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11830 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11831 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 11832 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 11833 | } |
| 11834 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 11835 | { |
| 11836 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 11837 | } |
| 11838 | #endif /* WLAN_FEATURE_11AC */ |
| 11839 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 11840 | { |
| 11841 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 11842 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 11843 | { |
| 11844 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 11845 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11846 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11847 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 11848 | { |
| 11849 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 11850 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 11851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11852 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 11853 | pr_info("Reporting MCS rate %d flags %x\n", |
| 11854 | sinfo->txrate.mcs, |
| 11855 | sinfo->txrate.flags ); |
| 11856 | #endif //LINKSPEED_DEBUG_ENABLED |
| 11857 | } |
| 11858 | } |
| 11859 | else |
| 11860 | { |
| 11861 | // report current rate instead of max rate |
| 11862 | |
| 11863 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 11864 | { |
| 11865 | //provide to the UI in units of 100kbps |
| 11866 | sinfo->txrate.legacy = myRate; |
| 11867 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 11868 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 11869 | #endif //LINKSPEED_DEBUG_ENABLED |
| 11870 | } |
| 11871 | else |
| 11872 | { |
| 11873 | //must be MCS |
| 11874 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11875 | #ifdef WLAN_FEATURE_11AC |
| 11876 | sinfo->txrate.nss = 1; |
| 11877 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 11878 | { |
| 11879 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 11880 | } |
| 11881 | else |
| 11882 | #endif /* WLAN_FEATURE_11AC */ |
| 11883 | { |
| 11884 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 11885 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11886 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 11887 | { |
| 11888 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 11889 | } |
| 11890 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 11891 | { |
| 11892 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 11893 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 11894 | #ifdef WLAN_FEATURE_11AC |
| 11895 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 11896 | { |
| 11897 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 11898 | } |
| 11899 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11900 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 11901 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 11902 | sinfo->txrate.mcs, |
| 11903 | sinfo->txrate.flags ); |
| 11904 | #endif //LINKSPEED_DEBUG_ENABLED |
| 11905 | } |
| 11906 | } |
| 11907 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 11908 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 11909 | sinfo->tx_packets = |
| 11910 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 11911 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 11912 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 11913 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 11914 | |
| 11915 | sinfo->tx_retries = |
| 11916 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 11917 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 11918 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 11919 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 11920 | |
| 11921 | sinfo->tx_failed = |
| 11922 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 11923 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 11924 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 11925 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 11926 | |
| 11927 | sinfo->filled |= |
| 11928 | STATION_INFO_TX_PACKETS | |
| 11929 | STATION_INFO_TX_RETRIES | |
| 11930 | STATION_INFO_TX_FAILED; |
| 11931 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11932 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11933 | TRACE_CODE_HDD_CFG80211_GET_STA, |
| 11934 | pAdapter->sessionId, maxRate)); |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 11935 | EXIT(); |
| 11936 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11937 | } |
| 11938 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 11939 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 11940 | u8* mac, struct station_info *sinfo) |
| 11941 | { |
| 11942 | int ret; |
| 11943 | |
| 11944 | vos_ssr_protect(__func__); |
| 11945 | ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo); |
| 11946 | vos_ssr_unprotect(__func__); |
| 11947 | |
| 11948 | return ret; |
| 11949 | } |
| 11950 | |
| 11951 | static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 11952 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11953 | { |
| 11954 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 11955 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11956 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11957 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11958 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11959 | ENTER(); |
| 11960 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11961 | if (NULL == pAdapter) |
| 11962 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 11963 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11964 | return -ENODEV; |
| 11965 | } |
| 11966 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 11967 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 11968 | TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT, |
| 11969 | pAdapter->sessionId, timeout)); |
| 11970 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 11971 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11972 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 11973 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11974 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11975 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 11976 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11977 | "%s: HDD context is not valid", __func__); |
| 11978 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11979 | } |
| 11980 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 11981 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 11982 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 11983 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 11984 | (eConnectionState_Associated == |
| 11985 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 11986 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 11987 | |
| 11988 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 11989 | "offload: in cfg80211_set_power_mgmt, calling arp offload"); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 11990 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 11991 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 11992 | { |
| 11993 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 11994 | "%s:Failed to enable ARPOFFLOAD Feature %d", |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 11995 | __func__, vos_status); |
| 11996 | } |
| 11997 | } |
| 11998 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11999 | /**The get power cmd from the supplicant gets updated by the nl only |
| 12000 | *on successful execution of the function call |
| 12001 | *we are oppositely mapped w.r.t mode in the driver |
| 12002 | **/ |
| 12003 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 12004 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12005 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12006 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 12007 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12008 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12009 | "%s: failed to enter bmps mode", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12010 | return -EINVAL; |
| 12011 | } |
| 12012 | return 0; |
| 12013 | } |
| 12014 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12015 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 12016 | struct net_device *dev, bool mode, int timeout) |
| 12017 | { |
| 12018 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12019 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12020 | vos_ssr_protect(__func__); |
| 12021 | ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout); |
| 12022 | vos_ssr_unprotect(__func__); |
| 12023 | |
| 12024 | return ret; |
| 12025 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12026 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12027 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 12028 | struct net_device *netdev, |
| 12029 | u8 key_index) |
| 12030 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12031 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12032 | return 0; |
| 12033 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12034 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12035 | |
| 12036 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 12037 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 12038 | struct net_device *dev, |
| 12039 | struct ieee80211_txq_params *params) |
| 12040 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12041 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12042 | return 0; |
| 12043 | } |
| 12044 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 12045 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 12046 | struct ieee80211_txq_params *params) |
| 12047 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12048 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12049 | return 0; |
| 12050 | } |
| 12051 | #endif //LINUX_VERSION_CODE |
| 12052 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12053 | static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12054 | struct net_device *dev, u8 *mac) |
| 12055 | { |
| 12056 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12057 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12058 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12059 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12060 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12061 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12062 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12063 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12064 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12065 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12066 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12067 | return -EINVAL; |
| 12068 | } |
| 12069 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12070 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 12071 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
| 12072 | pAdapter->sessionId, pAdapter->device_mode)); |
| 12073 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12074 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12075 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12076 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12077 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12078 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12079 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12080 | "%s: HDD context is not valid", __func__); |
| 12081 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12082 | } |
| 12083 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12084 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12085 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12086 | ) |
| 12087 | { |
| 12088 | if( NULL == mac ) |
| 12089 | { |
| 12090 | v_U16_t i; |
| 12091 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 12092 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 12093 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 12094 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12095 | { |
| 12096 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 12097 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12098 | "%s: Delete STA with MAC::" |
| 12099 | MAC_ADDRESS_STR, |
| 12100 | __func__, MAC_ADDR_ARRAY(macAddr)); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 12101 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 12102 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 12103 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12104 | } |
| 12105 | } |
| 12106 | } |
| 12107 | else |
| 12108 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12109 | |
| 12110 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 12111 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 12112 | { |
| 12113 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12114 | "%s: Skip this DEL STA as this is not used::" |
| 12115 | MAC_ADDRESS_STR, |
| 12116 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12117 | return -ENOENT; |
| 12118 | } |
| 12119 | |
| 12120 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 12121 | { |
| 12122 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12123 | "%s: Skip this DEL STA as deauth is in progress::" |
| 12124 | MAC_ADDRESS_STR, |
| 12125 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12126 | return -ENOENT; |
| 12127 | } |
| 12128 | |
| 12129 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 12130 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12131 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12132 | "%s: Delete STA with MAC::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12133 | MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12134 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12135 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12136 | |
| 12137 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 12138 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 12139 | { |
| 12140 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 12141 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12142 | "%s: STA removal failed for ::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12143 | MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12144 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 12145 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12146 | return -ENOENT; |
| 12147 | } |
| 12148 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12149 | } |
| 12150 | } |
| 12151 | |
| 12152 | EXIT(); |
| 12153 | |
| 12154 | return 0; |
| 12155 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12156 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 12157 | struct net_device *dev, u8 *mac) |
| 12158 | { |
| 12159 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12160 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12161 | vos_ssr_protect(__func__); |
| 12162 | ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, mac); |
| 12163 | vos_ssr_unprotect(__func__); |
| 12164 | |
| 12165 | return ret; |
| 12166 | } |
| 12167 | |
| 12168 | static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 12169 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 12170 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12171 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 12172 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 12173 | #ifdef FEATURE_WLAN_TDLS |
| 12174 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 12175 | ENTER(); |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 12176 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12177 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 12178 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
| 12179 | pAdapter->sessionId, params->listen_interval)); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 12180 | mask = params->sta_flags_mask; |
| 12181 | |
| 12182 | set = params->sta_flags_set; |
| 12183 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 12184 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 12185 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12186 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 12187 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 12188 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 12189 | |
| 12190 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 12191 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 12192 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 12193 | } |
| 12194 | } |
| 12195 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 12196 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12197 | } |
| 12198 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12199 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 12200 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 12201 | { |
| 12202 | int ret; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12203 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12204 | vos_ssr_protect(__func__); |
| 12205 | ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params); |
| 12206 | vos_ssr_unprotect(__func__); |
| 12207 | |
| 12208 | return ret; |
| 12209 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12210 | #ifdef FEATURE_WLAN_LFR |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12211 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 12212 | 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] | 12213 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12214 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12215 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12216 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12217 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12218 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12219 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12220 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12221 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12222 | hdd_context_t *pHddCtx; |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 12223 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR, |
| 12224 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12225 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12226 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12227 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12228 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12229 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12230 | return -EINVAL; |
| 12231 | } |
| 12232 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12233 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12234 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12235 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12236 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12237 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 12238 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12239 | "%s: HDD context is not valid", __func__); |
| 12240 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12241 | } |
| 12242 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12243 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12244 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12245 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12246 | |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12247 | for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12248 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12249 | if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12250 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 12251 | { |
| 12252 | /* BSSID matched previous entry. Overwrite it. */ |
| 12253 | BSSIDMatched = 1; |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12254 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12255 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12256 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12257 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12258 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12259 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12260 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12261 | dump_bssid(pmksa->bssid); |
| 12262 | dump_pmkid(halHandle, pmksa->pmkid); |
| 12263 | break; |
| 12264 | } |
| 12265 | } |
| 12266 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 12267 | /* Check we compared all entries,if then take the first slot now */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12268 | if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0; |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 12269 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12270 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12271 | { |
| 12272 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12273 | vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12274 | pmksa->bssid, ETHER_ADDR_LEN); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12275 | vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12276 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12277 | CSR_RSN_PMKID_SIZE); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12278 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.", |
| 12279 | __func__, pHddStaCtx->PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12280 | dump_bssid(pmksa->bssid); |
| 12281 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12282 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12283 | // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12284 | if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) |
| 12285 | pHddStaCtx->PMKIDCacheIndex++; |
| 12286 | else |
| 12287 | pHddStaCtx->PMKIDCacheIndex = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12288 | } |
| 12289 | |
| 12290 | |
| 12291 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12292 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.", |
| 12293 | __func__, pHddStaCtx->PMKIDCacheIndex ); |
| 12294 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12295 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12296 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12297 | pHddStaCtx->PMKIDCache, |
| 12298 | pHddStaCtx->PMKIDCacheIndex); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12299 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 12300 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
| 12301 | pAdapter->sessionId, result)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12302 | return 0; |
| 12303 | } |
| 12304 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 12305 | static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, |
| 12306 | struct cfg80211_pmksa *pmksa) |
| 12307 | { |
| 12308 | int ret; |
| 12309 | |
| 12310 | vos_ssr_protect(__func__); |
| 12311 | ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa); |
| 12312 | vos_ssr_unprotect(__func__); |
| 12313 | |
| 12314 | return ret; |
| 12315 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12316 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12317 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 12318 | 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] | 12319 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12320 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12321 | tANI_U32 j=0; |
| 12322 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12323 | hdd_station_ctx_t *pHddStaCtx; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12324 | tHalHandle halHandle; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12325 | tANI_U8 BSSIDMatched = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12326 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12327 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12328 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 12329 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR, |
| 12330 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12331 | |
| 12332 | /* Validate pAdapter */ |
| 12333 | if (NULL == pAdapter) |
| 12334 | { |
| 12335 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
| 12336 | return -EINVAL; |
| 12337 | } |
| 12338 | |
| 12339 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12340 | status = wlan_hdd_validate_context(pHddCtx); |
| 12341 | |
| 12342 | if (0 != status) |
| 12343 | { |
| 12344 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12345 | "%s: HDD context is not valid", __func__); |
| 12346 | return status; |
| 12347 | } |
| 12348 | |
| 12349 | /*Retrieve halHandle*/ |
| 12350 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12351 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12352 | |
| 12353 | /*in case index is 0,no entry to delete*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12354 | if (0 == pHddStaCtx->PMKIDCacheIndex) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12355 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12356 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush")); |
| 12357 | return 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12358 | } |
| 12359 | |
| 12360 | /*find the matching PMKSA entry from j=0 to (index-1), |
| 12361 | * and delete the matched one |
| 12362 | */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12363 | for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12364 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12365 | if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12366 | pmksa->bssid, |
| 12367 | WNI_CFG_BSSID_LEN)) |
| 12368 | { |
| 12369 | /* BSSID matched entry */ |
| 12370 | BSSIDMatched = 1; |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12371 | if (j < pHddStaCtx->PMKIDCacheIndex-1) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12372 | { |
| 12373 | /*replace the matching entry with the last entry in HDD local cache*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12374 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID, |
| 12375 | pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID, |
| 12376 | VOS_MAC_ADDR_SIZE); |
| 12377 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID, |
| 12378 | pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID, |
| 12379 | CSR_RSN_PMKID_SIZE); |
| 12380 | } |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12381 | |
| 12382 | /*clear the last entry in HDD cache ---[index-1]*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12383 | vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID, |
| 12384 | VOS_MAC_ADDR_SIZE); |
| 12385 | vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID, |
| 12386 | CSR_RSN_PMKID_SIZE); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12387 | /*reduce the PMKID array index*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12388 | pHddStaCtx->PMKIDCacheIndex--; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12389 | /*delete the last PMKID cache in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12390 | if (eHAL_STATUS_SUCCESS != |
| 12391 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12392 | { |
| 12393 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.", |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12394 | __func__, pHddStaCtx->PMKIDCacheIndex); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12395 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12396 | } |
| 12397 | |
| 12398 | dump_bssid(pmksa->bssid); |
| 12399 | dump_pmkid(halHandle,pmksa->pmkid); |
| 12400 | |
| 12401 | break; |
| 12402 | } |
| 12403 | } |
| 12404 | |
| 12405 | /* we compare all entries,but cannot find matching entry */ |
| 12406 | if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched) |
| 12407 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 12408 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12409 | "%s: No such PMKSA entry existed " MAC_ADDRESS_STR, |
| 12410 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12411 | dump_bssid(pmksa->bssid); |
| 12412 | dump_pmkid(halHandle, pmksa->pmkid); |
| 12413 | return -EINVAL; |
| 12414 | } |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12415 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12416 | } |
| 12417 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12418 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 12419 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, |
| 12420 | struct cfg80211_pmksa *pmksa) |
| 12421 | { |
| 12422 | int ret; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12423 | |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 12424 | vos_ssr_protect(__func__); |
| 12425 | ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa); |
| 12426 | vos_ssr_unprotect(__func__); |
| 12427 | |
| 12428 | return ret; |
| 12429 | |
| 12430 | } |
| 12431 | |
| 12432 | 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] | 12433 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12434 | tANI_U32 j=0; |
| 12435 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12436 | hdd_station_ctx_t *pHddStaCtx; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12437 | tHalHandle halHandle; |
| 12438 | hdd_context_t *pHddCtx; |
| 12439 | tANI_U8 *pBSSId; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12440 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12441 | |
| 12442 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__); |
| 12443 | |
| 12444 | /* Validate pAdapter */ |
| 12445 | if (NULL == pAdapter) |
| 12446 | { |
| 12447 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12448 | "%s: Invalid Adapter" ,__func__); |
| 12449 | return -EINVAL; |
| 12450 | } |
| 12451 | |
| 12452 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12453 | status = wlan_hdd_validate_context(pHddCtx); |
| 12454 | |
| 12455 | if (0 != status) |
| 12456 | { |
| 12457 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12458 | "%s: HDD context is not valid", __func__); |
| 12459 | return status; |
| 12460 | } |
| 12461 | |
| 12462 | /*Retrieve halHandle*/ |
| 12463 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12464 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12465 | |
| 12466 | /*in case index is 0,no entry to delete*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12467 | if (0 == pHddStaCtx->PMKIDCacheIndex) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12468 | { |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 12469 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush")); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12470 | return 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12471 | } |
| 12472 | |
| 12473 | /*delete all the PMKSA one by one */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12474 | for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12475 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12476 | pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12477 | /*delete the PMKID in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12478 | if (eHAL_STATUS_SUCCESS != |
| 12479 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12480 | { |
| 12481 | hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.", |
| 12482 | __func__,j); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12483 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12484 | } |
Kiet Lam | 8d21d5b | 2013-10-31 17:18:29 +0530 | [diff] [blame] | 12485 | /*clear the entry in HDD cache 0--index-1 */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12486 | vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE); |
| 12487 | vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE); |
| 12488 | } |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 12489 | |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 12490 | pHddStaCtx->PMKIDCacheIndex = 0; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 12491 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12492 | } |
Mahesh A Saptasagar | f7418d7 | 2014-06-02 14:48:54 +0530 | [diff] [blame] | 12493 | |
| 12494 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 12495 | { |
| 12496 | int ret; |
| 12497 | |
| 12498 | vos_ssr_protect(__func__); |
| 12499 | ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev); |
| 12500 | vos_ssr_unprotect(__func__); |
| 12501 | |
| 12502 | return ret; |
| 12503 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12504 | #endif |
| 12505 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12506 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12507 | static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 12508 | struct net_device *dev, |
| 12509 | struct cfg80211_update_ft_ies_params *ftie) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12510 | { |
| 12511 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12512 | hdd_station_ctx_t *pHddStaCtx; |
| 12513 | |
| 12514 | if (NULL == pAdapter) |
| 12515 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12516 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12517 | return -ENODEV; |
| 12518 | } |
| 12519 | |
| 12520 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12521 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 12522 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 12523 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
| 12524 | pAdapter->sessionId, pHddStaCtx->conn_info.connState)); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12525 | // Added for debug on reception of Re-assoc Req. |
| 12526 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 12527 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12528 | 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] | 12529 | ftie->ie_len); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12530 | hddLog(LOGE, FL("Should be Re-assoc Req IEs")); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12531 | } |
| 12532 | |
| 12533 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12534 | hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12535 | ftie->ie_len); |
| 12536 | #endif |
| 12537 | |
| 12538 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 12539 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 12540 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12541 | ftie->ie_len); |
| 12542 | return 0; |
| 12543 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 12544 | |
| 12545 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 12546 | struct net_device *dev, |
| 12547 | struct cfg80211_update_ft_ies_params *ftie) |
| 12548 | { |
| 12549 | int ret; |
| 12550 | |
| 12551 | vos_ssr_protect(__func__); |
| 12552 | ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie); |
| 12553 | vos_ssr_unprotect(__func__); |
| 12554 | |
| 12555 | return ret; |
| 12556 | } |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 12557 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 12558 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12559 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12560 | |
| 12561 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 12562 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 12563 | { |
| 12564 | int ret; |
| 12565 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 12566 | hdd_context_t *pHddCtx; |
| 12567 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12568 | ENTER(); |
| 12569 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12570 | if (NULL == pAdapter) |
| 12571 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 12572 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12573 | "%s: HDD adapter is Null", __func__); |
| 12574 | return ; |
| 12575 | } |
| 12576 | |
| 12577 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12578 | if (NULL == pHddCtx) |
| 12579 | { |
| 12580 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12581 | "%s: HDD context is Null!!!", __func__); |
| 12582 | return ; |
| 12583 | } |
| 12584 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12585 | spin_lock(&pHddCtx->schedScan_lock); |
| 12586 | if (TRUE == pHddCtx->isWiphySuspended) |
| 12587 | { |
| 12588 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 12589 | spin_unlock(&pHddCtx->schedScan_lock); |
| 12590 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12591 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 12592 | return ; |
| 12593 | } |
| 12594 | spin_unlock(&pHddCtx->schedScan_lock); |
| 12595 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12596 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 12597 | |
| 12598 | if (0 > ret) |
| 12599 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 12600 | |
| 12601 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12602 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12603 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12604 | } |
| 12605 | |
| 12606 | /* |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12607 | * FUNCTION: wlan_hdd_is_pno_allowed |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 12608 | * Disallow pno if any session is active |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12609 | */ |
| 12610 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter) |
| 12611 | { |
| 12612 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 12613 | hdd_adapter_t *pTempAdapter = NULL; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12614 | hdd_station_ctx_t *pStaCtx; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12615 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12616 | int status = 0; |
| 12617 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 12618 | |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 12619 | /* The current firmware design does not allow PNO during any |
| 12620 | * active sessions. Hence, determine the active sessions |
| 12621 | * and return a failure. |
| 12622 | */ |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12623 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)) |
| 12624 | { |
| 12625 | pTempAdapter = pAdapterNode->pAdapter; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12626 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12627 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12628 | if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode) |
| 12629 | && (eConnectionState_NotConnected != pStaCtx->conn_info.connState)) |
| 12630 | || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode) |
| 12631 | || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode) |
| 12632 | || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode) |
| 12633 | ) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12634 | { |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12635 | return eHAL_STATUS_FAILURE; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12636 | } |
| 12637 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 12638 | pAdapterNode = pNext; |
| 12639 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12640 | return eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12641 | } |
| 12642 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12643 | void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status) |
| 12644 | { |
| 12645 | hdd_adapter_t *pAdapter = callbackContext; |
| 12646 | hdd_context_t *pHddCtx; |
| 12647 | |
| 12648 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 12649 | { |
| 12650 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12651 | FL("Invalid adapter or adapter has invalid magic")); |
| 12652 | return; |
| 12653 | } |
| 12654 | |
| 12655 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12656 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
| 12657 | { |
| 12658 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12659 | FL("HDD context is not valid")); |
| 12660 | return; |
| 12661 | } |
| 12662 | |
c_hpothu | b53c45d | 2014-08-18 16:53:14 +0530 | [diff] [blame] | 12663 | if (VOS_STATUS_SUCCESS != status) |
| 12664 | { |
| 12665 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12666 | FL("PNO enable response status = %d"), status); |
c_hpothu | b53c45d | 2014-08-18 16:53:14 +0530 | [diff] [blame] | 12667 | pHddCtx->isPnoEnable = FALSE; |
| 12668 | } |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12669 | |
| 12670 | pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 12671 | complete(&pAdapter->pno_comp_var); |
| 12672 | } |
| 12673 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12674 | /* |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 12675 | * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start |
| 12676 | * Function to enable PNO |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12677 | */ |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 12678 | static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12679 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 12680 | { |
| 12681 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12682 | tpSirPNOScanReq pPnoRequest = NULL; |
| 12683 | hdd_context_t *pHddCtx; |
| 12684 | tHalHandle hHal; |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 12685 | v_U32_t i, indx, num_ch, tempInterval, j; |
Sushant Kaushik | d62d978 | 2014-02-19 15:39:40 +0530 | [diff] [blame] | 12686 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 12687 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12688 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 12689 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12690 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12691 | |
| 12692 | if (NULL == pAdapter) |
| 12693 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 12694 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12695 | "%s: HDD adapter is Null", __func__); |
| 12696 | return -ENODEV; |
| 12697 | } |
| 12698 | |
| 12699 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12700 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12701 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12702 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12703 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 12704 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12705 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12706 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12707 | } |
| 12708 | |
| 12709 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 12710 | if (NULL == hHal) |
| 12711 | { |
| 12712 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12713 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12714 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12715 | } |
Sushant Kaushik | 2fe8993 | 2014-09-03 10:58:09 +0530 | [diff] [blame] | 12716 | sme_ScanFlushResult(hHal, pAdapter->sessionId); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 12717 | ret = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 12718 | if (ret < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 12719 | { |
| 12720 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12721 | "%s: aborting the existing scan is unsuccessfull", __func__); |
| 12722 | return -EBUSY; |
| 12723 | } |
| 12724 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12725 | if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter)) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12726 | { |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 12727 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 12728 | FL("Cannot handle sched_scan")); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 12729 | return -EBUSY; |
| 12730 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12731 | |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 12732 | if (TRUE == pHddCtx->isPnoEnable) |
| 12733 | { |
| 12734 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 12735 | FL("already PNO is enabled")); |
| 12736 | return -EBUSY; |
| 12737 | } |
| 12738 | pHddCtx->isPnoEnable = TRUE; |
| 12739 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12740 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 12741 | if (NULL == pPnoRequest) |
| 12742 | { |
| 12743 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 12744 | "%s: vos_mem_malloc failed", __func__); |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 12745 | pHddCtx->isPnoEnable = FALSE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12746 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12747 | } |
| 12748 | |
Madan Mohan Koyyalamudi | c3f0435 | 2013-09-26 19:21:48 +0530 | [diff] [blame] | 12749 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12750 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 12751 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 12752 | |
| 12753 | if (( !pPnoRequest->ucNetworksCount ) || |
| 12754 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 12755 | { |
| 12756 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 12757 | "%s: Network input is not correct %d Max Network supported is %d", |
| 12758 | __func__, pPnoRequest->ucNetworksCount, |
| 12759 | SIR_PNO_MAX_SUPP_NETWORKS); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12760 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12761 | goto error; |
| 12762 | } |
| 12763 | |
| 12764 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 12765 | { |
| 12766 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12767 | "%s: Incorrect number of channels %d", |
| 12768 | __func__, request->n_channels); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12769 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12770 | goto error; |
| 12771 | } |
| 12772 | |
| 12773 | /* Framework provides one set of channels(all) |
| 12774 | * common for all saved profile */ |
| 12775 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 12776 | channels_allowed, &num_channels_allowed)) |
| 12777 | { |
| 12778 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12779 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12780 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12781 | goto error; |
| 12782 | } |
| 12783 | /* Checking each channel against allowed channel list */ |
| 12784 | num_ch = 0; |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12785 | if (request->n_channels) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12786 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12787 | char chList [(request->n_channels*5)+1]; |
| 12788 | int len; |
| 12789 | for (i = 0, len = 0; i < request->n_channels; i++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12790 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12791 | for (indx = 0; indx < num_channels_allowed; indx++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12792 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12793 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 12794 | { |
| 12795 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 12796 | len += snprintf(chList+len, 5, "%d ", |
| 12797 | request->channels[i]->hw_value); |
| 12798 | break ; |
| 12799 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12800 | } |
| 12801 | } |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12802 | hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList); |
| 12803 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12804 | |
| 12805 | /* Filling per profile params */ |
| 12806 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 12807 | { |
| 12808 | pPnoRequest->aNetworks[i].ssId.length = |
| 12809 | request->match_sets[i].ssid.ssid_len; |
| 12810 | |
| 12811 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 12812 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 12813 | { |
| 12814 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12815 | "%s: SSID Len %d is not correct for network %d", |
| 12816 | __func__, pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12817 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12818 | goto error; |
| 12819 | } |
| 12820 | |
| 12821 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 12822 | request->match_sets[i].ssid.ssid, |
| 12823 | request->match_sets[i].ssid.ssid_len); |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 12824 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12825 | "%s: SSID of network %d is %s ", __func__, |
| 12826 | i, pPnoRequest->aNetworks[i].ssId.ssId); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12827 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 12828 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 12829 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 12830 | |
| 12831 | /*Copying list of valid channel into request */ |
| 12832 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 12833 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 12834 | |
| 12835 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 12836 | } |
| 12837 | |
Mahesh A Saptasagar | 7bd6ad4 | 2014-07-21 18:56:33 +0530 | [diff] [blame] | 12838 | for (i = 0; i < request->n_ssids; i++) |
| 12839 | { |
| 12840 | j = 0; |
| 12841 | while (j < pPnoRequest->ucNetworksCount) |
| 12842 | { |
| 12843 | if ((pPnoRequest->aNetworks[j].ssId.length == |
| 12844 | request->ssids[i].ssid_len) && |
| 12845 | (0 == memcmp(pPnoRequest->aNetworks[j].ssId.ssId, |
| 12846 | request->ssids[i].ssid, |
| 12847 | pPnoRequest->aNetworks[j].ssId.length))) |
| 12848 | { |
| 12849 | pPnoRequest->aNetworks[j].bcastNetwType = eBCAST_HIDDEN; |
| 12850 | break; |
| 12851 | } |
| 12852 | j++; |
| 12853 | } |
| 12854 | } |
| 12855 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12856 | "Number of hidden networks being Configured = %d", |
| 12857 | request->n_ssids); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 12858 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 12859 | "request->ie_len = %zu", request->ie_len); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 12860 | if ((0 < request->ie_len) && (NULL != request->ie)) |
| 12861 | { |
| 12862 | pPnoRequest->us24GProbeTemplateLen = request->ie_len; |
| 12863 | memcpy(&pPnoRequest->p24GProbeTemplate, request->ie, |
| 12864 | pPnoRequest->us24GProbeTemplateLen); |
| 12865 | |
| 12866 | pPnoRequest->us5GProbeTemplateLen = request->ie_len; |
| 12867 | memcpy(&pPnoRequest->p5GProbeTemplate, request->ie, |
| 12868 | pPnoRequest->us5GProbeTemplateLen); |
| 12869 | } |
| 12870 | |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 12871 | /* Driver gets only one time interval which is hardcoded in |
| 12872 | * supplicant for 10000ms. Taking power consumption into account 6 timers |
| 12873 | * will be used, Timervalue is increased exponentially i.e 10,20,40, |
| 12874 | * 80,160,320 secs. And number of scan cycle for each timer |
| 12875 | * is configurable through INI param gPNOScanTimerRepeatValue. |
| 12876 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 12877 | * will be repeated after each interval specified by supplicant |
| 12878 | * till PNO is disabled. |
| 12879 | */ |
| 12880 | if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue) |
| 12881 | pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 12882 | else |
| 12883 | pPnoRequest->scanTimers.ucScanTimersCount = |
| 12884 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 12885 | |
| 12886 | tempInterval = (request->interval)/1000; |
| 12887 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12888 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 12889 | tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue); |
| 12890 | for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++) |
| 12891 | { |
| 12892 | pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat = |
| 12893 | pHddCtx->cfg_ini->configPNOScanTimerRepeatValue; |
| 12894 | pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval; |
| 12895 | tempInterval *= 2; |
| 12896 | } |
| 12897 | //Repeat last timer until pno disabled. |
| 12898 | pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
| 12899 | |
Madan Mohan Koyyalamudi | d206c7b | 2013-09-26 22:54:51 +0530 | [diff] [blame] | 12900 | pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12901 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12902 | INIT_COMPLETION(pAdapter->pno_comp_var); |
| 12903 | pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb; |
| 12904 | pPnoRequest->callbackContext = pAdapter; |
| 12905 | pAdapter->pno_req_status = 0; |
| 12906 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12907 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12908 | "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d", |
| 12909 | pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO, |
| 12910 | pPnoRequest->scanTimers.ucScanTimersCount); |
| 12911 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12912 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 12913 | pPnoRequest, pAdapter->sessionId, |
| 12914 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 12915 | if (eHAL_STATUS_SUCCESS != status) |
| 12916 | { |
| 12917 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 12918 | "%s: Failed to enable PNO", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12919 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12920 | goto error; |
| 12921 | } |
| 12922 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12923 | ret = wait_for_completion_timeout( |
| 12924 | &pAdapter->pno_comp_var, |
| 12925 | msecs_to_jiffies(WLAN_WAIT_TIME_PNO)); |
| 12926 | if (0 >= ret) |
| 12927 | { |
| 12928 | // Did not receive the response for PNO enable in time. |
| 12929 | // Assuming the PNO enable was success. |
| 12930 | // Returning error from here, because we timeout, results |
| 12931 | // in side effect of Wifi (Wifi Setting) not to work. |
| 12932 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12933 | FL("Timed out waiting for PNO to be Enabled")); |
| 12934 | ret = 0; |
| 12935 | goto error; |
| 12936 | } |
| 12937 | |
c_hpothu | 3c986b2 | 2014-07-09 14:45:09 +0530 | [diff] [blame] | 12938 | vos_mem_free(pPnoRequest); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12939 | ret = pAdapter->pno_req_status; |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 12940 | return ret; |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12941 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12942 | error: |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 12943 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12944 | FL("PNO scanRequest offloaded ret = %d"), ret); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12945 | vos_mem_free(pPnoRequest); |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 12946 | pHddCtx->isPnoEnable = FALSE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12947 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12948 | } |
| 12949 | |
| 12950 | /* |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 12951 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 12952 | * NL interface to enable PNO |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12953 | */ |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 12954 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 12955 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 12956 | { |
| 12957 | int ret; |
| 12958 | |
| 12959 | vos_ssr_protect(__func__); |
| 12960 | ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request); |
| 12961 | vos_ssr_unprotect(__func__); |
| 12962 | |
| 12963 | return ret; |
| 12964 | } |
| 12965 | |
| 12966 | /* |
| 12967 | * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop |
| 12968 | * Function to disable PNO |
| 12969 | */ |
| 12970 | static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12971 | struct net_device *dev) |
| 12972 | { |
| 12973 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 12974 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12975 | hdd_context_t *pHddCtx; |
| 12976 | tHalHandle hHal; |
| 12977 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12978 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12979 | |
| 12980 | ENTER(); |
| 12981 | |
| 12982 | if (NULL == pAdapter) |
| 12983 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 12984 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12985 | "%s: HDD adapter is Null", __func__); |
| 12986 | return -ENODEV; |
| 12987 | } |
| 12988 | |
| 12989 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12990 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12991 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 12992 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 12993 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 12994 | "%s: HDD context is Null", __func__); |
| 12995 | return -ENODEV; |
| 12996 | } |
| 12997 | |
| 12998 | /* The return 0 is intentional when isLogpInProgress and |
| 12999 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 13000 | * failure in sched_scan_stop , especially for a case where the unload |
| 13001 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 13002 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 13003 | * success. If it returns a failure , then its next invocation due to the |
| 13004 | * clean up of the second interface will have the dev pointer corresponding |
| 13005 | * to the first one leading to a crash. |
| 13006 | */ |
| 13007 | if (pHddCtx->isLogpInProgress) |
| 13008 | { |
| 13009 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13010 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 13011 | return ret; |
| 13012 | } |
| 13013 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 13014 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 13015 | { |
| 13016 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13017 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 13018 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13019 | } |
| 13020 | |
| 13021 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 13022 | if (NULL == hHal) |
| 13023 | { |
| 13024 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13025 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 13026 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13027 | } |
| 13028 | |
| 13029 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 13030 | if (NULL == pPnoRequest) |
| 13031 | { |
| 13032 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 13033 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 13034 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13035 | } |
| 13036 | |
| 13037 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 13038 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 13039 | pPnoRequest->ucNetworksCount = 0; |
| 13040 | |
| 13041 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 13042 | pAdapter->sessionId, |
| 13043 | NULL, pAdapter); |
| 13044 | if (eHAL_STATUS_SUCCESS != status) |
| 13045 | { |
| 13046 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13047 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 13048 | ret = -EINVAL; |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 13049 | goto error; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13050 | } |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 13051 | pHddCtx->isPnoEnable = FALSE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13052 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 13053 | error: |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 13054 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 13055 | FL("PNO scan disabled ret = %d"), ret); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13056 | vos_mem_free(pPnoRequest); |
| 13057 | |
| 13058 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 13059 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13060 | } |
| 13061 | |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 13062 | /* |
| 13063 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 13064 | * NL interface to disable PNO |
| 13065 | */ |
| 13066 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 13067 | struct net_device *dev) |
| 13068 | { |
| 13069 | int ret; |
| 13070 | |
| 13071 | vos_ssr_protect(__func__); |
| 13072 | ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev); |
| 13073 | vos_ssr_unprotect(__func__); |
| 13074 | |
| 13075 | return ret; |
| 13076 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 13077 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 13078 | |
| 13079 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13080 | #ifdef FEATURE_WLAN_TDLS |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 13081 | #if TDLS_MGMT_VERSION2 |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13082 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 13083 | u8 *peer, u8 action_code, u8 dialog_token, |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 13084 | u16 status_code, u32 peer_capability, const u8 *buf, size_t len) |
| 13085 | #else |
| 13086 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 13087 | u8 *peer, u8 action_code, u8 dialog_token, |
| 13088 | u16 status_code, const u8 *buf, size_t len) |
| 13089 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13090 | { |
| 13091 | |
| 13092 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13093 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13094 | u8 peerMac[6]; |
| 13095 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 13096 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13097 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 13098 | long rc; |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 13099 | #if !(TDLS_MGMT_VERSION2) |
| 13100 | u32 peer_capability = 0; |
| 13101 | #endif |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 13102 | tANI_U16 numCurrTdlsPeers; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 13103 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 13104 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 13105 | TRACE_CODE_HDD_CFG80211_TDLS_MGMT, |
| 13106 | pAdapter->sessionId, action_code)); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13107 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13108 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 13109 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13110 | "Invalid arguments"); |
| 13111 | return -EINVAL; |
| 13112 | } |
| 13113 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 13114 | if (pHddCtx->isLogpInProgress) |
| 13115 | { |
| 13116 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13117 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13118 | wlan_hdd_tdls_set_link_status(pAdapter, |
| 13119 | peer, |
| 13120 | eTDLS_LINK_IDLE, |
| 13121 | eTDLS_LINK_UNSPECIFIED); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 13122 | return -EBUSY; |
| 13123 | } |
| 13124 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 13125 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13126 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 13127 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 13128 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 13129 | MAC_ADDRESS_STR " action %d declined.", |
| 13130 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13131 | return -ENOTSUPP; |
| 13132 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13133 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 13134 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 13135 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 13136 | { |
| 13137 | /* if tdls_mode is disabled to respond to peer's request */ |
| 13138 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 13139 | { |
| 13140 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 13141 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 13142 | " TDLS mode is disabled. action %d declined.", |
| 13143 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 13144 | |
| 13145 | return -ENOTSUPP; |
| 13146 | } |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 13147 | |
| 13148 | if (vos_max_concurrent_connections_reached()) |
| 13149 | { |
| 13150 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections")); |
| 13151 | return -EINVAL; |
| 13152 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 13153 | } |
| 13154 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13155 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 13156 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 13157 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13158 | { |
| 13159 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13160 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 13161 | " TDLS setup is ongoing. action %d declined.", |
| 13162 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 13163 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13164 | } |
| 13165 | } |
| 13166 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13167 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 13168 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13169 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 13170 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 13171 | if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13172 | { |
| 13173 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 13174 | we return error code at 'add_station()'. Hence we have this |
| 13175 | check again in addtion to add_station(). |
| 13176 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13177 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13178 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13179 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13180 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 13181 | " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).", |
| 13182 | __func__, MAC_ADDR_ARRAY(peer), action_code, |
| 13183 | numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 13184 | return -EINVAL; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13185 | } |
| 13186 | else |
| 13187 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13188 | /* maximum reached. tweak to send error code to peer and return |
| 13189 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13190 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13191 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13192 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 13193 | " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).", |
| 13194 | __func__, MAC_ADDR_ARRAY(peer), status_code, |
| 13195 | numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 13196 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13197 | /* fall through to send setup resp with failure status |
| 13198 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13199 | } |
| 13200 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13201 | else |
| 13202 | { |
| 13203 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 13204 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 13205 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13206 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13207 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 13208 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 13209 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13210 | return -EPERM; |
| 13211 | } |
| 13212 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13213 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13214 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13215 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 13216 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 13217 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Kumar Khandavalli | 9fb625e | 2014-03-17 16:07:40 +0530 | [diff] [blame] | 13218 | "%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] | 13219 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 13220 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 13221 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13222 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13223 | /*Except teardown responder will not be used so just make 0*/ |
| 13224 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 13225 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13226 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 13227 | |
| 13228 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 13229 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 13230 | |
| 13231 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 13232 | responder = pTdlsPeer->is_responder; |
| 13233 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13234 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 13235 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Kumar Khandavalli | 9fb625e | 2014-03-17 16:07:40 +0530 | [diff] [blame] | 13236 | "%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] | 13237 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 13238 | dialog_token, status_code, len); |
| 13239 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13240 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13241 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13242 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 13243 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 13244 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13245 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 13246 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 13247 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13248 | { |
| 13249 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 13250 | { |
| 13251 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 13252 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13253 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 13254 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 13255 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 13256 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13257 | } |
| 13258 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 13259 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 13260 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 13261 | { |
| 13262 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 13263 | "%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] | 13264 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 13265 | return -EBUSY; |
| 13266 | } |
| 13267 | |
| 13268 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13269 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 13270 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13271 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Pradeep Reddy POTTETI | ca171f8 | 2014-03-21 14:17:35 +0530 | [diff] [blame] | 13272 | peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13273 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13274 | if (VOS_STATUS_SUCCESS != status) |
| 13275 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13276 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13277 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 13278 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13279 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 13280 | return -EINVAL; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13281 | } |
| 13282 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 13283 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 13284 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 13285 | |
| 13286 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13287 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 13288 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 13289 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %u", |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 13290 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 13291 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 13292 | |
| 13293 | if (pHddCtx->isLogpInProgress) |
| 13294 | { |
| 13295 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13296 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 13297 | return -EAGAIN; |
| 13298 | } |
| 13299 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 13300 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 13301 | return -EINVAL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13302 | } |
| 13303 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 13304 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13305 | { |
| 13306 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 13307 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13308 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13309 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13310 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 13311 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 13312 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13313 | } |
| 13314 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 13315 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 13316 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 13317 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13318 | |
| 13319 | return 0; |
| 13320 | } |
| 13321 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13322 | |
| 13323 | int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter, |
| 13324 | u8 *peer, |
| 13325 | cfg80211_exttdls_callback callback) |
| 13326 | { |
| 13327 | |
| 13328 | hddTdlsPeer_t *pTdlsPeer; |
| 13329 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13330 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13331 | " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR, |
| 13332 | __func__, MAC_ADDR_ARRAY(peer)); |
| 13333 | |
| 13334 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 13335 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 13336 | |
| 13337 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13338 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 13339 | __func__); |
| 13340 | return -ENOTSUPP; |
| 13341 | } |
| 13342 | |
| 13343 | /* To cater the requirement of establishing the TDLS link |
| 13344 | * irrespective of the data traffic , get an entry of TDLS peer. |
| 13345 | */ |
| 13346 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer); |
| 13347 | if (pTdlsPeer == NULL) { |
| 13348 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13349 | "%s: peer " MAC_ADDRESS_STR " not existing", |
| 13350 | __func__, MAC_ADDR_ARRAY(peer)); |
| 13351 | return -EINVAL; |
| 13352 | } |
| 13353 | |
| 13354 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) { |
| 13355 | |
| 13356 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13357 | " %s TDLS Add Force Peer Failed", |
| 13358 | __func__); |
| 13359 | return -EINVAL; |
| 13360 | } |
| 13361 | /*EXT TDLS*/ |
| 13362 | |
| 13363 | if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) { |
| 13364 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13365 | " %s TDLS set callback Failed", |
| 13366 | __func__); |
| 13367 | return -EINVAL; |
| 13368 | } |
| 13369 | |
| 13370 | return(0); |
| 13371 | |
| 13372 | } |
| 13373 | |
| 13374 | int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer) |
| 13375 | { |
| 13376 | |
| 13377 | hddTdlsPeer_t *pTdlsPeer; |
| 13378 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13379 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13380 | " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR, |
| 13381 | __func__, MAC_ADDR_ARRAY(peer)); |
| 13382 | |
| 13383 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 13384 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 13385 | |
| 13386 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13387 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 13388 | __func__); |
| 13389 | return -ENOTSUPP; |
| 13390 | } |
| 13391 | |
| 13392 | |
| 13393 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 13394 | |
| 13395 | if ( NULL == pTdlsPeer ) { |
| 13396 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR |
| 13397 | " peer not exsting", |
| 13398 | __func__, MAC_ADDR_ARRAY(peer)); |
| 13399 | return -EINVAL; |
| 13400 | } |
| 13401 | else { |
| 13402 | wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, |
| 13403 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 13404 | } |
| 13405 | |
| 13406 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) |
| 13407 | return -EINVAL; |
| 13408 | |
| 13409 | /*EXT TDLS*/ |
| 13410 | |
| 13411 | if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) { |
| 13412 | |
| 13413 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13414 | " %s TDLS set callback Failed", |
| 13415 | __func__); |
| 13416 | return -EINVAL; |
| 13417 | } |
| 13418 | return(0); |
| 13419 | |
| 13420 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 13421 | static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13422 | u8 *peer, enum nl80211_tdls_operation oper) |
| 13423 | { |
| 13424 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13425 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13426 | int status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 13427 | hddTdlsPeer_t *pTdlsPeer; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 13428 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 13429 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 13430 | TRACE_CODE_HDD_CFG80211_TDLS_OPER, |
| 13431 | pAdapter->sessionId, oper)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13432 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13433 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 13434 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 13435 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13436 | return -EINVAL; |
| 13437 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 13438 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13439 | status = wlan_hdd_validate_context(pHddCtx); |
| 13440 | |
| 13441 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 13442 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13443 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13444 | "%s: HDD context is not valid", __func__); |
| 13445 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 13446 | } |
| 13447 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13448 | |
| 13449 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 13450 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13451 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 13452 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 13453 | "TDLS Disabled in INI OR not enabled in FW. " |
| 13454 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13455 | return -ENOTSUPP; |
| 13456 | } |
| 13457 | |
| 13458 | switch (oper) { |
| 13459 | case NL80211_TDLS_ENABLE_LINK: |
| 13460 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13461 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 13462 | long ret; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 13463 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13464 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13465 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 13466 | |
| 13467 | if ( NULL == pTdlsPeer ) { |
| 13468 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 13469 | " (oper %d) not exsting. ignored", |
| 13470 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 13471 | return -EINVAL; |
| 13472 | } |
| 13473 | |
| 13474 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13475 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 13476 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 13477 | "NL80211_TDLS_ENABLE_LINK"); |
| 13478 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 13479 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 13480 | { |
| 13481 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 13482 | MAC_ADDRESS_STR " failed", |
| 13483 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 13484 | return -EINVAL; |
| 13485 | } |
| 13486 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 13487 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13488 | { |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 13489 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 13490 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 13491 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 13492 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 13493 | return -EINVAL; |
| 13494 | } |
| 13495 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 13496 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 13497 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13498 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 13499 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 13500 | * register with the TL on after the response for this operation |
| 13501 | * is received . |
| 13502 | */ |
| 13503 | ret = wait_for_completion_interruptible_timeout( |
| 13504 | &pAdapter->tdls_link_establish_req_comp, |
| 13505 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 13506 | if (ret <= 0) |
| 13507 | { |
| 13508 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13509 | "%s: Link Establish Request Faled Status %ld", |
| 13510 | __func__, ret); |
| 13511 | return -EINVAL; |
| 13512 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 13513 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13514 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, |
| 13515 | eTDLS_LINK_CONNECTED, |
| 13516 | eTDLS_LINK_SUCCESS); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 13517 | /* Mark TDLS client Authenticated .*/ |
| 13518 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 13519 | pTdlsPeer->staId, |
| 13520 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 13521 | if (VOS_STATUS_SUCCESS == status) |
| 13522 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 13523 | if (pTdlsPeer->is_responder == 0) |
| 13524 | { |
| 13525 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 13526 | |
| 13527 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 13528 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 13529 | WAIT_TIME_TDLS_INITIATOR); |
| 13530 | /* suspend initiator TX until it receives direct packet from the |
| 13531 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 13532 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 13533 | &staId, NULL); |
| 13534 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 13535 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 13536 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13537 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 13538 | |
| 13539 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 13540 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 13541 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 13542 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 13543 | int ac; |
| 13544 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 13545 | WLANTL_AC_VI, |
| 13546 | WLANTL_AC_BK, |
| 13547 | WLANTL_AC_BE }; |
| 13548 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 13549 | for(ac=0; ac < 4; ac++) |
| 13550 | { |
| 13551 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 13552 | pTdlsPeer->staId, ucAc[ac], |
| 13553 | tlTid[ac], tlTid[ac], 0, 0, |
| 13554 | WLANTL_BI_DIR ); |
| 13555 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 13556 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13557 | } |
| 13558 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13559 | } |
| 13560 | break; |
| 13561 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13562 | { |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13563 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 13564 | |
| 13565 | if ( NULL == pTdlsPeer ) { |
| 13566 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 13567 | " (oper %d) not exsting. ignored", |
| 13568 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 13569 | return -EINVAL; |
| 13570 | } |
| 13571 | |
| 13572 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13573 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 13574 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 13575 | "NL80211_TDLS_DISABLE_LINK"); |
| 13576 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 13577 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13578 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 13579 | long status; |
| 13580 | |
| 13581 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 13582 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13583 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13584 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 13585 | |
| 13586 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 13587 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 13588 | if (status <= 0) |
| 13589 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13590 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, |
| 13591 | eTDLS_LINK_IDLE, |
| 13592 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 13593 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13594 | "%s: Del station failed status %ld", |
| 13595 | __func__, status); |
| 13596 | return -EPERM; |
| 13597 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13598 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, |
| 13599 | eTDLS_LINK_IDLE, |
| 13600 | eTDLS_LINK_UNSPECIFIED); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13601 | } |
| 13602 | else |
| 13603 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13604 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13605 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13606 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 13607 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 13608 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13609 | case NL80211_TDLS_TEARDOWN: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13610 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13611 | status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13612 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13613 | if (0 != status) |
| 13614 | { |
| 13615 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13616 | "%s: Error in TDLS Teardown", __func__); |
| 13617 | return status; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13618 | } |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13619 | break; |
| 13620 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13621 | case NL80211_TDLS_SETUP: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13622 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13623 | status = wlan_hdd_tdls_extctrl_config_peer(pAdapter, |
| 13624 | peer, |
| 13625 | NULL); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13626 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 13627 | if (0 != status) |
| 13628 | { |
| 13629 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13630 | "%s: Error in TDLS Setup", __func__); |
| 13631 | return status; |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 13632 | } |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 13633 | break; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 13634 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13635 | case NL80211_TDLS_DISCOVERY_REQ: |
| 13636 | /* We don't support in-driver setup/teardown/discovery */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 13637 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 13638 | "%s: We don't support in-driver setup/teardown/discovery " |
| 13639 | ,__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13640 | return -ENOTSUPP; |
| 13641 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 13642 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13643 | "%s: unsupported event",__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13644 | return -ENOTSUPP; |
| 13645 | } |
| 13646 | return 0; |
| 13647 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 13648 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 13649 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 13650 | u8 *peer, enum nl80211_tdls_operation oper) |
| 13651 | { |
| 13652 | int ret; |
| 13653 | |
| 13654 | vos_ssr_protect(__func__); |
| 13655 | ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper); |
| 13656 | vos_ssr_unprotect(__func__); |
| 13657 | |
| 13658 | return ret; |
| 13659 | } |
| 13660 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 13661 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 13662 | struct net_device *dev, u8 *peer) |
| 13663 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 13664 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 13665 | "tdls send discover req: "MAC_ADDRESS_STR, |
| 13666 | MAC_ADDR_ARRAY(peer)); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 13667 | |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 13668 | #if TDLS_MGMT_VERSION2 |
| 13669 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 13670 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0); |
| 13671 | #else |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 13672 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 13673 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 13674 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 13675 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 13676 | #endif |
| 13677 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13678 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 13679 | /* |
| 13680 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 13681 | * Callback rountine called upon receiving response for |
| 13682 | * get offload info |
| 13683 | */ |
| 13684 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 13685 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 13686 | { |
| 13687 | |
| 13688 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13689 | tANI_U8 tempReplayCounter[8]; |
| 13690 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13691 | |
| 13692 | ENTER(); |
| 13693 | |
| 13694 | if (NULL == pAdapter) |
| 13695 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 13696 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13697 | "%s: HDD adapter is Null", __func__); |
| 13698 | return ; |
| 13699 | } |
| 13700 | |
| 13701 | if (NULL == pGtkOffloadGetInfoRsp) |
| 13702 | { |
| 13703 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13704 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 13705 | return ; |
| 13706 | } |
| 13707 | |
| 13708 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 13709 | { |
| 13710 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13711 | "%s: wlan Failed to get replay counter value", |
| 13712 | __func__); |
| 13713 | return ; |
| 13714 | } |
| 13715 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13716 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 13717 | /* Update replay counter */ |
| 13718 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 13719 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 13720 | |
| 13721 | { |
| 13722 | /* changing from little to big endian since supplicant |
| 13723 | * works on big endian format |
| 13724 | */ |
| 13725 | int i; |
| 13726 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 13727 | |
| 13728 | for (i = 0; i < 8; i++) |
| 13729 | { |
| 13730 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 13731 | } |
| 13732 | } |
| 13733 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13734 | /* Update replay counter to NL */ |
| 13735 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13736 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13737 | } |
| 13738 | |
| 13739 | /* |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 13740 | * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13741 | * This function is used to offload GTK rekeying job to the firmware. |
| 13742 | */ |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 13743 | 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] | 13744 | struct cfg80211_gtk_rekey_data *data) |
| 13745 | { |
| 13746 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13747 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 13748 | hdd_station_ctx_t *pHddStaCtx; |
| 13749 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13750 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13751 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13752 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 13753 | |
| 13754 | ENTER(); |
| 13755 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 13756 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13757 | if (NULL == pAdapter) |
| 13758 | { |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 13759 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13760 | "%s: HDD adapter is Null", __func__); |
| 13761 | return -ENODEV; |
| 13762 | } |
| 13763 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 13764 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 13765 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
| 13766 | pAdapter->sessionId, pAdapter->device_mode)); |
| 13767 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13768 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13769 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13770 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13771 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 13772 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13773 | "%s: HDD context is not valid", __func__); |
| 13774 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13775 | } |
| 13776 | |
| 13777 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 13778 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 13779 | if (NULL == hHal) |
| 13780 | { |
| 13781 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13782 | "%s: HAL context is Null!!!", __func__); |
| 13783 | return -EAGAIN; |
| 13784 | } |
| 13785 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13786 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 13787 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 13788 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 13789 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13790 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13791 | { |
| 13792 | /* changing from big to little endian since driver |
| 13793 | * works on little endian format |
| 13794 | */ |
| 13795 | tANI_U8 *p = |
| 13796 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 13797 | int i; |
| 13798 | |
| 13799 | for (i = 0; i < 8; i++) |
| 13800 | { |
| 13801 | p[7-i] = data->replay_ctr[i]; |
| 13802 | } |
| 13803 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13804 | |
| 13805 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 13806 | { |
| 13807 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13808 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 13809 | sizeof (tSirGtkOffloadParams)); |
| 13810 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13811 | pAdapter->sessionId); |
| 13812 | |
| 13813 | if (eHAL_STATUS_SUCCESS != status) |
| 13814 | { |
| 13815 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13816 | "%s: sme_SetGTKOffload failed, returned %d", |
| 13817 | __func__, status); |
| 13818 | return status; |
| 13819 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13820 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13821 | "%s: sme_SetGTKOffload successfull", __func__); |
| 13822 | } |
| 13823 | else |
| 13824 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13825 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13826 | "%s: wlan not suspended GTKOffload request is stored", |
| 13827 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13828 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 13829 | |
| 13830 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13831 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 13832 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 13833 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 13834 | struct cfg80211_gtk_rekey_data *data) |
| 13835 | { |
| 13836 | int ret; |
| 13837 | |
| 13838 | vos_ssr_protect(__func__); |
| 13839 | ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data); |
| 13840 | vos_ssr_unprotect(__func__); |
| 13841 | |
| 13842 | return ret; |
| 13843 | } |
| 13844 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 13845 | /* |
| 13846 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 13847 | * This function is used to set access control policy |
| 13848 | */ |
| 13849 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 13850 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 13851 | { |
| 13852 | int i; |
| 13853 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13854 | hdd_hostapd_state_t *pHostapdState; |
| 13855 | tsap_Config_t *pConfig; |
| 13856 | v_CONTEXT_t pVosContext = NULL; |
| 13857 | hdd_context_t *pHddCtx; |
| 13858 | int status; |
| 13859 | |
| 13860 | ENTER(); |
| 13861 | |
| 13862 | if (NULL == pAdapter) |
| 13863 | { |
| 13864 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 13865 | "%s: HDD adapter is Null", __func__); |
| 13866 | return -ENODEV; |
| 13867 | } |
| 13868 | |
| 13869 | if (NULL == params) |
| 13870 | { |
| 13871 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 13872 | "%s: params is Null", __func__); |
| 13873 | return -EINVAL; |
| 13874 | } |
| 13875 | |
| 13876 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13877 | status = wlan_hdd_validate_context(pHddCtx); |
| 13878 | |
| 13879 | if (0 != status) |
| 13880 | { |
| 13881 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13882 | "%s: HDD context is not valid", __func__); |
| 13883 | return status; |
| 13884 | } |
| 13885 | |
| 13886 | pVosContext = pHddCtx->pvosContext; |
| 13887 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 13888 | |
| 13889 | if (NULL == pHostapdState) |
| 13890 | { |
| 13891 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 13892 | "%s: pHostapdState is Null", __func__); |
| 13893 | return -EINVAL; |
| 13894 | } |
| 13895 | |
| 13896 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 13897 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 13898 | |
| 13899 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 13900 | { |
| 13901 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 13902 | |
| 13903 | /* default value */ |
| 13904 | pConfig->num_accept_mac = 0; |
| 13905 | pConfig->num_deny_mac = 0; |
| 13906 | |
| 13907 | /** |
| 13908 | * access control policy |
| 13909 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 13910 | * listed in hostapd.deny file. |
| 13911 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 13912 | * listed in hostapd.accept file. |
| 13913 | */ |
| 13914 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 13915 | { |
| 13916 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 13917 | } |
| 13918 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 13919 | { |
| 13920 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 13921 | } |
| 13922 | else |
| 13923 | { |
| 13924 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13925 | "%s:Acl Policy : %d is not supported", |
| 13926 | __func__, params->acl_policy); |
| 13927 | return -ENOTSUPP; |
| 13928 | } |
| 13929 | |
| 13930 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 13931 | { |
| 13932 | pConfig->num_accept_mac = params->n_acl_entries; |
| 13933 | for (i = 0; i < params->n_acl_entries; i++) |
| 13934 | { |
| 13935 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13936 | "** Add ACL MAC entry %i in WhiletList :" |
| 13937 | MAC_ADDRESS_STR, i, |
| 13938 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 13939 | |
| 13940 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 13941 | sizeof(qcmacaddr)); |
| 13942 | } |
| 13943 | } |
| 13944 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 13945 | { |
| 13946 | pConfig->num_deny_mac = params->n_acl_entries; |
| 13947 | for (i = 0; i < params->n_acl_entries; i++) |
| 13948 | { |
| 13949 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13950 | "** Add ACL MAC entry %i in BlackList :" |
| 13951 | MAC_ADDRESS_STR, i, |
| 13952 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 13953 | |
| 13954 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 13955 | sizeof(qcmacaddr)); |
| 13956 | } |
| 13957 | } |
| 13958 | |
| 13959 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 13960 | { |
| 13961 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13962 | "%s: SAP Set Mac Acl fail", __func__); |
| 13963 | return -EINVAL; |
| 13964 | } |
| 13965 | } |
| 13966 | else |
| 13967 | { |
| 13968 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 13969 | "%s: Invalid device_mode = %s (%d)", |
| 13970 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 13971 | pAdapter->device_mode); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 13972 | return -EINVAL; |
| 13973 | } |
| 13974 | |
| 13975 | return 0; |
| 13976 | } |
| 13977 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 13978 | #ifdef WLAN_NL80211_TESTMODE |
| 13979 | #ifdef FEATURE_WLAN_LPHB |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 13980 | void wlan_hdd_cfg80211_lphb_ind_handler |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 13981 | ( |
| 13982 | void *pAdapter, |
| 13983 | void *indCont |
| 13984 | ) |
| 13985 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 13986 | tSirLPHBInd *lphbInd; |
| 13987 | struct sk_buff *skb; |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 13988 | hdd_context_t *pHddCtxt; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 13989 | |
| 13990 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 13991 | "LPHB indication arrived"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 13992 | |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 13993 | if (pAdapter == NULL) |
| 13994 | { |
| 13995 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13996 | "%s: pAdapter is NULL\n",__func__); |
| 13997 | return; |
| 13998 | } |
| 13999 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14000 | if (NULL == indCont) |
| 14001 | { |
| 14002 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14003 | "LPHB IND, invalid argument"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14004 | return; |
| 14005 | } |
| 14006 | |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 14007 | pHddCtxt = (hdd_context_t *)pAdapter; |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14008 | lphbInd = (tSirLPHBInd *)indCont; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14009 | skb = cfg80211_testmode_alloc_event_skb( |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 14010 | pHddCtxt->wiphy, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14011 | sizeof(tSirLPHBInd), |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14012 | GFP_ATOMIC); |
| 14013 | if (!skb) |
| 14014 | { |
| 14015 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14016 | "LPHB timeout, NL buffer alloc fail"); |
| 14017 | return; |
| 14018 | } |
| 14019 | |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 14020 | 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] | 14021 | { |
| 14022 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14023 | "WLAN_HDD_TM_ATTR_CMD put fail"); |
| 14024 | goto nla_put_failure; |
| 14025 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 14026 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14027 | { |
| 14028 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14029 | "WLAN_HDD_TM_ATTR_TYPE put fail"); |
| 14030 | goto nla_put_failure; |
| 14031 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 14032 | if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14033 | sizeof(tSirLPHBInd), lphbInd)) |
| 14034 | { |
| 14035 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14036 | "WLAN_HDD_TM_ATTR_DATA put fail"); |
| 14037 | goto nla_put_failure; |
| 14038 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14039 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 14040 | return; |
| 14041 | |
| 14042 | nla_put_failure: |
| 14043 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14044 | "NLA Put fail"); |
| 14045 | kfree_skb(skb); |
| 14046 | |
| 14047 | return; |
| 14048 | } |
| 14049 | #endif /* FEATURE_WLAN_LPHB */ |
| 14050 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 14051 | 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] | 14052 | { |
| 14053 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 14054 | int err = 0; |
| 14055 | #ifdef FEATURE_WLAN_LPHB |
| 14056 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14057 | eHalStatus smeStatus; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14058 | #endif /* FEATURE_WLAN_LPHB */ |
| 14059 | |
| 14060 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 14061 | if (err) |
| 14062 | { |
| 14063 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14064 | "%s Testmode INV ATTR", __func__); |
| 14065 | return err; |
| 14066 | } |
| 14067 | |
| 14068 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 14069 | { |
| 14070 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14071 | "%s Testmode INV CMD", __func__); |
| 14072 | return -EINVAL; |
| 14073 | } |
| 14074 | |
| 14075 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 14076 | { |
| 14077 | #ifdef FEATURE_WLAN_LPHB |
| 14078 | /* Low Power Heartbeat configuration request */ |
| 14079 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 14080 | { |
| 14081 | int buf_len; |
| 14082 | void *buf; |
| 14083 | tSirLPHBReq *hb_params = NULL; |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 14084 | tSirLPHBReq *hb_params_temp = NULL; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14085 | |
| 14086 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 14087 | { |
| 14088 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14089 | "%s Testmode INV DATA", __func__); |
| 14090 | return -EINVAL; |
| 14091 | } |
| 14092 | |
| 14093 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14094 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 14095 | |
| 14096 | hb_params_temp =(tSirLPHBReq *)buf; |
| 14097 | if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) && |
| 14098 | (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0)) |
| 14099 | return -EINVAL; |
| 14100 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14101 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 14102 | if (NULL == hb_params) |
| 14103 | { |
| 14104 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14105 | "%s Request Buffer Alloc Fail", __func__); |
| 14106 | return -EINVAL; |
| 14107 | } |
| 14108 | |
| 14109 | vos_mem_copy(hb_params, buf, buf_len); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14110 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 14111 | hb_params, |
| 14112 | wlan_hdd_cfg80211_lphb_ind_handler); |
| 14113 | if (eHAL_STATUS_SUCCESS != smeStatus) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14114 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 14115 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14116 | "LPHB Config Fail, disable"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14117 | vos_mem_free(hb_params); |
| 14118 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14119 | return 0; |
| 14120 | } |
| 14121 | #endif /* FEATURE_WLAN_LPHB */ |
| 14122 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 14123 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14124 | "%s: unsupported event",__func__); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14125 | return -EOPNOTSUPP; |
| 14126 | } |
| 14127 | |
| 14128 | return err; |
| 14129 | } |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 14130 | |
| 14131 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 14132 | { |
| 14133 | int ret; |
| 14134 | |
| 14135 | vos_ssr_protect(__func__); |
| 14136 | ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len); |
| 14137 | vos_ssr_unprotect(__func__); |
| 14138 | |
| 14139 | return ret; |
| 14140 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14141 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 14142 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 14143 | static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14144 | struct net_device *dev, |
| 14145 | int idx, struct survey_info *survey) |
| 14146 | { |
| 14147 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14148 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 14149 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14150 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 14151 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14152 | v_S7_t snr,rssi; |
| 14153 | int status, i, j, filled = 0; |
| 14154 | |
| 14155 | ENTER(); |
| 14156 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14157 | if (NULL == pAdapter) |
| 14158 | { |
| 14159 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14160 | "%s: HDD adapter is Null", __func__); |
| 14161 | return -ENODEV; |
| 14162 | } |
| 14163 | |
| 14164 | if (NULL == wiphy) |
| 14165 | { |
| 14166 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14167 | "%s: wiphy is Null", __func__); |
| 14168 | return -ENODEV; |
| 14169 | } |
| 14170 | |
| 14171 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14172 | status = wlan_hdd_validate_context(pHddCtx); |
| 14173 | |
| 14174 | if (0 != status) |
| 14175 | { |
| 14176 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14177 | "%s: HDD context is not valid", __func__); |
| 14178 | return status; |
| 14179 | } |
| 14180 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 14181 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14182 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14183 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 14184 | 0 != pAdapter->survey_idx || |
| 14185 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14186 | { |
| 14187 | /* The survey dump ops when implemented completely is expected to |
| 14188 | * return a survey of all channels and the ops is called by the |
| 14189 | * kernel with incremental values of the argument 'idx' till it |
| 14190 | * returns -ENONET. But we can only support the survey for the |
| 14191 | * operating channel for now. survey_idx is used to track |
| 14192 | * that the ops is called only once and then return -ENONET for |
| 14193 | * the next iteration |
| 14194 | */ |
| 14195 | pAdapter->survey_idx = 0; |
| 14196 | return -ENONET; |
| 14197 | } |
| 14198 | |
| 14199 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 14200 | |
| 14201 | wlan_hdd_get_snr(pAdapter, &snr); |
| 14202 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 14203 | |
| 14204 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 14205 | hdd_wlan_get_freq(channel, &freq); |
| 14206 | |
| 14207 | |
| 14208 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 14209 | { |
| 14210 | if (NULL == wiphy->bands[i]) |
| 14211 | { |
| 14212 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 14213 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 14214 | continue; |
| 14215 | } |
| 14216 | |
| 14217 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 14218 | { |
| 14219 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 14220 | |
| 14221 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 14222 | { |
| 14223 | survey->channel = &band->channels[j]; |
| 14224 | /* The Rx BDs contain SNR values in dB for the received frames |
| 14225 | * while the supplicant expects noise. So we calculate and |
| 14226 | * return the value of noise (dBm) |
| 14227 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 14228 | */ |
| 14229 | survey->noise = rssi - snr; |
| 14230 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 14231 | filled = 1; |
| 14232 | } |
| 14233 | } |
| 14234 | } |
| 14235 | |
| 14236 | if (filled) |
| 14237 | pAdapter->survey_idx = 1; |
| 14238 | else |
| 14239 | { |
| 14240 | pAdapter->survey_idx = 0; |
| 14241 | return -ENONET; |
| 14242 | } |
| 14243 | |
| 14244 | return 0; |
| 14245 | } |
| 14246 | |
Mahesh A Saptasagar | 2757407 | 2014-06-17 13:39:04 +0530 | [diff] [blame] | 14247 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 14248 | struct net_device *dev, |
| 14249 | int idx, struct survey_info *survey) |
| 14250 | { |
| 14251 | int ret; |
| 14252 | |
| 14253 | vos_ssr_protect(__func__); |
| 14254 | ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey); |
| 14255 | vos_ssr_unprotect(__func__); |
| 14256 | |
| 14257 | return ret; |
| 14258 | } |
| 14259 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14260 | /* |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 14261 | * FUNCTION: __wlan_hdd_cfg80211_resume_wlan |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14262 | * this is called when cfg80211 driver resume |
| 14263 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 14264 | */ |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 14265 | int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14266 | { |
| 14267 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 14268 | hdd_adapter_t *pAdapter; |
| 14269 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 14270 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 14271 | |
| 14272 | ENTER(); |
| 14273 | |
| 14274 | if ( NULL == pHddCtx ) |
| 14275 | { |
| 14276 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14277 | "%s: HddCtx validation failed", __func__); |
| 14278 | return 0; |
| 14279 | } |
| 14280 | |
| 14281 | if (pHddCtx->isLogpInProgress) |
| 14282 | { |
| 14283 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14284 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 14285 | return 0; |
| 14286 | } |
| 14287 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 14288 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14289 | { |
| 14290 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14291 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 14292 | return 0; |
| 14293 | } |
| 14294 | |
| 14295 | spin_lock(&pHddCtx->schedScan_lock); |
| 14296 | pHddCtx->isWiphySuspended = FALSE; |
| 14297 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 14298 | { |
| 14299 | spin_unlock(&pHddCtx->schedScan_lock); |
| 14300 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 14301 | "%s: Return resume is not due to PNO indication", __func__); |
| 14302 | return 0; |
| 14303 | } |
| 14304 | // Reset flag to avoid updatating cfg80211 data old results again |
| 14305 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 14306 | spin_unlock(&pHddCtx->schedScan_lock); |
| 14307 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 14308 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14309 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 14310 | |
| 14311 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 14312 | { |
| 14313 | pAdapter = pAdapterNode->pAdapter; |
| 14314 | if ( (NULL != pAdapter) && |
| 14315 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 14316 | { |
| 14317 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 14318 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14319 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 14320 | "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 14321 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14322 | else |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 14323 | { |
| 14324 | /* Acquire wakelock to handle the case where APP's tries to |
| 14325 | * suspend immediately after updating the scan results. Whis |
| 14326 | * results in app's is in suspended state and not able to |
| 14327 | * process the connect request to AP |
| 14328 | */ |
| 14329 | hdd_prevent_suspend_timeout(2000); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14330 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 14331 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14332 | |
| 14333 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 14334 | "%s : cfg80211 scan result database updated", __func__); |
| 14335 | |
| 14336 | return 0; |
| 14337 | |
| 14338 | } |
| 14339 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 14340 | pAdapterNode = pNext; |
| 14341 | } |
| 14342 | |
| 14343 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 14344 | "%s: Failed to find Adapter", __func__); |
| 14345 | return 0; |
| 14346 | } |
| 14347 | |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 14348 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 14349 | { |
| 14350 | int ret; |
| 14351 | |
| 14352 | vos_ssr_protect(__func__); |
| 14353 | ret = __wlan_hdd_cfg80211_resume_wlan(wiphy); |
| 14354 | vos_ssr_unprotect(__func__); |
| 14355 | |
| 14356 | return ret; |
| 14357 | } |
| 14358 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14359 | /* |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 14360 | * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14361 | * this is called when cfg80211 driver suspends |
| 14362 | */ |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 14363 | int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14364 | struct cfg80211_wowlan *wow) |
| 14365 | { |
| 14366 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 14367 | |
| 14368 | ENTER(); |
| 14369 | if (NULL == pHddCtx) |
| 14370 | { |
| 14371 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14372 | "%s: HddCtx validation failed", __func__); |
| 14373 | return 0; |
| 14374 | } |
| 14375 | |
| 14376 | pHddCtx->isWiphySuspended = TRUE; |
| 14377 | |
| 14378 | EXIT(); |
| 14379 | |
| 14380 | return 0; |
| 14381 | } |
| 14382 | |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 14383 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 14384 | struct cfg80211_wowlan *wow) |
| 14385 | { |
| 14386 | int ret; |
| 14387 | |
| 14388 | vos_ssr_protect(__func__); |
| 14389 | ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow); |
| 14390 | vos_ssr_unprotect(__func__); |
| 14391 | |
| 14392 | return ret; |
| 14393 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14394 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14395 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14396 | { |
| 14397 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 14398 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 14399 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 14400 | .change_station = wlan_hdd_change_station, |
| 14401 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 14402 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 14403 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 14404 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 14405 | #else |
| 14406 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 14407 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 14408 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14409 | #endif |
| 14410 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 14411 | .add_key = wlan_hdd_cfg80211_add_key, |
| 14412 | .get_key = wlan_hdd_cfg80211_get_key, |
| 14413 | .del_key = wlan_hdd_cfg80211_del_key, |
| 14414 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 14415 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14416 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 14417 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14418 | .scan = wlan_hdd_cfg80211_scan, |
| 14419 | .connect = wlan_hdd_cfg80211_connect, |
| 14420 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 14421 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 14422 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 14423 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 14424 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 14425 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14426 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 14427 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 14428 | .mgmt_tx = wlan_hdd_mgmt_tx, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14429 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 14430 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 14431 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 14432 | .set_txq_params = wlan_hdd_set_txq_params, |
| 14433 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14434 | .get_station = wlan_hdd_cfg80211_get_station, |
| 14435 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 14436 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 14437 | .add_station = wlan_hdd_cfg80211_add_station, |
| 14438 | #ifdef FEATURE_WLAN_LFR |
| 14439 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 14440 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 14441 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 14442 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 14443 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 14444 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 14445 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 14446 | #ifdef FEATURE_WLAN_TDLS |
| 14447 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 14448 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 14449 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 14450 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 14451 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 14452 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 14453 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 14454 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 14455 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 14456 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 14457 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 14458 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 14459 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 14460 | #ifdef WLAN_NL80211_TESTMODE |
| 14461 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 14462 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 14463 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14464 | }; |
| 14465 | |