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 | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 23 | * Copyright (c) 2012-2014 Qualcomm Atheros, Inc. |
| 24 | * All Rights Reserved. |
| 25 | * Qualcomm Atheros Confidential and Proprietary. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 26 | * |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 27 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 28 | |
| 29 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 30 | /**======================================================================== |
| 31 | |
| 32 | \file wlan_hdd_cfg80211.c |
| 33 | |
| 34 | \brief WLAN Host Device Driver implementation |
| 35 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 36 | ========================================================================*/ |
| 37 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 38 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 39 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 40 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | |
| 42 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 43 | This section contains comments describing changes made to the module. |
| 44 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 45 | |
| 46 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 47 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 48 | |
| 49 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 50 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 51 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 52 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 53 | |
| 54 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 55 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 56 | ==========================================================================*/ |
| 57 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 58 | |
| 59 | #include <linux/version.h> |
| 60 | #include <linux/module.h> |
| 61 | #include <linux/kernel.h> |
| 62 | #include <linux/init.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <wlan_hdd_includes.h> |
| 65 | #include <net/arp.h> |
| 66 | #include <net/cfg80211.h> |
| 67 | #include <linux/wireless.h> |
| 68 | #include <wlan_hdd_wowl.h> |
| 69 | #include <aniGlobal.h> |
| 70 | #include "ccmApi.h" |
| 71 | #include "sirParams.h" |
| 72 | #include "dot11f.h" |
| 73 | #include "wlan_hdd_assoc.h" |
| 74 | #include "wlan_hdd_wext.h" |
| 75 | #include "sme_Api.h" |
| 76 | #include "wlan_hdd_p2p.h" |
| 77 | #include "wlan_hdd_cfg80211.h" |
| 78 | #include "wlan_hdd_hostapd.h" |
| 79 | #include "sapInternal.h" |
| 80 | #include "wlan_hdd_softap_tx_rx.h" |
| 81 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 82 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 83 | #include "wlan_hdd_power.h" |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 84 | #include "wlan_hdd_trace.h" |
| 85 | #include "vos_types.h" |
| 86 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 87 | #ifdef WLAN_BTAMP_FEATURE |
| 88 | #include "bap_hdd_misc.h" |
| 89 | #endif |
| 90 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 91 | #ifdef FEATURE_WLAN_TDLS |
| 92 | #include "wlan_hdd_tdls.h" |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 93 | #include "wlan_hdd_wmm.h" |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 94 | #include "wlan_qct_wda.h" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 95 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 96 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 97 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 98 | |
| 99 | #define g_mode_rates_size (12) |
| 100 | #define a_mode_rates_size (8) |
| 101 | #define FREQ_BASE_80211G (2407) |
| 102 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 103 | #define MAX_SCAN_SSID 9 |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 104 | #define MAX_PENDING_LOG 5 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 105 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
krunal soni | 2a6a906 | 2014-02-11 14:14:23 -0800 | [diff] [blame] | 106 | ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 107 | |
| 108 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 109 | .band = IEEE80211_BAND_2GHZ, \ |
| 110 | .center_freq = (freq), \ |
| 111 | .hw_value = (chan),\ |
| 112 | .flags = (flag), \ |
| 113 | .max_antenna_gain = 0 ,\ |
| 114 | .max_power = 30, \ |
| 115 | } |
| 116 | |
| 117 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 118 | .band = IEEE80211_BAND_5GHZ, \ |
| 119 | .center_freq = (freq), \ |
| 120 | .hw_value = (chan),\ |
| 121 | .flags = (flag), \ |
| 122 | .max_antenna_gain = 0 ,\ |
| 123 | .max_power = 30, \ |
| 124 | } |
| 125 | |
| 126 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 127 | {\ |
| 128 | .bitrate = rate, \ |
| 129 | .hw_value = rate_id, \ |
| 130 | .flags = flag, \ |
| 131 | } |
| 132 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 133 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 134 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 135 | #else |
| 136 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 137 | #endif |
| 138 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 139 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 140 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 141 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 142 | #endif |
| 143 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 144 | #define HDD_CHANNEL_14 14 |
| 145 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 146 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 147 | /* |
| 148 | * Used to allocate the size of 4096 for the link layer stats. |
| 149 | * The size of 4096 is considered assuming that all data per |
| 150 | * respective event fit with in the limit.Please take a call |
| 151 | * on the limit based on the data requirements on link layer |
| 152 | * statistics. |
| 153 | */ |
| 154 | #define LL_STATS_EVENT_BUF_SIZE 4096 |
| 155 | #endif |
| 156 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 157 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 158 | { |
| 159 | WLAN_CIPHER_SUITE_WEP40, |
| 160 | WLAN_CIPHER_SUITE_WEP104, |
| 161 | WLAN_CIPHER_SUITE_TKIP, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 162 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 163 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 164 | WLAN_CIPHER_SUITE_KRK, |
| 165 | WLAN_CIPHER_SUITE_CCMP, |
| 166 | #else |
| 167 | WLAN_CIPHER_SUITE_CCMP, |
| 168 | #endif |
| 169 | #ifdef FEATURE_WLAN_WAPI |
| 170 | WLAN_CIPHER_SUITE_SMS4, |
| 171 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 172 | #ifdef WLAN_FEATURE_11W |
| 173 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 174 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 178 | { |
| 179 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 180 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 181 | } |
| 182 | |
| 183 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 184 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 185 | HDD2GHZCHAN(2412, 1, 0) , |
| 186 | HDD2GHZCHAN(2417, 2, 0) , |
| 187 | HDD2GHZCHAN(2422, 3, 0) , |
| 188 | HDD2GHZCHAN(2427, 4, 0) , |
| 189 | HDD2GHZCHAN(2432, 5, 0) , |
| 190 | HDD2GHZCHAN(2437, 6, 0) , |
| 191 | HDD2GHZCHAN(2442, 7, 0) , |
| 192 | HDD2GHZCHAN(2447, 8, 0) , |
| 193 | HDD2GHZCHAN(2452, 9, 0) , |
| 194 | HDD2GHZCHAN(2457, 10, 0) , |
| 195 | HDD2GHZCHAN(2462, 11, 0) , |
| 196 | HDD2GHZCHAN(2467, 12, 0) , |
| 197 | HDD2GHZCHAN(2472, 13, 0) , |
| 198 | HDD2GHZCHAN(2484, 14, 0) , |
| 199 | }; |
| 200 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 201 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 202 | { |
| 203 | HDD2GHZCHAN(2412, 1, 0) , |
| 204 | HDD2GHZCHAN(2437, 6, 0) , |
| 205 | HDD2GHZCHAN(2462, 11, 0) , |
| 206 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 207 | |
| 208 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 209 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 210 | HDD5GHZCHAN(4920, 240, 0) , |
| 211 | HDD5GHZCHAN(4940, 244, 0) , |
| 212 | HDD5GHZCHAN(4960, 248, 0) , |
| 213 | HDD5GHZCHAN(4980, 252, 0) , |
| 214 | HDD5GHZCHAN(5040, 208, 0) , |
| 215 | HDD5GHZCHAN(5060, 212, 0) , |
| 216 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 217 | HDD5GHZCHAN(5180, 36, 0) , |
| 218 | HDD5GHZCHAN(5200, 40, 0) , |
| 219 | HDD5GHZCHAN(5220, 44, 0) , |
| 220 | HDD5GHZCHAN(5240, 48, 0) , |
| 221 | HDD5GHZCHAN(5260, 52, 0) , |
| 222 | HDD5GHZCHAN(5280, 56, 0) , |
| 223 | HDD5GHZCHAN(5300, 60, 0) , |
| 224 | HDD5GHZCHAN(5320, 64, 0) , |
| 225 | HDD5GHZCHAN(5500,100, 0) , |
| 226 | HDD5GHZCHAN(5520,104, 0) , |
| 227 | HDD5GHZCHAN(5540,108, 0) , |
| 228 | HDD5GHZCHAN(5560,112, 0) , |
| 229 | HDD5GHZCHAN(5580,116, 0) , |
| 230 | HDD5GHZCHAN(5600,120, 0) , |
| 231 | HDD5GHZCHAN(5620,124, 0) , |
| 232 | HDD5GHZCHAN(5640,128, 0) , |
| 233 | HDD5GHZCHAN(5660,132, 0) , |
| 234 | HDD5GHZCHAN(5680,136, 0) , |
| 235 | HDD5GHZCHAN(5700,140, 0) , |
Leo Chang | 80de3c2 | 2013-11-26 10:52:12 -0800 | [diff] [blame] | 236 | #ifdef FEATURE_WLAN_CH144 |
| 237 | HDD5GHZCHAN(5720,144, 0) , |
| 238 | #endif /* FEATURE_WLAN_CH144 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | HDD5GHZCHAN(5745,149, 0) , |
| 240 | HDD5GHZCHAN(5765,153, 0) , |
| 241 | HDD5GHZCHAN(5785,157, 0) , |
| 242 | HDD5GHZCHAN(5805,161, 0) , |
| 243 | HDD5GHZCHAN(5825,165, 0) , |
| 244 | }; |
| 245 | |
| 246 | static struct ieee80211_rate g_mode_rates[] = |
| 247 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 248 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 249 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 250 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 251 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 252 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 253 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 254 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 255 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 256 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 257 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 258 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 259 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 260 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | |
| 262 | static struct ieee80211_rate a_mode_rates[] = |
| 263 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 264 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 265 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 266 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 267 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 268 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 269 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 270 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 271 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 272 | }; |
| 273 | |
| 274 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 275 | { |
| 276 | .channels = hdd_channels_2_4_GHZ, |
| 277 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 278 | .band = IEEE80211_BAND_2GHZ, |
| 279 | .bitrates = g_mode_rates, |
| 280 | .n_bitrates = g_mode_rates_size, |
| 281 | .ht_cap.ht_supported = 1, |
| 282 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 283 | | IEEE80211_HT_CAP_GRN_FLD |
| 284 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 285 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 286 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 287 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 288 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 289 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 290 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 291 | }; |
| 292 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 293 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 294 | { |
| 295 | .channels = hdd_social_channels_2_4_GHZ, |
| 296 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 297 | .band = IEEE80211_BAND_2GHZ, |
| 298 | .bitrates = g_mode_rates, |
| 299 | .n_bitrates = g_mode_rates_size, |
| 300 | .ht_cap.ht_supported = 1, |
| 301 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 302 | | IEEE80211_HT_CAP_GRN_FLD |
| 303 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 304 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 305 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 306 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 307 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 308 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 309 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 310 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | |
| 312 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 313 | { |
| 314 | .channels = hdd_channels_5_GHZ, |
| 315 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 316 | .band = IEEE80211_BAND_5GHZ, |
| 317 | .bitrates = a_mode_rates, |
| 318 | .n_bitrates = a_mode_rates_size, |
| 319 | .ht_cap.ht_supported = 1, |
| 320 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 321 | | IEEE80211_HT_CAP_GRN_FLD |
| 322 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 323 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 324 | | IEEE80211_HT_CAP_SGI_40 |
| 325 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 326 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 327 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 328 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 329 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 330 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 331 | }; |
| 332 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 333 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 334 | TX/RX direction for each kind of interface */ |
| 335 | static const struct ieee80211_txrx_stypes |
| 336 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 337 | [NL80211_IFTYPE_STATION] = { |
| 338 | .tx = 0xffff, |
| 339 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 340 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 341 | }, |
| 342 | [NL80211_IFTYPE_AP] = { |
| 343 | .tx = 0xffff, |
| 344 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 345 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 346 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 347 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 348 | BIT(SIR_MAC_MGMT_AUTH) | |
| 349 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 350 | BIT(SIR_MAC_MGMT_ACTION), |
| 351 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 352 | [NL80211_IFTYPE_ADHOC] = { |
| 353 | .tx = 0xffff, |
| 354 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 355 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 356 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 357 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 358 | BIT(SIR_MAC_MGMT_AUTH) | |
| 359 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 360 | BIT(SIR_MAC_MGMT_ACTION), |
| 361 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 362 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 363 | .tx = 0xffff, |
| 364 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 365 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 366 | }, |
| 367 | [NL80211_IFTYPE_P2P_GO] = { |
| 368 | /* This is also same as for SoftAP */ |
| 369 | .tx = 0xffff, |
| 370 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 371 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 372 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 373 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 374 | BIT(SIR_MAC_MGMT_AUTH) | |
| 375 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 376 | BIT(SIR_MAC_MGMT_ACTION), |
| 377 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 378 | }; |
| 379 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 380 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 381 | static const struct ieee80211_iface_limit |
| 382 | wlan_hdd_iface_limit[] = { |
| 383 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 384 | /* max = 3 ; Our driver create two interfaces during driver init |
| 385 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 386 | * interface until a group is formed. In JB architecture, once the |
| 387 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 388 | * Client. |
| 389 | * When supplicant remove the group, it first issue a set interface |
| 390 | * cmd to change the mode back to Station. In JB this works fine as |
| 391 | * we advertize two station type interface during driver init. |
| 392 | * Some vendors create separate interface for P2P GO/Client, |
| 393 | * after group formation(Third one). But while group remove |
| 394 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 395 | * But as we advertized only two sta type interfaces nl80211 was |
| 396 | * returning error for the third one which was leading to failure in |
| 397 | * delete interface. Ideally while removing the group, supplicant |
| 398 | * should not try to change the 3rd interface mode to Station type. |
| 399 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 400 | * interface type to 3 |
| 401 | */ |
| 402 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 403 | .types = BIT(NL80211_IFTYPE_STATION), |
| 404 | }, |
| 405 | { |
| 406 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 407 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 408 | }, |
| 409 | { |
| 410 | .max = 1, |
| 411 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 412 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 413 | }, |
| 414 | }; |
| 415 | |
| 416 | /* By default, only single channel concurrency is allowed */ |
| 417 | static struct ieee80211_iface_combination |
| 418 | wlan_hdd_iface_combination = { |
| 419 | .limits = wlan_hdd_iface_limit, |
| 420 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 421 | /* |
| 422 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 423 | * and p2p0 interfaces during driver init |
| 424 | * Some vendors create separate interface for P2P operations. |
| 425 | * wlan0: STA interface |
| 426 | * p2p0: P2P Device interface, action frames goes |
| 427 | * through this interface. |
| 428 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 429 | * created for p2p operations(GO/CLIENT interface). |
| 430 | */ |
| 431 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 432 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 433 | .beacon_int_infra_match = false, |
| 434 | }; |
| 435 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 436 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 437 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 438 | |
| 439 | /* Data rate 100KBPS based on IE Index */ |
| 440 | struct index_data_rate_type |
| 441 | { |
| 442 | v_U8_t beacon_rate_index; |
| 443 | v_U16_t supported_rate[4]; |
| 444 | }; |
| 445 | |
| 446 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 447 | The IDX field is the rate index |
| 448 | The HI field is the rate when RSSI is strong or being ignored |
| 449 | (in this case we report actual rate) |
| 450 | The MID field is the rate when RSSI is moderate |
| 451 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 452 | The LO field is the rate when RSSI is low |
| 453 | (in this case we don't report rates, actual current rate used) |
| 454 | */ |
| 455 | static const struct |
| 456 | { |
| 457 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 458 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | } supported_data_rate[] = |
| 460 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 461 | /* IDX HI HM LM LO (RSSI-based index */ |
| 462 | {2, { 10, 10, 10, 0}}, |
| 463 | {4, { 20, 20, 10, 0}}, |
| 464 | {11, { 55, 20, 10, 0}}, |
| 465 | {12, { 60, 55, 20, 0}}, |
| 466 | {18, { 90, 55, 20, 0}}, |
| 467 | {22, {110, 55, 20, 0}}, |
| 468 | {24, {120, 90, 60, 0}}, |
| 469 | {36, {180, 120, 60, 0}}, |
| 470 | {44, {220, 180, 60, 0}}, |
| 471 | {48, {240, 180, 90, 0}}, |
| 472 | {66, {330, 180, 90, 0}}, |
| 473 | {72, {360, 240, 90, 0}}, |
| 474 | {96, {480, 240, 120, 0}}, |
| 475 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 476 | }; |
| 477 | |
| 478 | /* MCS Based rate table */ |
| 479 | static struct index_data_rate_type supported_mcs_rate[] = |
| 480 | { |
| 481 | /* MCS L20 L40 S20 S40 */ |
| 482 | {0, {65, 135, 72, 150}}, |
| 483 | {1, {130, 270, 144, 300}}, |
| 484 | {2, {195, 405, 217, 450}}, |
| 485 | {3, {260, 540, 289, 600}}, |
| 486 | {4, {390, 810, 433, 900}}, |
| 487 | {5, {520, 1080, 578, 1200}}, |
| 488 | {6, {585, 1215, 650, 1350}}, |
| 489 | {7, {650, 1350, 722, 1500}} |
| 490 | }; |
| 491 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 492 | #ifdef WLAN_FEATURE_11AC |
| 493 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 494 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 495 | |
| 496 | struct index_vht_data_rate_type |
| 497 | { |
| 498 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 499 | v_U16_t supported_VHT80_rate[2]; |
| 500 | v_U16_t supported_VHT40_rate[2]; |
| 501 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 502 | }; |
| 503 | |
| 504 | typedef enum |
| 505 | { |
| 506 | DATA_RATE_11AC_MAX_MCS_7, |
| 507 | DATA_RATE_11AC_MAX_MCS_8, |
| 508 | DATA_RATE_11AC_MAX_MCS_9, |
| 509 | DATA_RATE_11AC_MAX_MCS_NA |
| 510 | } eDataRate11ACMaxMcs; |
| 511 | |
| 512 | /* MCS Based VHT rate table */ |
| 513 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 514 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 515 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 516 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 517 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 518 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 519 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 520 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 521 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 522 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 523 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 524 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 525 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 526 | }; |
| 527 | #endif /* WLAN_FEATURE_11AC */ |
| 528 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 529 | extern struct net_device_ops net_ops_struct; |
| 530 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 531 | #ifdef WLAN_NL80211_TESTMODE |
| 532 | enum wlan_hdd_tm_attr |
| 533 | { |
| 534 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 535 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 536 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 537 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 538 | /* keep last */ |
| 539 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 540 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 541 | }; |
| 542 | |
| 543 | enum wlan_hdd_tm_cmd |
| 544 | { |
| 545 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 546 | }; |
| 547 | |
| 548 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 549 | |
| 550 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 551 | { |
| 552 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 553 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 554 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 555 | }; |
| 556 | #endif /* WLAN_NL80211_TESTMODE */ |
| 557 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 558 | #ifdef FEATURE_WLAN_CH_AVOID |
| 559 | /* |
| 560 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 561 | * This is called when wlan driver needs to send vendor specific |
| 562 | * avoid frequency range event to userspace |
| 563 | */ |
| 564 | int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx, |
| 565 | tHddAvoidFreqList *pAvoidFreqList) |
| 566 | { |
| 567 | struct sk_buff *vendor_event; |
| 568 | |
| 569 | ENTER(); |
| 570 | |
| 571 | if (!pHddCtx) |
| 572 | { |
| 573 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 574 | "%s: HDD context is null", __func__); |
| 575 | return -1; |
| 576 | } |
| 577 | |
| 578 | if (!pAvoidFreqList) |
| 579 | { |
| 580 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 581 | "%s: pAvoidFreqList is null", __func__); |
| 582 | return -1; |
| 583 | } |
| 584 | |
| 585 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 586 | sizeof(tHddAvoidFreqList), |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 587 | QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 588 | GFP_KERNEL); |
| 589 | if (!vendor_event) |
| 590 | { |
| 591 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 592 | "%s: cfg80211_vendor_event_alloc failed", __func__); |
| 593 | return -1; |
| 594 | } |
| 595 | |
| 596 | memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)), |
| 597 | (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList)); |
| 598 | |
| 599 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 600 | |
| 601 | EXIT(); |
| 602 | return 0; |
| 603 | } |
| 604 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 605 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 606 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 607 | |
| 608 | static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats, |
| 609 | struct sk_buff *vendor_event) |
| 610 | { |
| 611 | if (nla_put_u8(vendor_event, |
| 612 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE, |
| 613 | stats->rate.preamble) || |
| 614 | nla_put_u8(vendor_event, |
| 615 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS, |
| 616 | stats->rate.nss) || |
| 617 | nla_put_u8(vendor_event, |
| 618 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW, |
| 619 | stats->rate.bw) || |
| 620 | nla_put_u8(vendor_event, |
| 621 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX, |
| 622 | stats->rate.rateMcsIdx) || |
| 623 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE, |
| 624 | stats->rate.bitrate ) || |
| 625 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU, |
| 626 | stats->txMpdu ) || |
| 627 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU, |
| 628 | stats->rxMpdu ) || |
| 629 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST, |
| 630 | stats->mpduLost ) || |
| 631 | nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES, |
| 632 | stats->retries) || |
| 633 | nla_put_u32(vendor_event, |
| 634 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT, |
| 635 | stats->retriesShort ) || |
| 636 | nla_put_u32(vendor_event, |
| 637 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG, |
| 638 | stats->retriesLong)) |
| 639 | { |
| 640 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 641 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 642 | return FALSE; |
| 643 | } |
| 644 | return TRUE; |
| 645 | } |
| 646 | |
| 647 | static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats, |
| 648 | struct sk_buff *vendor_event) |
| 649 | { |
| 650 | u32 i = 0; |
| 651 | struct nlattr *rateInfo; |
| 652 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE, |
| 653 | stats->type) || |
| 654 | nla_put(vendor_event, |
| 655 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS, |
| 656 | VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) || |
| 657 | nla_put_u32(vendor_event, |
| 658 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES, |
| 659 | stats->capabilities) || |
| 660 | nla_put_u32(vendor_event, |
| 661 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES, |
| 662 | stats->numRate)) |
| 663 | { |
| 664 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 665 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 666 | goto error; |
| 667 | } |
| 668 | |
| 669 | rateInfo = nla_nest_start(vendor_event, |
| 670 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO); |
| 671 | for (i = 0; i < stats->numRate; i++) |
| 672 | { |
| 673 | struct nlattr *rates; |
| 674 | tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *) |
| 675 | stats->rateStats + |
| 676 | (i * sizeof(tSirWifiRateStat))); |
| 677 | rates = nla_nest_start(vendor_event, i); |
| 678 | |
| 679 | if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event)) |
| 680 | { |
| 681 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 682 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 683 | return FALSE; |
| 684 | } |
| 685 | nla_nest_end(vendor_event, rates); |
| 686 | } |
| 687 | nla_nest_end(vendor_event, rateInfo); |
| 688 | |
| 689 | return TRUE; |
| 690 | error: |
| 691 | return FALSE; |
| 692 | } |
| 693 | |
| 694 | static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats, |
| 695 | struct sk_buff *vendor_event) |
| 696 | { |
| 697 | if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC, |
| 698 | stats->ac ) || |
| 699 | nla_put_u32(vendor_event, |
| 700 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU, |
| 701 | stats->txMpdu ) || |
| 702 | nla_put_u32(vendor_event, |
| 703 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU, |
| 704 | stats->rxMpdu ) || |
| 705 | nla_put_u32(vendor_event, |
| 706 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST, |
| 707 | stats->txMcast ) || |
| 708 | nla_put_u32(vendor_event, |
| 709 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST, |
| 710 | stats->rxMcast ) || |
| 711 | nla_put_u32(vendor_event, |
| 712 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU, |
| 713 | stats->rxAmpdu ) || |
| 714 | nla_put_u32(vendor_event, |
| 715 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU, |
| 716 | stats->txAmpdu ) || |
| 717 | nla_put_u32(vendor_event, |
| 718 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST, |
| 719 | stats->mpduLost )|| |
| 720 | nla_put_u32(vendor_event, |
| 721 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES, |
| 722 | stats->retries ) || |
| 723 | nla_put_u32(vendor_event, |
| 724 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT, |
| 725 | stats->retriesShort ) || |
| 726 | nla_put_u32(vendor_event, |
| 727 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG, |
| 728 | stats->retriesLong ) || |
| 729 | nla_put_u32(vendor_event, |
| 730 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN, |
| 731 | stats->contentionTimeMin ) || |
| 732 | nla_put_u32(vendor_event, |
| 733 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX, |
| 734 | stats->contentionTimeMax ) || |
| 735 | nla_put_u32(vendor_event, |
| 736 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG, |
| 737 | stats->contentionTimeAvg ) || |
| 738 | nla_put_u32(vendor_event, |
| 739 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES, |
| 740 | stats->contentionNumSamples )) |
| 741 | { |
| 742 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 743 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 744 | return FALSE; |
| 745 | } |
| 746 | return TRUE; |
| 747 | } |
| 748 | |
| 749 | static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats, |
| 750 | struct sk_buff *vendor_event) |
| 751 | { |
| 752 | if (nla_put_u32(vendor_event, |
| 753 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) || |
| 754 | nla_put(vendor_event, |
| 755 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR, |
| 756 | VOS_MAC_ADDR_SIZE, stats->macAddr) || |
| 757 | nla_put_u32(vendor_event, |
| 758 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE, |
| 759 | stats->state ) || |
| 760 | nla_put_u32(vendor_event, |
| 761 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING, |
| 762 | stats->roaming ) || |
| 763 | nla_put_u32(vendor_event, |
| 764 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES, |
| 765 | stats->capabilities ) || |
| 766 | nla_put(vendor_event, |
| 767 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID, |
| 768 | strlen(stats->ssid), stats->ssid) || |
| 769 | nla_put(vendor_event, |
| 770 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID, |
| 771 | WNI_CFG_BSSID_LEN, stats->bssid) || |
| 772 | nla_put(vendor_event, |
| 773 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR, |
| 774 | WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) || |
| 775 | nla_put(vendor_event, |
| 776 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR, |
| 777 | WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr) |
| 778 | ) |
| 779 | { |
| 780 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 781 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 782 | return FALSE; |
| 783 | } |
| 784 | return TRUE; |
| 785 | } |
| 786 | |
| 787 | static v_BOOL_t put_wifi_iface_stats(tpSirWifiIfaceStat pWifiIfaceStat, |
| 788 | struct sk_buff *vendor_event) |
| 789 | { |
| 790 | int i = 0; |
| 791 | struct nlattr *wmmInfo; |
| 792 | if (FALSE == put_wifi_interface_info( |
| 793 | &pWifiIfaceStat->info, |
| 794 | vendor_event)) |
| 795 | { |
| 796 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 797 | FL("QCA_WLAN_VENDOR_ATTR put fail") ); |
| 798 | return FALSE; |
| 799 | |
| 800 | } |
| 801 | |
| 802 | if (nla_put_u32(vendor_event, |
| 803 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX, |
| 804 | pWifiIfaceStat->beaconRx) || |
| 805 | nla_put_u32(vendor_event, |
| 806 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX, |
| 807 | pWifiIfaceStat->mgmtRx) || |
| 808 | nla_put_u32(vendor_event, |
| 809 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX, |
| 810 | pWifiIfaceStat->mgmtActionRx) || |
| 811 | nla_put_u32(vendor_event, |
| 812 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX, |
| 813 | pWifiIfaceStat->mgmtActionTx) || |
| 814 | nla_put_u32(vendor_event, |
| 815 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT, |
| 816 | pWifiIfaceStat->rssiMgmt) || |
| 817 | nla_put_u32(vendor_event, |
| 818 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA, |
| 819 | pWifiIfaceStat->rssiData) || |
| 820 | nla_put_u32(vendor_event, |
| 821 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK, |
| 822 | pWifiIfaceStat->rssiAck)) |
| 823 | { |
| 824 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 825 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 826 | return FALSE; |
| 827 | } |
| 828 | |
| 829 | wmmInfo = nla_nest_start(vendor_event, |
| 830 | QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO); |
| 831 | for (i = 0; i < WIFI_AC_MAX; i++) |
| 832 | { |
| 833 | struct nlattr *wmmStats; |
| 834 | wmmStats = nla_nest_start(vendor_event, i); |
| 835 | if (FALSE == put_wifi_wmm_ac_stat( |
| 836 | &pWifiIfaceStat->AccessclassStats[i], |
| 837 | vendor_event)) |
| 838 | { |
| 839 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 840 | FL("QCA_WLAN_VENDOR_ATTR put Fail")); |
| 841 | return FALSE; |
| 842 | } |
| 843 | |
| 844 | nla_nest_end(vendor_event, wmmStats); |
| 845 | } |
| 846 | nla_nest_end(vendor_event, wmmInfo); |
| 847 | return TRUE; |
| 848 | } |
| 849 | |
| 850 | static tSirWifiInterfaceMode |
| 851 | hdd_map_device_to_ll_iface_mode ( int deviceMode ) |
| 852 | { |
| 853 | switch (deviceMode) |
| 854 | { |
| 855 | case WLAN_HDD_INFRA_STATION: |
| 856 | return WIFI_INTERFACE_STA; |
| 857 | case WLAN_HDD_SOFTAP: |
| 858 | return WIFI_INTERFACE_SOFTAP; |
| 859 | case WLAN_HDD_P2P_CLIENT: |
| 860 | return WIFI_INTERFACE_P2P_CLIENT; |
| 861 | case WLAN_HDD_P2P_GO: |
| 862 | return WIFI_INTERFACE_P2P_GO; |
| 863 | case WLAN_HDD_IBSS: |
| 864 | return WIFI_INTERFACE_IBSS; |
| 865 | default: |
| 866 | /* Return Interface Mode as STA for all the unsupported modes */ |
| 867 | return WIFI_INTERFACE_STA; |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter, |
| 872 | tpSirWifiInterfaceInfo pInfo) |
| 873 | { |
| 874 | v_U8_t *staMac = NULL; |
| 875 | hdd_station_ctx_t *pHddStaCtx; |
| 876 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 877 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
| 878 | |
| 879 | pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode); |
| 880 | |
| 881 | vos_mem_copy(pInfo->macAddr, |
| 882 | pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
| 883 | |
| 884 | if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 885 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 886 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))) |
| 887 | { |
| 888 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 889 | if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) |
| 890 | { |
| 891 | pInfo->state = WIFI_DISCONNECTED; |
| 892 | } |
| 893 | if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) |
| 894 | { |
| 895 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 896 | "%s: Session ID %d, Connection is in progress", __func__, |
| 897 | pAdapter->sessionId); |
| 898 | pInfo->state = WIFI_ASSOCIATING; |
| 899 | } |
| 900 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 901 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 902 | { |
| 903 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 904 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 905 | "%s: client " MAC_ADDRESS_STR |
| 906 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 907 | MAC_ADDR_ARRAY(staMac)); |
| 908 | pInfo->state = WIFI_AUTHENTICATING; |
| 909 | } |
| 910 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 911 | { |
| 912 | pInfo->state = WIFI_ASSOCIATED; |
| 913 | vos_mem_copy(pInfo->bssid, |
| 914 | &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN); |
| 915 | vos_mem_copy(pInfo->ssid, |
| 916 | pHddStaCtx->conn_info.SSID.SSID.ssId, |
| 917 | pHddStaCtx->conn_info.SSID.SSID.length); |
| 918 | //NULL Terminate the string. |
| 919 | pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0; |
| 920 | } |
| 921 | } |
| 922 | vos_mem_copy(pInfo->countryStr, |
| 923 | pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN); |
| 924 | |
| 925 | vos_mem_copy(pInfo->apCountryStr, |
| 926 | pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN); |
| 927 | |
| 928 | return TRUE; |
| 929 | } |
| 930 | |
| 931 | /* |
| 932 | * hdd_link_layer_process_peer_stats () - This function is called after |
| 933 | * receiving Link Layer Peer statistics from FW.This function converts |
| 934 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 935 | * layers. |
| 936 | */ |
| 937 | static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter, |
| 938 | v_VOID_t *pData) |
| 939 | { |
| 940 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 941 | tpSirWifiRateStat pWifiRateStat; |
| 942 | tpSirWifiPeerStat pWifiPeerStat; |
| 943 | tpSirWifiPeerInfo pWifiPeerInfo; |
| 944 | struct nlattr *peerInfo; |
| 945 | struct sk_buff *vendor_event; |
| 946 | int status, i; |
| 947 | |
| 948 | status = wlan_hdd_validate_context(pHddCtx); |
| 949 | if (0 != status) |
| 950 | { |
| 951 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 952 | FL("HDD context is not valid") ); |
| 953 | return; |
| 954 | } |
| 955 | |
| 956 | pWifiPeerStat = (tpSirWifiPeerStat) pData; |
| 957 | |
| 958 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 959 | "LL_STATS_PEER_ALL : numPeers %u", |
| 960 | pWifiPeerStat->numPeers); |
| 961 | { |
| 962 | for (i = 0; i < pWifiPeerStat->numPeers; i++) |
| 963 | { |
| 964 | pWifiPeerInfo = (tpSirWifiPeerInfo) |
| 965 | ((uint8 *)pWifiPeerStat->peerInfo + |
| 966 | ( i * sizeof(tSirWifiPeerInfo))); |
| 967 | |
| 968 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 969 | " %d) LL_STATS Channel Stats " |
| 970 | " Peer Type %u " |
| 971 | " peerMacAddress %pM " |
| 972 | " capabilities 0x%x " |
| 973 | " numRate %u ", |
| 974 | i, |
| 975 | pWifiPeerInfo->type, |
| 976 | pWifiPeerInfo->peerMacAddress, |
| 977 | pWifiPeerInfo->capabilities, |
| 978 | pWifiPeerInfo->numRate); |
| 979 | { |
| 980 | int j; |
| 981 | for (j = 0; j < pWifiPeerInfo->numRate; j++) |
| 982 | { |
| 983 | pWifiRateStat = (tpSirWifiRateStat) |
| 984 | ((tANI_U8 *) pWifiPeerInfo->rateStats + |
| 985 | ( j * sizeof(tSirWifiRateStat))); |
| 986 | |
| 987 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 988 | " peer Rate Stats " |
| 989 | " preamble %u " |
| 990 | " nss %u " |
| 991 | " bw %u " |
| 992 | " rateMcsIdx %u " |
| 993 | " reserved %u " |
| 994 | " bitrate %u " |
| 995 | " txMpdu %u " |
| 996 | " rxMpdu %u " |
| 997 | " mpduLost %u " |
| 998 | " retries %u " |
| 999 | " retriesShort %u " |
| 1000 | " retriesLong %u", |
| 1001 | pWifiRateStat->rate.preamble, |
| 1002 | pWifiRateStat->rate.nss, |
| 1003 | pWifiRateStat->rate.bw, |
| 1004 | pWifiRateStat->rate.rateMcsIdx, |
| 1005 | pWifiRateStat->rate.reserved, |
| 1006 | pWifiRateStat->rate.bitrate, |
| 1007 | pWifiRateStat->txMpdu, |
| 1008 | pWifiRateStat->rxMpdu, |
| 1009 | pWifiRateStat->mpduLost, |
| 1010 | pWifiRateStat->retries, |
| 1011 | pWifiRateStat->retriesShort, |
| 1012 | pWifiRateStat->retriesLong); |
| 1013 | } |
| 1014 | } |
| 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | /* |
| 1019 | * Allocate a size of 4096 for the peer stats comprising |
| 1020 | * each of size = sizeof (tSirWifiPeerInfo) + numRate * |
| 1021 | * sizeof (tSirWifiRateStat).Each field is put with an |
| 1022 | * NL attribute.The size of 4096 is considered assuming |
| 1023 | * that number of rates shall not exceed beyond 50 with |
| 1024 | * the sizeof (tSirWifiRateStat) being 32. |
| 1025 | */ |
| 1026 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1027 | LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 1028 | QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX, |
| 1029 | GFP_KERNEL); |
| 1030 | if (!vendor_event) |
| 1031 | { |
| 1032 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1033 | "%s: cfg80211_vendor_event_alloc failed", |
| 1034 | __func__); |
| 1035 | return; |
| 1036 | } |
| 1037 | if (nla_put_u32(vendor_event, |
| 1038 | QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS, |
| 1039 | pWifiPeerStat->numPeers)) |
| 1040 | { |
| 1041 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1042 | "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__); |
| 1043 | kfree_skb(vendor_event); |
| 1044 | return; |
| 1045 | } |
| 1046 | |
| 1047 | peerInfo = nla_nest_start(vendor_event, |
| 1048 | QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO); |
| 1049 | |
| 1050 | pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *) |
| 1051 | pWifiPeerStat->peerInfo); |
| 1052 | |
| 1053 | for (i = 1; i <= pWifiPeerStat->numPeers; i++) |
| 1054 | { |
| 1055 | struct nlattr *peers = nla_nest_start(vendor_event, i); |
| 1056 | int numRate = pWifiPeerInfo->numRate; |
| 1057 | |
| 1058 | if (FALSE == put_wifi_peer_info( |
| 1059 | pWifiPeerInfo, vendor_event)) |
| 1060 | { |
| 1061 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1062 | "%s: put_wifi_peer_info put fail", __func__); |
| 1063 | kfree_skb(vendor_event); |
| 1064 | return; |
| 1065 | } |
| 1066 | |
| 1067 | pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *) |
| 1068 | pWifiPeerStat->peerInfo + |
| 1069 | (i * sizeof(tSirWifiPeerInfo)) + |
| 1070 | (numRate * sizeof (tSirWifiRateStat))); |
| 1071 | nla_nest_end(vendor_event, peers); |
| 1072 | } |
| 1073 | nla_nest_end(vendor_event, peerInfo); |
| 1074 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1075 | } |
| 1076 | |
| 1077 | /* |
| 1078 | * hdd_link_layer_process_iface_stats () - This function is called after |
| 1079 | * receiving Link Layer Interface statistics from FW.This function converts |
| 1080 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1081 | * layers. |
| 1082 | */ |
| 1083 | static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter, |
| 1084 | v_VOID_t *pData) |
| 1085 | { |
| 1086 | tpSirWifiIfaceStat pWifiIfaceStat; |
| 1087 | struct sk_buff *vendor_event; |
| 1088 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1089 | int status; |
| 1090 | |
| 1091 | status = wlan_hdd_validate_context(pHddCtx); |
| 1092 | if (0 != status) |
| 1093 | { |
| 1094 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1095 | FL("HDD context is not valid") ); |
| 1096 | return; |
| 1097 | } |
| 1098 | /* |
| 1099 | * Allocate a size of 4096 for the interface stats comprising |
| 1100 | * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered |
| 1101 | * assuming that all these fit with in the limit.Please take |
| 1102 | * a call on the limit based on the data requirements on |
| 1103 | * interface statistics. |
| 1104 | */ |
| 1105 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1106 | LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN, |
| 1107 | QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX, |
| 1108 | GFP_KERNEL); |
| 1109 | if (!vendor_event) |
| 1110 | { |
| 1111 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1112 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1113 | return; |
| 1114 | } |
| 1115 | |
| 1116 | pWifiIfaceStat = (tpSirWifiIfaceStat) pData; |
| 1117 | |
| 1118 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1119 | "WMI_LINK_STATS_IFACE Data"); |
| 1120 | |
| 1121 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1122 | "LL_STATS_IFACE: " |
| 1123 | " Mode %u " |
| 1124 | " MAC %pM " |
| 1125 | " State %u " |
| 1126 | " Roaming %u " |
| 1127 | " capabilities 0x%x " |
| 1128 | " SSID %s " |
| 1129 | " BSSID %pM", |
| 1130 | pWifiIfaceStat->info.mode, |
| 1131 | pWifiIfaceStat->info.macAddr, |
| 1132 | pWifiIfaceStat->info.state, |
| 1133 | pWifiIfaceStat->info.roaming, |
| 1134 | pWifiIfaceStat->info.capabilities, |
| 1135 | pWifiIfaceStat->info.ssid, |
| 1136 | pWifiIfaceStat->info.bssid); |
| 1137 | |
| 1138 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1139 | " AP country str: %c%c%c", |
| 1140 | pWifiIfaceStat->info.apCountryStr[0], |
| 1141 | pWifiIfaceStat->info.apCountryStr[1], |
| 1142 | pWifiIfaceStat->info.apCountryStr[2]); |
| 1143 | |
| 1144 | |
| 1145 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1146 | " Country Str Association: %c%c%c", |
| 1147 | pWifiIfaceStat->info.countryStr[0], |
| 1148 | pWifiIfaceStat->info.countryStr[1], |
| 1149 | pWifiIfaceStat->info.countryStr[2]); |
| 1150 | |
| 1151 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1152 | " beaconRx %u " |
| 1153 | " mgmtRx %u " |
| 1154 | " mgmtActionRx %u " |
| 1155 | " mgmtActionTx %u " |
| 1156 | " rssiMgmt %u " |
| 1157 | " rssiData %u " |
| 1158 | " rssiAck %u", |
| 1159 | pWifiIfaceStat->beaconRx, |
| 1160 | pWifiIfaceStat->mgmtRx, |
| 1161 | pWifiIfaceStat->mgmtActionRx, |
| 1162 | pWifiIfaceStat->mgmtActionTx, |
| 1163 | pWifiIfaceStat->rssiMgmt, |
| 1164 | pWifiIfaceStat->rssiData, |
| 1165 | pWifiIfaceStat->rssiAck ); |
| 1166 | |
| 1167 | |
| 1168 | { |
| 1169 | int i; |
| 1170 | for (i = 0 ; i < WIFI_AC_MAX; i ++) |
| 1171 | { |
| 1172 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1173 | |
| 1174 | " %d) LL_STATS IFACE: " |
| 1175 | " ac: %u txMpdu: %u " |
| 1176 | " rxMpdu: %u txMcast: %u " |
| 1177 | " rxMcast: %u rxAmpdu: %u " |
| 1178 | " txAmpdu: %u mpduLost: %u " |
| 1179 | " retries: %u retriesShort: %u " |
| 1180 | " retriesLong: %u contentionTimeMin: %u " |
| 1181 | " contentionTimeMax: %u contentionTimeAvg: %u " |
| 1182 | " contentionNumSamples: %u", |
| 1183 | i, |
| 1184 | pWifiIfaceStat->AccessclassStats[i].ac, |
| 1185 | pWifiIfaceStat->AccessclassStats[i].txMpdu, |
| 1186 | pWifiIfaceStat->AccessclassStats[i].rxMpdu, |
| 1187 | pWifiIfaceStat->AccessclassStats[i].txMcast, |
| 1188 | pWifiIfaceStat->AccessclassStats[i].rxMcast, |
| 1189 | pWifiIfaceStat->AccessclassStats[i].rxAmpdu, |
| 1190 | pWifiIfaceStat->AccessclassStats[i].txAmpdu, |
| 1191 | pWifiIfaceStat->AccessclassStats[i].mpduLost, |
| 1192 | pWifiIfaceStat->AccessclassStats[i].retries, |
| 1193 | pWifiIfaceStat-> |
| 1194 | AccessclassStats[i].retriesShort, |
| 1195 | pWifiIfaceStat->AccessclassStats[i].retriesLong, |
| 1196 | pWifiIfaceStat-> |
| 1197 | AccessclassStats[i].contentionTimeMin, |
| 1198 | pWifiIfaceStat-> |
| 1199 | AccessclassStats[i].contentionTimeMax, |
| 1200 | pWifiIfaceStat-> |
| 1201 | AccessclassStats[i].contentionTimeAvg, |
| 1202 | pWifiIfaceStat-> |
| 1203 | AccessclassStats[i].contentionNumSamples); |
| 1204 | |
| 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | if (FALSE == hdd_get_interface_info( pAdapter, |
| 1209 | &pWifiIfaceStat->info)) |
| 1210 | { |
| 1211 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1212 | FL("hdd_get_interface_info get fail") ); |
| 1213 | kfree_skb(vendor_event); |
| 1214 | return; |
| 1215 | } |
| 1216 | |
| 1217 | if (FALSE == put_wifi_iface_stats( pWifiIfaceStat, |
| 1218 | vendor_event)) |
| 1219 | { |
| 1220 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1221 | FL("put_wifi_iface_stats fail") ); |
| 1222 | kfree_skb(vendor_event); |
| 1223 | return; |
| 1224 | } |
| 1225 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1226 | } |
| 1227 | |
| 1228 | /* |
| 1229 | * hdd_link_layer_process_radio_stats () - This function is called after |
| 1230 | * receiving Link Layer Radio statistics from FW.This function converts |
| 1231 | * the firmware data to the NL data and sends the same to the kernel/upper |
| 1232 | * layers. |
| 1233 | */ |
| 1234 | static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter, |
| 1235 | v_VOID_t *pData) |
| 1236 | { |
| 1237 | int status, i; |
| 1238 | tpSirWifiRadioStat pWifiRadioStat; |
| 1239 | tpSirWifiChannelStats pWifiChannelStats; |
| 1240 | struct sk_buff *vendor_event; |
| 1241 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1242 | struct nlattr *chList; |
| 1243 | |
| 1244 | status = wlan_hdd_validate_context(pHddCtx); |
| 1245 | if (0 != status) |
| 1246 | { |
| 1247 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1248 | FL("HDD context is not valid") ); |
| 1249 | return; |
| 1250 | } |
| 1251 | pWifiRadioStat = (tpSirWifiRadioStat) pData; |
| 1252 | |
| 1253 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1254 | "LL_STATS_RADIO" |
| 1255 | " radio is %d onTime is %u " |
| 1256 | " txTime is %u rxTime is %u " |
| 1257 | " onTimeScan is %u onTimeNbd is %u " |
| 1258 | " onTimeGscan is %u onTimeRoamScan is %u " |
| 1259 | " onTimePnoScan is %u onTimeHs20 is %u " |
| 1260 | " numChannels is %u", |
| 1261 | pWifiRadioStat->radio, pWifiRadioStat->onTime, |
| 1262 | pWifiRadioStat->txTime, pWifiRadioStat->rxTime, |
| 1263 | pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd, |
| 1264 | pWifiRadioStat->onTimeGscan, |
| 1265 | pWifiRadioStat->onTimeRoamScan, |
| 1266 | pWifiRadioStat->onTimePnoScan, |
| 1267 | pWifiRadioStat->onTimeHs20, |
| 1268 | pWifiRadioStat->numChannels); |
| 1269 | /* |
| 1270 | * Allocate a size of 4096 for the Radio stats comprising |
| 1271 | * sizeof (tSirWifiRadioStat) + numChannels * sizeof |
| 1272 | * (tSirWifiChannelStats).Each channel data is put with an |
| 1273 | * NL attribute.The size of 4096 is considered assuming that |
| 1274 | * number of channels shall not exceed beyond 60 with the |
| 1275 | * sizeof (tSirWifiChannelStats) being 24 bytes. |
| 1276 | */ |
| 1277 | |
| 1278 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 1279 | LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN , |
| 1280 | QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX, |
| 1281 | GFP_KERNEL); |
| 1282 | |
| 1283 | if (!vendor_event) |
| 1284 | { |
| 1285 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1286 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1287 | return; |
| 1288 | } |
| 1289 | |
| 1290 | if (nla_put_u32(vendor_event, |
| 1291 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID, |
| 1292 | pWifiRadioStat->radio) || |
| 1293 | nla_put_u32(vendor_event, |
| 1294 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME, |
| 1295 | pWifiRadioStat->onTime) || |
| 1296 | nla_put_u32(vendor_event, |
| 1297 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME, |
| 1298 | pWifiRadioStat->txTime) || |
| 1299 | nla_put_u32(vendor_event, |
| 1300 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME, |
| 1301 | pWifiRadioStat->rxTime) || |
| 1302 | nla_put_u32(vendor_event, |
| 1303 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN, |
| 1304 | pWifiRadioStat->onTimeScan) || |
| 1305 | nla_put_u32(vendor_event, |
| 1306 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD, |
| 1307 | pWifiRadioStat->onTimeNbd) || |
| 1308 | nla_put_u32(vendor_event, |
| 1309 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_GSCAN, |
| 1310 | pWifiRadioStat->onTimeGscan)|| |
| 1311 | nla_put_u32(vendor_event, |
| 1312 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN, |
| 1313 | pWifiRadioStat->onTimeRoamScan) || |
| 1314 | nla_put_u32(vendor_event, |
| 1315 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN, |
| 1316 | pWifiRadioStat->onTimePnoScan) || |
| 1317 | nla_put_u32(vendor_event, |
| 1318 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20, |
| 1319 | pWifiRadioStat->onTimeHs20) || |
| 1320 | nla_put_u32(vendor_event, |
| 1321 | QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS, |
| 1322 | pWifiRadioStat->numChannels)) |
| 1323 | { |
| 1324 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1325 | FL("QCA_WLAN_VENDOR_ATTR put fail")); |
| 1326 | kfree_skb(vendor_event); |
| 1327 | return ; |
| 1328 | } |
| 1329 | |
| 1330 | chList = nla_nest_start(vendor_event, |
| 1331 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO); |
| 1332 | for (i = 0; i < pWifiRadioStat->numChannels; i++) |
| 1333 | { |
| 1334 | struct nlattr *chInfo; |
| 1335 | |
| 1336 | pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*) |
| 1337 | pWifiRadioStat->channels + |
| 1338 | (i * sizeof(tSirWifiChannelStats))); |
| 1339 | |
| 1340 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1341 | " %d) Channel Info" |
| 1342 | " width is %u " |
| 1343 | " CenterFreq %u " |
| 1344 | " CenterFreq0 %u " |
| 1345 | " CenterFreq1 %u " |
| 1346 | " onTime %u " |
| 1347 | " ccaBusyTime %u", |
| 1348 | i, |
| 1349 | pWifiChannelStats->channel.width, |
| 1350 | pWifiChannelStats->channel.centerFreq, |
| 1351 | pWifiChannelStats->channel.centerFreq0, |
| 1352 | pWifiChannelStats->channel.centerFreq1, |
| 1353 | pWifiChannelStats->onTime, |
| 1354 | pWifiChannelStats->ccaBusyTime); |
| 1355 | |
| 1356 | |
| 1357 | chInfo = nla_nest_start(vendor_event, i); |
| 1358 | |
| 1359 | if (nla_put_u32(vendor_event, |
| 1360 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH, |
| 1361 | pWifiChannelStats->channel.width) || |
| 1362 | nla_put_u32(vendor_event, |
| 1363 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ, |
| 1364 | pWifiChannelStats->channel.centerFreq) || |
| 1365 | nla_put_u32(vendor_event, |
| 1366 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0, |
| 1367 | pWifiChannelStats->channel.centerFreq0) || |
| 1368 | nla_put_u32(vendor_event, |
| 1369 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1, |
| 1370 | pWifiChannelStats->channel.centerFreq1) || |
| 1371 | nla_put_u32(vendor_event, |
| 1372 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME, |
| 1373 | pWifiChannelStats->onTime) || |
| 1374 | nla_put_u32(vendor_event, |
| 1375 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME, |
| 1376 | pWifiChannelStats->ccaBusyTime)) |
| 1377 | { |
| 1378 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1379 | FL("cfg80211_vendor_event_alloc failed") ); |
| 1380 | kfree_skb(vendor_event); |
| 1381 | return ; |
| 1382 | } |
| 1383 | nla_nest_end(vendor_event, chInfo); |
| 1384 | } |
| 1385 | nla_nest_end(vendor_event, chList); |
| 1386 | |
| 1387 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 1388 | return; |
| 1389 | } |
| 1390 | |
| 1391 | /* |
| 1392 | * hdd_link_layer_stats_ind_callback () - This function is called after |
| 1393 | * receiving Link Layer indications from FW.This callback converts the firmware |
| 1394 | * data to the NL data and send the same to the kernel/upper layers. |
| 1395 | */ |
| 1396 | static void hdd_link_layer_stats_ind_callback ( void *pCtx, |
| 1397 | int indType, |
| 1398 | void *pRsp ) |
| 1399 | { |
| 1400 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCtx; |
| 1401 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1402 | int status; |
| 1403 | |
| 1404 | status = wlan_hdd_validate_context(pHddCtx); |
| 1405 | |
| 1406 | if (0 != status) |
| 1407 | { |
| 1408 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1409 | FL("HDD context is not valid")); |
| 1410 | return; |
| 1411 | } |
| 1412 | |
| 1413 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1414 | "%s: Link Layer Indication indType: %d", __func__, indType); |
| 1415 | switch (indType) |
| 1416 | { |
| 1417 | case SIR_HAL_LL_STATS_RESULTS_RSP: |
| 1418 | { |
| 1419 | tpSirLLStatsResults linkLayerStatsResults = |
| 1420 | (tpSirLLStatsResults)pRsp; |
| 1421 | |
| 1422 | |
| 1423 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1424 | FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") ); |
| 1425 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1426 | "LL_STATS RESULTS RESPONSE paramID = 0x%x", |
| 1427 | linkLayerStatsResults->paramId); |
| 1428 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1429 | "LL_STATS RESULTS RESPONSE ifaceId = %u", |
| 1430 | linkLayerStatsResults->ifaceId); |
| 1431 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1432 | "LL_STATS RESULTS RESPONSE respId = %u", |
| 1433 | linkLayerStatsResults->respId); |
| 1434 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1435 | "LL_STATS RESULTS RESPONSE moreResultToFollow = %u", |
| 1436 | linkLayerStatsResults->moreResultToFollow); |
| 1437 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1438 | "LL_STATS RESULTS RESPONSE result = %p", |
| 1439 | linkLayerStatsResults->result); |
| 1440 | if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO ) |
| 1441 | { |
| 1442 | hdd_link_layer_process_radio_stats(pAdapter, |
| 1443 | (v_VOID_t *)linkLayerStatsResults->result); |
| 1444 | } |
| 1445 | else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE ) |
| 1446 | { |
| 1447 | hdd_link_layer_process_iface_stats(pAdapter, |
| 1448 | (v_VOID_t *)linkLayerStatsResults->result); |
| 1449 | } |
| 1450 | else if ( linkLayerStatsResults->paramId & |
| 1451 | WMI_LINK_STATS_ALL_PEER ) |
| 1452 | { |
| 1453 | hdd_link_layer_process_peer_stats(pAdapter, |
| 1454 | (v_VOID_t *)linkLayerStatsResults->result); |
| 1455 | } /* WMI_LINK_STATS_ALL_PEER */ |
| 1456 | else |
| 1457 | { |
| 1458 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1459 | FL("INVALID LL_STATS_NOTIFY RESPONSE ***********")); |
| 1460 | } |
| 1461 | |
| 1462 | break; |
| 1463 | } |
| 1464 | default: |
| 1465 | hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType); |
| 1466 | break; |
| 1467 | } |
| 1468 | return; |
| 1469 | } |
| 1470 | |
| 1471 | const struct |
| 1472 | nla_policy |
| 1473 | qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] = |
| 1474 | { |
| 1475 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] = |
| 1476 | { .type = NLA_U32 }, |
| 1477 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] = |
| 1478 | { .type = NLA_U32 }, |
| 1479 | }; |
| 1480 | |
| 1481 | static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy, |
| 1482 | struct wireless_dev *wdev, |
| 1483 | void *data, |
| 1484 | int data_len) |
| 1485 | { |
| 1486 | int status; |
| 1487 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1]; |
| 1488 | tpSirLLStatsSetReq pLinkLayerStatsSetReq; |
| 1489 | struct net_device *dev = wdev->netdev; |
| 1490 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1491 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1492 | |
| 1493 | status = wlan_hdd_validate_context(pHddCtx); |
| 1494 | if (0 != status) |
| 1495 | { |
| 1496 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1497 | FL("HDD context is not valid")); |
| 1498 | return -EINVAL; |
| 1499 | } |
| 1500 | |
| 1501 | if (NULL == pAdapter) |
| 1502 | { |
| 1503 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1504 | FL("HDD adapter is Null")); |
| 1505 | return -ENODEV; |
| 1506 | } |
| 1507 | |
| 1508 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX, |
| 1509 | (struct nlattr *)data, |
| 1510 | data_len, qca_wlan_vendor_ll_set_policy)) |
| 1511 | { |
| 1512 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1513 | return -EINVAL; |
| 1514 | } |
| 1515 | if (!tb_vendor |
| 1516 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]) |
| 1517 | { |
| 1518 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present")); |
| 1519 | return -EINVAL; |
| 1520 | } |
| 1521 | if (!tb_vendor[ |
| 1522 | QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]) |
| 1523 | { |
| 1524 | hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present")); |
| 1525 | return -EINVAL; |
| 1526 | } |
| 1527 | pLinkLayerStatsSetReq = vos_mem_malloc(sizeof(tSirLLStatsSetReq)); |
| 1528 | if (NULL == pLinkLayerStatsSetReq) |
| 1529 | { |
| 1530 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1531 | FL(" Unable to allocate memory to pLinkLayerStatsSetReq") ); |
| 1532 | return -ENOMEM; |
| 1533 | } |
| 1534 | // Shall take the request Id if the Upper layers pass. 1 For now. |
| 1535 | pLinkLayerStatsSetReq->reqId = 1; |
| 1536 | |
| 1537 | pLinkLayerStatsSetReq->mpduSizeThreshold = |
| 1538 | nla_get_u32( |
| 1539 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]); |
| 1540 | |
| 1541 | pLinkLayerStatsSetReq->aggressiveStatisticsGathering = |
| 1542 | nla_get_u32( |
| 1543 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]); |
| 1544 | |
| 1545 | /* staId 0 in Firmware is reserved for Broadcast/Multicast data. |
| 1546 | * Hence the interface staId start from 1. Hence the staId matching the |
| 1547 | * interface in the firmware is sessionId + 1. |
| 1548 | */ |
| 1549 | pLinkLayerStatsSetReq->staId = pAdapter->sessionId + 1; |
| 1550 | |
| 1551 | |
| 1552 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1553 | "LL_STATS_SET reqId = %d", |
| 1554 | pLinkLayerStatsSetReq->reqId); |
| 1555 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1556 | "LL_STATS_SET staId = %d", pLinkLayerStatsSetReq->staId); |
| 1557 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1558 | "LL_STATS_SET mpduSizeThreshold = %d", |
| 1559 | pLinkLayerStatsSetReq->mpduSizeThreshold); |
| 1560 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1561 | "LL_STATS_SET aggressive Statistics Gathering = %d", |
| 1562 | pLinkLayerStatsSetReq->aggressiveStatisticsGathering); |
| 1563 | |
| 1564 | if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB( |
| 1565 | pHddCtx->hHal, |
| 1566 | pAdapter->sessionId, |
| 1567 | hdd_link_layer_stats_ind_callback, |
| 1568 | pAdapter)) |
| 1569 | { |
| 1570 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1571 | "sme_SetLinkLayerStatsIndCB Failed", __func__); |
| 1572 | vos_mem_free(pLinkLayerStatsSetReq); |
| 1573 | return -EINVAL; |
| 1574 | |
| 1575 | } |
| 1576 | if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal, |
| 1577 | pLinkLayerStatsSetReq)) |
| 1578 | { |
| 1579 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1580 | "sme_LLStatsSetReq Failed", __func__); |
| 1581 | vos_mem_free(pLinkLayerStatsSetReq); |
| 1582 | return -EINVAL; |
| 1583 | } |
| 1584 | |
| 1585 | pAdapter->isLinkLayerStatsSet = 1; |
| 1586 | |
| 1587 | return 0; |
| 1588 | } |
| 1589 | |
| 1590 | const struct |
| 1591 | nla_policy |
| 1592 | qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] = |
| 1593 | { |
| 1594 | /* Unsigned 32bit value provided by the caller issuing the GET stats |
| 1595 | * command. When reporting |
| 1596 | * the stats results, the driver uses the same value to indicate |
| 1597 | * which GET request the results |
| 1598 | * correspond to. |
| 1599 | */ |
| 1600 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 }, |
| 1601 | |
| 1602 | /* Unsigned 32bit value . bit mask to identify what statistics are |
| 1603 | requested for retrieval */ |
| 1604 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 }, |
| 1605 | }; |
| 1606 | |
| 1607 | static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy, |
| 1608 | struct wireless_dev *wdev, |
| 1609 | void *data, |
| 1610 | int data_len) |
| 1611 | { |
| 1612 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1613 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1]; |
| 1614 | tpSirLLStatsGetReq pLinkLayerStatsGetReq; |
| 1615 | struct net_device *dev = wdev->netdev; |
| 1616 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1617 | int status; |
| 1618 | |
| 1619 | status = wlan_hdd_validate_context(pHddCtx); |
| 1620 | if (0 != status) |
| 1621 | { |
| 1622 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1623 | FL("HDD context is not valid")); |
| 1624 | return -EINVAL ; |
| 1625 | } |
| 1626 | |
| 1627 | if (NULL == pAdapter) |
| 1628 | { |
| 1629 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1630 | "%s: HDD adapter is Null", __func__); |
| 1631 | return -ENODEV; |
| 1632 | } |
| 1633 | |
| 1634 | if (!pAdapter->isLinkLayerStatsSet) |
| 1635 | { |
| 1636 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1637 | "%s: isLinkLayerStatsSet : %d", |
| 1638 | __func__, pAdapter->isLinkLayerStatsSet); |
| 1639 | return -EINVAL; |
| 1640 | } |
| 1641 | |
| 1642 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX, |
| 1643 | (struct nlattr *)data, |
| 1644 | data_len, qca_wlan_vendor_ll_get_policy)) |
| 1645 | { |
| 1646 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1647 | return -EINVAL; |
| 1648 | } |
| 1649 | |
| 1650 | if (!tb_vendor |
| 1651 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]) |
| 1652 | { |
| 1653 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present")); |
| 1654 | return -EINVAL; |
| 1655 | } |
| 1656 | |
| 1657 | if (!tb_vendor |
| 1658 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]) |
| 1659 | { |
| 1660 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present")); |
| 1661 | return -EINVAL; |
| 1662 | } |
| 1663 | |
| 1664 | pLinkLayerStatsGetReq = vos_mem_malloc(sizeof(tSirLLStatsGetReq)); |
| 1665 | |
| 1666 | if (NULL == pLinkLayerStatsGetReq) |
| 1667 | { |
| 1668 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1669 | FL("Unable to allocate memory to pLinkLayerStatsGetReq")); |
| 1670 | return -ENOMEM; |
| 1671 | } |
| 1672 | |
| 1673 | pLinkLayerStatsGetReq->reqId = |
| 1674 | nla_get_u32( tb_vendor[ |
| 1675 | QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]); |
| 1676 | pLinkLayerStatsGetReq->paramIdMask = |
| 1677 | nla_get_u32( tb_vendor[ |
| 1678 | QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]); |
| 1679 | |
| 1680 | /* staId 0 in Firmware is reserved for Broadcast/Multicast data. |
| 1681 | * Hence the interface staId start from 1. Hence the staId matching the |
| 1682 | * interface in the firmware is sessionId + 1. |
| 1683 | */ |
| 1684 | pLinkLayerStatsGetReq->staId = pAdapter->sessionId + 1; |
| 1685 | |
| 1686 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1687 | "LL_STATS_GET reqId = %d", pLinkLayerStatsGetReq->reqId); |
| 1688 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1689 | "LL_STATS_GET staId = %d", pLinkLayerStatsGetReq->staId); |
| 1690 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1691 | "LL_STATS_GET paramIdMask = %d", |
| 1692 | pLinkLayerStatsGetReq->paramIdMask); |
| 1693 | |
| 1694 | if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal, |
| 1695 | pLinkLayerStatsGetReq)) |
| 1696 | { |
| 1697 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:" |
| 1698 | "sme_LLStatsGetReq Failed", __func__); |
| 1699 | vos_mem_free(pLinkLayerStatsGetReq); |
| 1700 | return -EINVAL; |
| 1701 | } |
| 1702 | return 0; |
| 1703 | } |
| 1704 | |
| 1705 | const struct |
| 1706 | nla_policy |
| 1707 | qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] = |
| 1708 | { |
| 1709 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 }, |
| 1710 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 }, |
| 1711 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 }, |
| 1712 | [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 }, |
| 1713 | }; |
| 1714 | |
| 1715 | static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy, |
| 1716 | struct wireless_dev *wdev, |
| 1717 | void *data, |
| 1718 | int data_len) |
| 1719 | { |
| 1720 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 1721 | struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1]; |
| 1722 | tpSirLLStatsClearReq pLinkLayerStatsClearReq; |
| 1723 | struct net_device *dev = wdev->netdev; |
| 1724 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1725 | u32 statsClearReqMask; |
| 1726 | u8 stopReq; |
| 1727 | int status; |
| 1728 | |
| 1729 | status = wlan_hdd_validate_context(pHddCtx); |
| 1730 | if (0 != status) |
| 1731 | { |
| 1732 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1733 | FL("HDD context is not valid")); |
| 1734 | return -EINVAL; |
| 1735 | } |
| 1736 | |
| 1737 | if (NULL == pAdapter) |
| 1738 | { |
| 1739 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1740 | "%s: HDD adapter is Null", __func__); |
| 1741 | return -ENODEV; |
| 1742 | } |
| 1743 | |
| 1744 | if (!pAdapter->isLinkLayerStatsSet) |
| 1745 | { |
| 1746 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1747 | "%s: isLinkLayerStatsSet : %d", |
| 1748 | __func__, pAdapter->isLinkLayerStatsSet); |
| 1749 | return -EINVAL; |
| 1750 | } |
| 1751 | |
| 1752 | if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX, |
| 1753 | (struct nlattr *)data, |
| 1754 | data_len, qca_wlan_vendor_ll_clr_policy)) |
| 1755 | { |
| 1756 | hddLog(VOS_TRACE_LEVEL_ERROR, FL() ); |
| 1757 | return -EINVAL; |
| 1758 | } |
| 1759 | |
| 1760 | if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] || |
| 1761 | |
| 1762 | !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]) |
| 1763 | { |
| 1764 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") ); |
| 1765 | return -EINVAL; |
| 1766 | |
| 1767 | } |
| 1768 | |
| 1769 | pLinkLayerStatsClearReq = vos_mem_malloc(sizeof(tSirLLStatsClearReq)); |
| 1770 | if (NULL == pLinkLayerStatsClearReq) |
| 1771 | { |
| 1772 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1773 | FL("Unable to allocate memory to pLinkLayerStatsClearReq")); |
| 1774 | return -ENOMEM; |
| 1775 | } |
| 1776 | |
| 1777 | statsClearReqMask = pLinkLayerStatsClearReq->statsClearReqMask = |
| 1778 | nla_get_u32( |
| 1779 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]); |
| 1780 | |
| 1781 | stopReq = pLinkLayerStatsClearReq->stopReq = |
| 1782 | nla_get_u8( |
| 1783 | tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]); |
| 1784 | |
| 1785 | // Shall take the request Id if the Upper layers pass. 1 For now. |
| 1786 | pLinkLayerStatsClearReq->reqId = 1; |
| 1787 | |
| 1788 | /* staId 0 in Firmware is reserved for Broadcast/Multicast data. |
| 1789 | * Hence the interface staId start from 1. Hence the staId matching the |
| 1790 | * interface in the firmware is sessionId + 1. |
| 1791 | */ |
| 1792 | pLinkLayerStatsClearReq->staId = pAdapter->sessionId + 1; |
| 1793 | |
| 1794 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1795 | "LL_STATS_CLEAR reqId = %d", pLinkLayerStatsClearReq->reqId); |
| 1796 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1797 | "LL_STATS_CLEAR staId = %d", pLinkLayerStatsClearReq->staId); |
| 1798 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1799 | "LL_STATS_CLEAR statsClearReqMask = 0x%X", |
| 1800 | pLinkLayerStatsClearReq->statsClearReqMask); |
| 1801 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1802 | "LL_STATS_CLEAR stopReq = %d", |
| 1803 | pLinkLayerStatsClearReq->stopReq); |
| 1804 | |
| 1805 | if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal, |
| 1806 | pLinkLayerStatsClearReq)) |
| 1807 | { |
| 1808 | struct sk_buff *temp_skbuff; |
| 1809 | temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, |
| 1810 | 2 * sizeof(u32) + |
| 1811 | NLMSG_HDRLEN); |
| 1812 | |
| 1813 | if (temp_skbuff != NULL) |
| 1814 | { |
| 1815 | |
| 1816 | if (nla_put_u32(temp_skbuff, |
| 1817 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK, |
| 1818 | statsClearReqMask) || |
| 1819 | nla_put_u32(temp_skbuff, |
| 1820 | QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP, |
| 1821 | stopReq)) |
| 1822 | { |
| 1823 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail")); |
| 1824 | kfree_skb(temp_skbuff); |
| 1825 | return -EINVAL; |
| 1826 | } |
| 1827 | /* If the ask is to stop the stats collection as part of clear |
| 1828 | * (stopReq = 1) , ensure that no further requests of get |
| 1829 | * go to the firmware by having isLinkLayerStatsSet set to 0. |
| 1830 | * However it the stopReq as part of the clear request is 0 , |
| 1831 | * the request to get the statistics are ehonoured as in this |
| 1832 | * case the firmware is just asked to clear the statistics. |
| 1833 | */ |
| 1834 | if (pLinkLayerStatsClearReq->stopReq == 1) |
| 1835 | pAdapter->isLinkLayerStatsSet = 0; |
| 1836 | return cfg80211_vendor_cmd_reply(temp_skbuff); |
| 1837 | } |
| 1838 | return -ENOMEM; |
| 1839 | } |
| 1840 | vos_mem_free(pLinkLayerStatsClearReq); |
| 1841 | return -EINVAL; |
| 1842 | } |
| 1843 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1844 | |
| 1845 | const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = |
| 1846 | { |
| 1847 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 1848 | { |
| 1849 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 1850 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR, |
| 1851 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 1852 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 1853 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 1854 | .doit = wlan_hdd_cfg80211_ll_stats_clear |
| 1855 | }, |
| 1856 | |
| 1857 | { |
| 1858 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 1859 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET, |
| 1860 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 1861 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 1862 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 1863 | .doit = wlan_hdd_cfg80211_ll_stats_set |
| 1864 | }, |
| 1865 | |
| 1866 | { |
| 1867 | .info.vendor_id = QCA_NL80211_VENDOR_ID, |
| 1868 | .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET, |
| 1869 | .flags = WIPHY_VENDOR_CMD_NEED_WDEV | |
| 1870 | WIPHY_VENDOR_CMD_NEED_NETDEV | |
| 1871 | WIPHY_VENDOR_CMD_NEED_RUNNING, |
| 1872 | .doit = wlan_hdd_cfg80211_ll_stats_get |
| 1873 | } |
| 1874 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1875 | }; |
| 1876 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 1877 | /* vendor specific events */ |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1878 | static const |
| 1879 | struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 1880 | { |
| 1881 | #ifdef FEATURE_WLAN_CH_AVOID |
| 1882 | { |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1883 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1884 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 1885 | }, |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1886 | #endif /* FEATURE_WLAN_CH_AVOID Index = 0*/ |
| 1887 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 1888 | { |
| 1889 | /* Index = 1*/ |
| 1890 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1891 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET |
| 1892 | }, |
| 1893 | { |
| 1894 | /* Index = 2*/ |
| 1895 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1896 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET |
| 1897 | }, |
| 1898 | { |
| 1899 | /* Index = 3*/ |
| 1900 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1901 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR |
| 1902 | }, |
| 1903 | { |
| 1904 | /* Index = 4*/ |
| 1905 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1906 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS |
| 1907 | }, |
| 1908 | { |
| 1909 | /* Index = 5*/ |
| 1910 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1911 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS |
| 1912 | }, |
| 1913 | { |
| 1914 | /* Index = 6*/ |
| 1915 | .vendor_id = QCA_NL80211_VENDOR_ID, |
| 1916 | .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS |
| 1917 | }, |
| 1918 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1919 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 1920 | }; |
| 1921 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1922 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 1923 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1924 | * This function is called by hdd_wlan_startup() |
| 1925 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 1926 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1927 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 1928 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1929 | { |
| 1930 | struct wiphy *wiphy; |
| 1931 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1932 | /* |
| 1933 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1934 | */ |
| 1935 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 1936 | |
| 1937 | if (!wiphy) |
| 1938 | { |
| 1939 | /* Print error and jump into err label and free the memory */ |
| 1940 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 1941 | return NULL; |
| 1942 | } |
| 1943 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 1944 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1945 | return wiphy; |
| 1946 | } |
| 1947 | |
| 1948 | /* |
| 1949 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1950 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1951 | * private ioctl to change the band value |
| 1952 | */ |
| 1953 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 1954 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 1955 | int i, j; |
| 1956 | eNVChannelEnabledType channelEnabledState; |
| 1957 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1958 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 1959 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 1960 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1961 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 1962 | |
| 1963 | if (NULL == wiphy->bands[i]) |
| 1964 | { |
| 1965 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 1966 | __func__, i); |
| 1967 | continue; |
| 1968 | } |
| 1969 | |
| 1970 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 1971 | { |
| 1972 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 1973 | |
| 1974 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 1975 | band->channels[j].hw_value); |
| 1976 | |
| 1977 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 1978 | { |
| 1979 | // Enable Social channels for P2P |
| 1980 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 1981 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 1982 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 1983 | else |
| 1984 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 1985 | continue; |
| 1986 | } |
| 1987 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 1988 | { |
| 1989 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 1990 | continue; |
| 1991 | } |
| 1992 | |
| 1993 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 1994 | NV_CHANNEL_INVALID == channelEnabledState) |
| 1995 | { |
| 1996 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 1997 | } |
| 1998 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 1999 | { |
| 2000 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 2001 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 2002 | } |
| 2003 | else |
| 2004 | { |
| 2005 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 2006 | |IEEE80211_CHAN_RADAR); |
| 2007 | } |
| 2008 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2009 | } |
| 2010 | return 0; |
| 2011 | } |
| 2012 | /* |
| 2013 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2014 | * This function is called by hdd_wlan_startup() |
| 2015 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2016 | * This function is used to initialize and register wiphy structure. |
| 2017 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 2018 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2019 | struct wiphy *wiphy, |
| 2020 | hdd_config_t *pCfg |
| 2021 | ) |
| 2022 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 2023 | int i, j; |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 2024 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2025 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2026 | ENTER(); |
| 2027 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2028 | /* Now bind the underlying wlan device with wiphy */ |
| 2029 | set_wiphy_dev(wiphy, dev); |
| 2030 | |
| 2031 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2032 | |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 2033 | #ifndef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 2034 | /* the flag for the other case would be initialzed in |
| 2035 | vos_init_wiphy_from_nv_bin */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 2036 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 2037 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 2038 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2039 | /* This will disable updating of NL channels from passive to |
| 2040 | * active if a beacon is received on passive channel. */ |
| 2041 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Amar Singhal | f007319 | 2013-09-20 12:34:56 -0700 | [diff] [blame] | 2042 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2043 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 2044 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2045 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 2046 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 2047 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 2048 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2049 | | WIPHY_FLAG_OFFCHAN_TX; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 2050 | wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2051 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 2052 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2053 | #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] | 2054 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 2055 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 2056 | || pCfg->isFastRoamIniFeatureEnabled |
| 2057 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2058 | #ifdef FEATURE_WLAN_ESE |
| 2059 | || pCfg->isEseIniFeatureEnabled |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 2060 | #endif |
| 2061 | ) |
| 2062 | { |
| 2063 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 2064 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 2065 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 2066 | #ifdef FEATURE_WLAN_TDLS |
| 2067 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 2068 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 2069 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 2070 | #ifdef FEATURE_WLAN_SCAN_PNO |
Hardik Kantilal Patel | 3dfd879 | 2013-11-13 20:34:57 +0530 | [diff] [blame] | 2071 | if (pCfg->configPNOScanSupport) |
| 2072 | { |
| 2073 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 2074 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
| 2075 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 2076 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
| 2077 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 2078 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 2079 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2080 | #ifdef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 2081 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 2082 | driver can still register regulatory callback and |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2083 | it will get regulatory settings in wiphy->band[], but |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 2084 | driver need to determine what to do with both |
| 2085 | regulatory settings */ |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2086 | |
| 2087 | wiphy->reg_notifier = wlan_hdd_linux_reg_notifier; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 2088 | #else |
| 2089 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 2090 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2091 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2092 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 2093 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 2094 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2095 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2096 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 2097 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2098 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2099 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2100 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2101 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 2102 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2103 | | BIT(NL80211_IFTYPE_AP); |
| 2104 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 2105 | if( pCfg->advertiseConcurrentOperation ) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 2106 | { |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 2107 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 2108 | if( pCfg->enableMCC ) |
| 2109 | { |
| 2110 | /* Currently, supports up to two channels */ |
| 2111 | wlan_hdd_iface_combination.num_different_channels = 2; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 2112 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 2113 | if( !pCfg->allowMCCGODiffBI ) |
| 2114 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 2115 | |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 2116 | } |
| 2117 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 2118 | wiphy->n_iface_combinations = 1; |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 2119 | #endif |
Rashmi Ramanna | bd3feb7 | 2014-02-25 16:14:48 +0530 | [diff] [blame] | 2120 | } |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 2121 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2122 | /* Before registering we need to update the ht capabilitied based |
| 2123 | * on ini values*/ |
| 2124 | if( !pCfg->ShortGI20MhzEnable ) |
| 2125 | { |
| 2126 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 2127 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 2128 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 2129 | } |
| 2130 | |
| 2131 | if( !pCfg->ShortGI40MhzEnable ) |
| 2132 | { |
| 2133 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 2134 | } |
| 2135 | |
| 2136 | if( !pCfg->nChannelBondingMode5GHz ) |
| 2137 | { |
| 2138 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 2139 | } |
| 2140 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 2141 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 2142 | if (true == hdd_is_5g_supported(pHddCtx)) |
| 2143 | { |
| 2144 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 2145 | } |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 2146 | |
| 2147 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 2148 | { |
| 2149 | |
| 2150 | if (NULL == wiphy->bands[i]) |
| 2151 | { |
| 2152 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 2153 | __func__, i); |
| 2154 | continue; |
| 2155 | } |
| 2156 | |
| 2157 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 2158 | { |
| 2159 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 2160 | |
| 2161 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 2162 | { |
| 2163 | // Enable social channels for P2P |
| 2164 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 2165 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 2166 | else |
| 2167 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 2168 | continue; |
| 2169 | } |
| 2170 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 2171 | { |
| 2172 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 2173 | continue; |
| 2174 | } |
| 2175 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2176 | } |
| 2177 | /*Initialise the supported cipher suite details*/ |
| 2178 | wiphy->cipher_suites = hdd_cipher_suites; |
| 2179 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 2180 | |
| 2181 | /*signal strength in mBm (100*dBm) */ |
| 2182 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 2183 | |
| 2184 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2185 | wiphy->max_remain_on_channel_duration = 1000; |
| 2186 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2187 | |
Sunil Dutt | c69bccb | 2014-05-26 21:30:20 +0530 | [diff] [blame] | 2188 | wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands); |
| 2189 | wiphy->vendor_commands = hdd_wiphy_vendor_commands; |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 2190 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 2191 | wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 2192 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 2193 | EXIT(); |
| 2194 | return 0; |
| 2195 | } |
| 2196 | |
| 2197 | /* In this function we are registering wiphy. */ |
| 2198 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 2199 | { |
| 2200 | ENTER(); |
| 2201 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2202 | if (0 > wiphy_register(wiphy)) |
| 2203 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 2204 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2205 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 2206 | return -EIO; |
| 2207 | } |
| 2208 | |
| 2209 | EXIT(); |
| 2210 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2211 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2212 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 2213 | /* In this function we are updating channel list when, |
| 2214 | regulatory domain is FCC and country code is US. |
| 2215 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 2216 | As per FCC smart phone is not a indoor device. |
| 2217 | GO should not opeate on indoor channels */ |
| 2218 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 2219 | { |
| 2220 | int j; |
| 2221 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2222 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 2223 | //Default counrtycode from NV at the time of wiphy initialization. |
| 2224 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 2225 | &defaultCountryCode[0])) |
| 2226 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 2227 | hddLog(LOGE, FL("Failed to get default country code from NV")); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 2228 | } |
| 2229 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 2230 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 2231 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 2232 | { |
| 2233 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 2234 | return; |
| 2235 | } |
| 2236 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 2237 | { |
| 2238 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 2239 | // Mark UNII -1 band channel as passive |
| 2240 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 2241 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 2242 | } |
| 2243 | } |
| 2244 | } |
| 2245 | |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 2246 | /* This function registers for all frame which supplicant is interested in */ |
| 2247 | void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2248 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2249 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 2250 | /* Register for all P2P action, public action etc frames */ |
| 2251 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 2252 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2253 | ENTER(); |
| 2254 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2255 | /* Right now we are registering these frame when driver is getting |
| 2256 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 2257 | frame register ops, we will move this code as a part of that */ |
| 2258 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2259 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2260 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 2261 | |
| 2262 | /* GAS Initial Response */ |
| 2263 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2264 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2265 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2266 | /* GAS Comeback Request */ |
| 2267 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2268 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 2269 | |
| 2270 | /* GAS Comeback Response */ |
| 2271 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2272 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 2273 | |
| 2274 | /* P2P Public Action */ |
| 2275 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2276 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2277 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 2278 | |
| 2279 | /* P2P Action */ |
| 2280 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2281 | (v_U8_t*)P2P_ACTION_FRAME, |
| 2282 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 2283 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 2284 | /* WNM BSS Transition Request frame */ |
| 2285 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2286 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 2287 | WNM_BSS_ACTION_FRAME_SIZE ); |
Leela Venkata Kiran Kumar Reddy Chirala | e8e62c8 | 2013-10-29 18:23:26 -0700 | [diff] [blame] | 2288 | |
| 2289 | /* WNM-Notification */ |
| 2290 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2291 | (v_U8_t*)WNM_NOTIFICATION_FRAME, |
| 2292 | WNM_NOTIFICATION_FRAME_SIZE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2293 | } |
| 2294 | |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 2295 | void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2296 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2297 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 2298 | /* Register for all P2P action, public action etc frames */ |
| 2299 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 2300 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2301 | ENTER(); |
| 2302 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2303 | /* Right now we are registering these frame when driver is getting |
| 2304 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 2305 | frame register ops, we will move this code as a part of that */ |
| 2306 | /* GAS Initial Request */ |
| 2307 | |
| 2308 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2309 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 2310 | |
| 2311 | /* GAS Initial Response */ |
| 2312 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2313 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2315 | /* GAS Comeback Request */ |
| 2316 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2317 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 2318 | |
| 2319 | /* GAS Comeback Response */ |
| 2320 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2321 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 2322 | |
| 2323 | /* P2P Public Action */ |
| 2324 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2325 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2326 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 2327 | |
| 2328 | /* P2P Action */ |
| 2329 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2330 | (v_U8_t*)P2P_ACTION_FRAME, |
| 2331 | P2P_ACTION_FRAME_SIZE ); |
Leela Venkata Kiran Kumar Reddy Chirala | e8e62c8 | 2013-10-29 18:23:26 -0700 | [diff] [blame] | 2332 | /* WNM-Notification */ |
| 2333 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 2334 | (v_U8_t*)WNM_NOTIFICATION_FRAME, |
| 2335 | WNM_NOTIFICATION_FRAME_SIZE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2336 | } |
| 2337 | |
| 2338 | #ifdef FEATURE_WLAN_WAPI |
| 2339 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 2340 | const u8 *mac_addr, u8 *key , int key_Len) |
| 2341 | { |
| 2342 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2343 | tCsrRoamSetKey setKey; |
| 2344 | v_BOOL_t isConnected = TRUE; |
| 2345 | int status = 0; |
| 2346 | v_U32_t roamId= 0xFF; |
| 2347 | tANI_U8 *pKeyPtr = NULL; |
| 2348 | int n = 0; |
| 2349 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2350 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)", |
| 2351 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 2352 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2353 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 2354 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2355 | setKey.keyId = key_index; // Store Key ID |
| 2356 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 2357 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 2358 | setKey.paeRole = 0 ; // the PAE role |
| 2359 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 2360 | { |
| 2361 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 2362 | } |
| 2363 | else |
| 2364 | { |
| 2365 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 2366 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 2367 | } |
| 2368 | setKey.keyLength = key_Len; |
| 2369 | pKeyPtr = setKey.Key; |
| 2370 | memcpy( pKeyPtr, key, key_Len); |
| 2371 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2372 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2373 | __func__, key_Len); |
| 2374 | for (n = 0 ; n < key_Len; n++) |
| 2375 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 2376 | __func__,n,setKey.Key[n]); |
| 2377 | |
| 2378 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 2379 | if ( isConnected ) |
| 2380 | { |
| 2381 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2382 | pAdapter->sessionId, &setKey, &roamId ); |
| 2383 | } |
| 2384 | if ( status != 0 ) |
| 2385 | { |
| 2386 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2387 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 2388 | __LINE__, status ); |
| 2389 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 2390 | } |
| 2391 | } |
| 2392 | #endif /* FEATURE_WLAN_WAPI*/ |
| 2393 | |
| 2394 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2395 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2396 | beacon_data_t **ppBeacon, |
| 2397 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2398 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2399 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2400 | beacon_data_t **ppBeacon, |
| 2401 | struct cfg80211_beacon_data *params, |
| 2402 | int dtim_period) |
| 2403 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2404 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2405 | int size; |
| 2406 | beacon_data_t *beacon = NULL; |
| 2407 | beacon_data_t *old = NULL; |
| 2408 | int head_len,tail_len; |
| 2409 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2410 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2411 | if (params->head && !params->head_len) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2412 | { |
| 2413 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2414 | FL("head_len is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2415 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2416 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2417 | |
| 2418 | old = pAdapter->sessionCtx.ap.beacon; |
| 2419 | |
| 2420 | if (!params->head && !old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2421 | { |
| 2422 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2423 | FL("session(%d) old and new heads points to NULL"), |
| 2424 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2425 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2426 | } |
| 2427 | |
| 2428 | if (params->tail && !params->tail_len) |
| 2429 | { |
| 2430 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2431 | FL("tail_len is zero but tail is not NULL")); |
| 2432 | return -EINVAL; |
| 2433 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2434 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2435 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 2436 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 2437 | if (!params->dtim_period) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2438 | { |
| 2439 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2440 | FL("dtim period is 0")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2441 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2442 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2443 | #endif |
| 2444 | |
| 2445 | if(params->head) |
| 2446 | head_len = params->head_len; |
| 2447 | else |
| 2448 | head_len = old->head_len; |
| 2449 | |
| 2450 | if(params->tail || !old) |
| 2451 | tail_len = params->tail_len; |
| 2452 | else |
| 2453 | tail_len = old->tail_len; |
| 2454 | |
| 2455 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 2456 | |
| 2457 | beacon = kzalloc(size, GFP_KERNEL); |
| 2458 | |
| 2459 | if( beacon == NULL ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2460 | { |
| 2461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2462 | FL("Mem allocation for beacon failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2463 | return -ENOMEM; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2464 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2465 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2466 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2467 | if(params->dtim_period || !old ) |
| 2468 | beacon->dtim_period = params->dtim_period; |
| 2469 | else |
| 2470 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2471 | #else |
| 2472 | if(dtim_period || !old ) |
| 2473 | beacon->dtim_period = dtim_period; |
| 2474 | else |
| 2475 | beacon->dtim_period = old->dtim_period; |
| 2476 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2477 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2478 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 2479 | beacon->tail = beacon->head + head_len; |
| 2480 | beacon->head_len = head_len; |
| 2481 | beacon->tail_len = tail_len; |
| 2482 | |
| 2483 | if(params->head) { |
| 2484 | memcpy (beacon->head,params->head,beacon->head_len); |
| 2485 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2486 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2487 | if(old) |
| 2488 | memcpy (beacon->head,old->head,beacon->head_len); |
| 2489 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2490 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2491 | if(params->tail) { |
| 2492 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 2493 | } |
| 2494 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2495 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2496 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 2497 | } |
| 2498 | |
| 2499 | *ppBeacon = beacon; |
| 2500 | |
| 2501 | kfree(old); |
| 2502 | |
| 2503 | return 0; |
| 2504 | |
| 2505 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2506 | |
| 2507 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 2508 | { |
| 2509 | int left = length; |
| 2510 | v_U8_t *ptr = pIes; |
| 2511 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2513 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2514 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2515 | elem_id = ptr[0]; |
| 2516 | elem_len = ptr[1]; |
| 2517 | left -= 2; |
| 2518 | if(elem_len > left) |
| 2519 | { |
| 2520 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2521 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2522 | eid,elem_len,left); |
| 2523 | return NULL; |
| 2524 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2525 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2526 | { |
| 2527 | return ptr; |
| 2528 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2529 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2530 | left -= elem_len; |
| 2531 | ptr += (elem_len + 2); |
| 2532 | } |
| 2533 | return NULL; |
| 2534 | } |
| 2535 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2536 | /* Check if rate is 11g rate or not */ |
| 2537 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 2538 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 2539 | 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] | 2540 | u8 i; |
| 2541 | for (i = 0; i < 8; i++) |
| 2542 | { |
| 2543 | if(rate == gRateArray[i]) |
| 2544 | return TRUE; |
| 2545 | } |
| 2546 | return FALSE; |
| 2547 | } |
| 2548 | |
| 2549 | /* Check for 11g rate and set proper 11g only mode */ |
| 2550 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 2551 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 2552 | { |
| 2553 | u8 i, num_rates = pIe[0]; |
| 2554 | |
| 2555 | pIe += 1; |
| 2556 | for ( i = 0; i < num_rates; i++) |
| 2557 | { |
| 2558 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 2559 | { |
| 2560 | /* If rate set have 11g rate than change the mode to 11G */ |
| 2561 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 2562 | if (pIe[i] & BASIC_RATE_MASK) |
| 2563 | { |
| 2564 | /* If we have 11g rate as basic rate, it means mode |
| 2565 | is 11g only mode. |
| 2566 | */ |
| 2567 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 2568 | *pCheckRatesfor11g = FALSE; |
| 2569 | } |
| 2570 | } |
| 2571 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 2572 | { |
| 2573 | *require_ht = TRUE; |
| 2574 | } |
| 2575 | } |
| 2576 | return; |
| 2577 | } |
| 2578 | |
| 2579 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 2580 | { |
| 2581 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 2582 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 2583 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 2584 | u8 checkRatesfor11g = TRUE; |
| 2585 | u8 require_ht = FALSE; |
| 2586 | u8 *pIe=NULL; |
| 2587 | |
| 2588 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 2589 | |
| 2590 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 2591 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 2592 | if (pIe != NULL) |
| 2593 | { |
| 2594 | pIe += 1; |
| 2595 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 2596 | &pConfig->SapHw_mode); |
| 2597 | } |
| 2598 | |
| 2599 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 2600 | WLAN_EID_EXT_SUPP_RATES); |
| 2601 | if (pIe != NULL) |
| 2602 | { |
| 2603 | |
| 2604 | pIe += 1; |
| 2605 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 2606 | &pConfig->SapHw_mode); |
| 2607 | } |
| 2608 | |
| 2609 | if( pConfig->channel > 14 ) |
| 2610 | { |
| 2611 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 2612 | } |
| 2613 | |
| 2614 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 2615 | WLAN_EID_HT_CAPABILITY); |
| 2616 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2617 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2618 | { |
| 2619 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 2620 | if(require_ht) |
| 2621 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 2622 | } |
| 2623 | } |
| 2624 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2625 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 2626 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 2627 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 2628 | v_U16_t ielen = 0; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2629 | v_U8_t *pIe = NULL; |
| 2630 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 2631 | |
| 2632 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 2633 | pBeacon->tail, pBeacon->tail_len); |
| 2634 | |
| 2635 | if (pIe) |
| 2636 | { |
| 2637 | ielen = pIe[1] + 2; |
| 2638 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 2639 | { |
| 2640 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 2641 | } |
| 2642 | else |
| 2643 | { |
| 2644 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 2645 | return -EINVAL; |
| 2646 | } |
| 2647 | *total_ielen += ielen; |
| 2648 | } |
| 2649 | return 0; |
| 2650 | } |
| 2651 | |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 2652 | static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter, |
| 2653 | v_U8_t *genie, v_U8_t *total_ielen) |
| 2654 | { |
| 2655 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 2656 | int left = pBeacon->tail_len; |
| 2657 | v_U8_t *ptr = pBeacon->tail; |
| 2658 | v_U8_t elem_id, elem_len; |
| 2659 | v_U16_t ielen = 0; |
| 2660 | |
| 2661 | if ( NULL == ptr || 0 == left ) |
| 2662 | return; |
| 2663 | |
| 2664 | while (left >= 2) |
| 2665 | { |
| 2666 | elem_id = ptr[0]; |
| 2667 | elem_len = ptr[1]; |
| 2668 | left -= 2; |
| 2669 | if (elem_len > left) |
| 2670 | { |
| 2671 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 2672 | "****Invalid IEs eid = %d elem_len=%d left=%d*****", |
| 2673 | elem_id, elem_len, left); |
| 2674 | return; |
| 2675 | } |
| 2676 | if (IE_EID_VENDOR == elem_id) |
| 2677 | { |
| 2678 | /* skipping the VSIE's which we don't want to include or |
| 2679 | * it will be included by existing code |
| 2680 | */ |
| 2681 | if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) && |
| 2682 | #ifdef WLAN_FEATURE_WFD |
| 2683 | (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) && |
| 2684 | #endif |
| 2685 | (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 2686 | (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 2687 | (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) && |
| 2688 | (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 2689 | (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0)) |
| 2690 | { |
| 2691 | ielen = ptr[1] + 2; |
| 2692 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 2693 | { |
| 2694 | vos_mem_copy(&genie[*total_ielen], ptr, ielen); |
| 2695 | *total_ielen += ielen; |
| 2696 | } |
| 2697 | else |
| 2698 | { |
| 2699 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 2700 | "IE Length is too big " |
| 2701 | "IEs eid=%d elem_len=%d total_ie_lent=%d", |
| 2702 | elem_id, elem_len, *total_ielen); |
| 2703 | } |
| 2704 | } |
| 2705 | } |
| 2706 | |
| 2707 | left -= elem_len; |
| 2708 | ptr += (elem_len + 2); |
| 2709 | } |
| 2710 | return; |
| 2711 | } |
| 2712 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2713 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2714 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 2715 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2716 | #else |
| 2717 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 2718 | struct cfg80211_beacon_data *params) |
| 2719 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2720 | { |
| 2721 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2722 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2723 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2724 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2725 | |
| 2726 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 2727 | |
| 2728 | if(genie == NULL) { |
| 2729 | |
| 2730 | return -ENOMEM; |
| 2731 | } |
| 2732 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2733 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 2734 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2735 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2736 | hddLog(LOGE, |
| 2737 | FL("Adding WPS IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2738 | ret = -EINVAL; |
| 2739 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2740 | } |
| 2741 | |
| 2742 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2743 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 2744 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 2745 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2746 | hddLog(LOGE, |
| 2747 | FL("Adding WFD IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2748 | ret = -EINVAL; |
| 2749 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2750 | } |
| 2751 | #endif |
| 2752 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2753 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 2754 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2755 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2756 | hddLog(LOGE, |
| 2757 | FL("Adding P2P IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2758 | ret = -EINVAL; |
| 2759 | goto done; |
| 2760 | } |
| 2761 | |
| 2762 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 2763 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 2764 | wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2765 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2766 | |
| 2767 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2768 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 2769 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 2770 | { |
| 2771 | hddLog(LOGE, |
| 2772 | "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] | 2773 | ret = -EINVAL; |
| 2774 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2775 | } |
| 2776 | |
| 2777 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2778 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 2779 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 2780 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 2781 | ==eHAL_STATUS_FAILURE) |
| 2782 | { |
| 2783 | hddLog(LOGE, |
| 2784 | "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] | 2785 | ret = -EINVAL; |
| 2786 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2787 | } |
| 2788 | |
| 2789 | // Added for ProResp IE |
| 2790 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 2791 | { |
| 2792 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 2793 | u8 probe_rsp_ie_len[3] = {0}; |
| 2794 | u8 counter = 0; |
| 2795 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 2796 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 2797 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 2798 | Store More then 255 bytes into One Variable. |
| 2799 | */ |
| 2800 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 2801 | { |
| 2802 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 2803 | { |
| 2804 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 2805 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 2806 | } |
| 2807 | else |
| 2808 | { |
| 2809 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 2810 | rem_probe_resp_ie_len = 0; |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | rem_probe_resp_ie_len = 0; |
| 2815 | |
| 2816 | if (probe_rsp_ie_len[0] > 0) |
| 2817 | { |
| 2818 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2819 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 2820 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 2821 | probe_rsp_ie_len[0], NULL, |
| 2822 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 2823 | { |
| 2824 | hddLog(LOGE, |
| 2825 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2826 | ret = -EINVAL; |
| 2827 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2828 | } |
| 2829 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 2830 | } |
| 2831 | |
| 2832 | if (probe_rsp_ie_len[1] > 0) |
| 2833 | { |
| 2834 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2835 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 2836 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 2837 | probe_rsp_ie_len[1], NULL, |
| 2838 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 2839 | { |
| 2840 | hddLog(LOGE, |
| 2841 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2842 | ret = -EINVAL; |
| 2843 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2844 | } |
| 2845 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 2846 | } |
| 2847 | |
| 2848 | if (probe_rsp_ie_len[2] > 0) |
| 2849 | { |
| 2850 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2851 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 2852 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 2853 | probe_rsp_ie_len[2], NULL, |
| 2854 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 2855 | { |
| 2856 | hddLog(LOGE, |
| 2857 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2858 | ret = -EINVAL; |
| 2859 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2860 | } |
| 2861 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 2862 | } |
| 2863 | |
| 2864 | if (probe_rsp_ie_len[1] == 0 ) |
| 2865 | { |
| 2866 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2867 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 2868 | eANI_BOOLEAN_FALSE) ) |
| 2869 | { |
| 2870 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2871 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2872 | } |
| 2873 | } |
| 2874 | |
| 2875 | if (probe_rsp_ie_len[2] == 0 ) |
| 2876 | { |
| 2877 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2878 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 2879 | eANI_BOOLEAN_FALSE) ) |
| 2880 | { |
| 2881 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2882 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2883 | } |
| 2884 | } |
| 2885 | |
| 2886 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2887 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 2888 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 2889 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 2890 | == eHAL_STATUS_FAILURE) |
| 2891 | { |
| 2892 | hddLog(LOGE, |
| 2893 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2894 | ret = -EINVAL; |
| 2895 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2896 | } |
| 2897 | } |
| 2898 | else |
| 2899 | { |
| 2900 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2901 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 2902 | |
| 2903 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2904 | "%s: No Probe Response IE received in set beacon", |
| 2905 | __func__); |
| 2906 | } |
| 2907 | |
| 2908 | // Added for AssocResp IE |
| 2909 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 2910 | { |
| 2911 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2912 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 2913 | params->assocresp_ies_len, NULL, |
| 2914 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 2915 | { |
| 2916 | hddLog(LOGE, |
| 2917 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2918 | ret = -EINVAL; |
| 2919 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2920 | } |
| 2921 | |
| 2922 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2923 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 2924 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 2925 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 2926 | == eHAL_STATUS_FAILURE) |
| 2927 | { |
| 2928 | hddLog(LOGE, |
| 2929 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2930 | ret = -EINVAL; |
| 2931 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2932 | } |
| 2933 | } |
| 2934 | else |
| 2935 | { |
| 2936 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2937 | "%s: No Assoc Response IE received in set beacon", |
| 2938 | __func__); |
| 2939 | |
| 2940 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 2941 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2942 | eANI_BOOLEAN_FALSE) ) |
| 2943 | { |
| 2944 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2945 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2946 | } |
| 2947 | } |
| 2948 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2949 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2950 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 2951 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2952 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2953 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2954 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2955 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 2956 | * called by wlan_hdd_cfg80211_start_bss() and |
| 2957 | * wlan_hdd_cfg80211_set_channel() |
| 2958 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2959 | * channel list. |
| 2960 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 2961 | 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] | 2962 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2963 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2964 | v_U32_t num_ch = 0; |
| 2965 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 2966 | u32 indx = 0; |
| 2967 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 2968 | v_U8_t fValidChannel = FALSE, count = 0; |
| 2969 | 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] | 2970 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2971 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 2972 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 2973 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2974 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 2975 | /* Validate the channel */ |
| 2976 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2977 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 2978 | if ( channel == rfChannels[count].channelNum ) |
| 2979 | { |
| 2980 | fValidChannel = TRUE; |
| 2981 | break; |
| 2982 | } |
| 2983 | } |
| 2984 | if (fValidChannel != TRUE) |
| 2985 | { |
| 2986 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2987 | "%s: Invalid Channel [%d]", __func__, channel); |
| 2988 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2989 | } |
| 2990 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 2991 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2992 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 2993 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 2994 | valid_ch, &num_ch)) |
| 2995 | { |
| 2996 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2997 | "%s: failed to get valid channel list", __func__); |
| 2998 | return VOS_STATUS_E_FAILURE; |
| 2999 | } |
| 3000 | for (indx = 0; indx < num_ch; indx++) |
| 3001 | { |
| 3002 | if (channel == valid_ch[indx]) |
| 3003 | { |
| 3004 | break; |
| 3005 | } |
| 3006 | } |
| 3007 | |
Rashmi Ramanna | 3b59e12 | 2014-04-10 14:45:13 +0530 | [diff] [blame] | 3008 | if (indx >= num_ch) |
| 3009 | { |
| 3010 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 3011 | { |
| 3012 | eCsrBand band; |
| 3013 | unsigned int freq; |
| 3014 | |
| 3015 | sme_GetFreqBand(hHal, &band); |
| 3016 | |
| 3017 | if (eCSR_BAND_5G == band) |
| 3018 | { |
| 3019 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3020 | if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3021 | { |
| 3022 | freq = ieee80211_channel_to_frequency(channel, |
| 3023 | IEEE80211_BAND_2GHZ); |
| 3024 | } |
| 3025 | else |
| 3026 | { |
| 3027 | freq = ieee80211_channel_to_frequency(channel, |
| 3028 | IEEE80211_BAND_5GHZ); |
| 3029 | } |
| 3030 | #else |
| 3031 | freq = ieee80211_channel_to_frequency(channel); |
| 3032 | #endif |
| 3033 | if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq)) |
| 3034 | return VOS_STATUS_SUCCESS; |
| 3035 | } |
| 3036 | } |
| 3037 | |
| 3038 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3039 | "%s: Invalid Channel [%d]", __func__, channel); |
| 3040 | return VOS_STATUS_E_FAILURE; |
| 3041 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3042 | } |
Rashmi Ramanna | 3b59e12 | 2014-04-10 14:45:13 +0530 | [diff] [blame] | 3043 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3044 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3045 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3046 | } |
| 3047 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3048 | /** |
| 3049 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 3050 | * This function is used to set the channel number |
| 3051 | */ |
| 3052 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 3053 | struct ieee80211_channel *chan, |
| 3054 | enum nl80211_channel_type channel_type |
| 3055 | ) |
| 3056 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3057 | hdd_adapter_t *pAdapter = NULL; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3058 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 3059 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3060 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3061 | hdd_context_t *pHddCtx; |
| 3062 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3063 | |
| 3064 | ENTER(); |
| 3065 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3066 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3067 | if( NULL == dev ) |
| 3068 | { |
| 3069 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3070 | "%s: Called with dev = NULL.", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3071 | return -ENODEV; |
| 3072 | } |
| 3073 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 3074 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3075 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3076 | TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId, |
| 3077 | channel_type )); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3078 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 3079 | "%s: device_mode = %s (%d) freq = %d", __func__, |
| 3080 | hdd_device_modetoString(pAdapter->device_mode), |
| 3081 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3082 | |
| 3083 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3084 | status = wlan_hdd_validate_context(pHddCtx); |
| 3085 | |
| 3086 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3087 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3088 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3089 | "%s: HDD context is not valid", __func__); |
| 3090 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3091 | } |
| 3092 | |
| 3093 | /* |
| 3094 | * Do freq to chan conversion |
| 3095 | * TODO: for 11a |
| 3096 | */ |
| 3097 | |
| 3098 | channel = ieee80211_frequency_to_channel(freq); |
| 3099 | |
| 3100 | /* Check freq range */ |
| 3101 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 3102 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 3103 | { |
| 3104 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3105 | "%s: Channel [%d] is outside valid range from %d to %d", |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3106 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 3107 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 3108 | return -EINVAL; |
| 3109 | } |
| 3110 | |
| 3111 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 3112 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 3113 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 3114 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3115 | { |
| 3116 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 3117 | { |
| 3118 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3119 | "%s: Invalid Channel [%d]", __func__, channel); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3120 | return -EINVAL; |
| 3121 | } |
| 3122 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 3123 | "%s: set channel to [%d] for device mode =%d", |
| 3124 | __func__, channel,pAdapter->device_mode); |
| 3125 | } |
| 3126 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3127 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3128 | ) |
| 3129 | { |
| 3130 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3131 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 3132 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3133 | |
| 3134 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 3135 | { |
| 3136 | /* Link is up then return cant set channel*/ |
| 3137 | hddLog( VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3138 | "%s: IBSS Associated, can't set the channel", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3139 | return -EINVAL; |
| 3140 | } |
| 3141 | |
| 3142 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 3143 | pHddStaCtx->conn_info.operationChannel = channel; |
| 3144 | pRoamProfile->ChannelInfo.ChannelList = |
| 3145 | &pHddStaCtx->conn_info.operationChannel; |
| 3146 | } |
| 3147 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3148 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3149 | ) |
| 3150 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 3151 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 3152 | { |
| 3153 | if(VOS_STATUS_SUCCESS != |
| 3154 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 3155 | { |
| 3156 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3157 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 3158 | return -EINVAL; |
| 3159 | } |
| 3160 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 3161 | } |
| 3162 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3163 | { |
| 3164 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3165 | |
| 3166 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 3167 | channel set by supplicant |
| 3168 | */ |
| 3169 | if ( cfg_param->apAutoChannelSelection ) |
| 3170 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 3171 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 3172 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3173 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 3174 | "%s: set channel to auto channel (0) for device mode =%s (%d)", |
| 3175 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 3176 | pAdapter->device_mode); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3177 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 3178 | else |
| 3179 | { |
| 3180 | if(VOS_STATUS_SUCCESS != |
| 3181 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 3182 | { |
| 3183 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3184 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 3185 | return -EINVAL; |
| 3186 | } |
| 3187 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 3188 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3189 | } |
| 3190 | } |
| 3191 | else |
| 3192 | { |
| 3193 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 3194 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 3195 | return -EINVAL; |
| 3196 | } |
| 3197 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3198 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 3199 | } |
| 3200 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3201 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 3202 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 3203 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3204 | #else |
| 3205 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 3206 | struct cfg80211_beacon_data *params, |
| 3207 | const u8 *ssid, size_t ssid_len, |
| 3208 | enum nl80211_hidden_ssid hidden_ssid) |
| 3209 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3210 | { |
| 3211 | tsap_Config_t *pConfig; |
| 3212 | beacon_data_t *pBeacon = NULL; |
| 3213 | struct ieee80211_mgmt *pMgmt_frame; |
| 3214 | v_U8_t *pIe=NULL; |
| 3215 | v_U16_t capab_info; |
| 3216 | eCsrAuthType RSNAuthType; |
| 3217 | eCsrEncryptionType RSNEncryptType; |
| 3218 | eCsrEncryptionType mcRSNEncryptType; |
| 3219 | int status = VOS_STATUS_SUCCESS; |
| 3220 | tpWLAN_SAPEventCB pSapEventCallback; |
| 3221 | hdd_hostapd_state_t *pHostapdState; |
| 3222 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 3223 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 3224 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3225 | struct qc_mac_acl_entry *acl_entry = NULL; |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 3226 | hdd_config_t *iniConfig; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3227 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 3228 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Chet Lanctot | 4014244 | 2014-05-20 13:39:25 -0700 | [diff] [blame] | 3229 | v_BOOL_t MFPCapable = VOS_FALSE; |
| 3230 | v_BOOL_t MFPRequired = VOS_FALSE; |
Abhishek Singh | f0ac175 | 2014-03-05 17:47:09 +0530 | [diff] [blame] | 3231 | eHddDot11Mode sapDot11Mode = |
| 3232 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3233 | |
| 3234 | ENTER(); |
| 3235 | |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 3236 | iniConfig = pHddCtx->cfg_ini; |
| 3237 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3238 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 3239 | |
| 3240 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 3241 | |
| 3242 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 3243 | |
| 3244 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 3245 | |
| 3246 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 3247 | |
| 3248 | //channel is already set in the set_channel Call back |
| 3249 | //pConfig->channel = pCommitConfig->channel; |
| 3250 | |
| 3251 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3252 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3253 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 3254 | |
| 3255 | pConfig->dtim_period = pBeacon->dtim_period; |
| 3256 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3257 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3258 | pConfig->dtim_period); |
| 3259 | |
| 3260 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 3261 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3262 | { |
| 3263 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3264 | WLAN_EID_COUNTRY); |
Kiet Lam | 083504c | 2013-11-25 14:17:45 +0530 | [diff] [blame] | 3265 | if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0) |
| 3266 | { |
| 3267 | tANI_BOOLEAN restartNeeded; |
| 3268 | pConfig->ieee80211d = 1; |
| 3269 | vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3); |
| 3270 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 3271 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
| 3272 | } |
| 3273 | else if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3274 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3275 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3276 | pConfig->ieee80211d = 1; |
| 3277 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 3278 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 3279 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3280 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3281 | else |
| 3282 | { |
| 3283 | pConfig->ieee80211d = 0; |
| 3284 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 3285 | /* |
| 3286 | * If auto channel is configured i.e. channel is 0, |
| 3287 | * so skip channel validation. |
| 3288 | */ |
| 3289 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 3290 | { |
| 3291 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 3292 | { |
| 3293 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3294 | "%s: Invalid Channel [%d]", __func__, pConfig->channel); |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 3295 | return -EINVAL; |
| 3296 | } |
| 3297 | } |
| 3298 | else |
| 3299 | { |
| 3300 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 3301 | { |
| 3302 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 3303 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 3304 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 3305 | } |
| 3306 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 3307 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3308 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3309 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3310 | { |
| 3311 | pConfig->ieee80211d = 0; |
| 3312 | } |
| 3313 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 3314 | |
| 3315 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3316 | |
| 3317 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3318 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 3319 | |
| 3320 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 3321 | |
| 3322 | /*Set wps station to configured*/ |
| 3323 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 3324 | |
| 3325 | if(pIe) |
| 3326 | { |
| 3327 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 3328 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3329 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3330 | return -EINVAL; |
| 3331 | } |
| 3332 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 3333 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 3334 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3335 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 3336 | * WPS state |
| 3337 | */ |
| 3338 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 3339 | { |
| 3340 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 3341 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 3342 | { |
| 3343 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 3344 | } |
| 3345 | } |
| 3346 | } |
| 3347 | else |
| 3348 | { |
| 3349 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 3350 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3351 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3352 | |
| 3353 | pConfig->RSNWPAReqIELength = 0; |
| 3354 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3355 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3356 | WLAN_EID_RSN); |
| 3357 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3358 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3359 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 3360 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 3361 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3362 | /* The actual processing may eventually be more extensive than |
| 3363 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3364 | * by the app. |
| 3365 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3366 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3367 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 3368 | &RSNEncryptType, |
| 3369 | &mcRSNEncryptType, |
| 3370 | &RSNAuthType, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 3371 | &MFPCapable, |
| 3372 | &MFPRequired, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3373 | pConfig->pRSNWPAReqIE[1]+2, |
| 3374 | pConfig->pRSNWPAReqIE ); |
| 3375 | |
| 3376 | if( VOS_STATUS_SUCCESS == status ) |
| 3377 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3378 | /* Now copy over all the security attributes you have |
| 3379 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3380 | * */ |
| 3381 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 3382 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 3383 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 3384 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 3385 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3386 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3387 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 3388 | } |
| 3389 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3390 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3391 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 3392 | pBeacon->tail, pBeacon->tail_len); |
| 3393 | |
| 3394 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 3395 | { |
| 3396 | if (pConfig->pRSNWPAReqIE) |
| 3397 | { |
| 3398 | /*Mixed mode WPA/WPA2*/ |
| 3399 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 3400 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 3401 | } |
| 3402 | else |
| 3403 | { |
| 3404 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 3405 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 3406 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3407 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3408 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 3409 | &RSNEncryptType, |
| 3410 | &mcRSNEncryptType, |
| 3411 | &RSNAuthType, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 3412 | &MFPCapable, |
| 3413 | &MFPRequired, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3414 | pConfig->pRSNWPAReqIE[1]+2, |
| 3415 | pConfig->pRSNWPAReqIE ); |
| 3416 | |
| 3417 | if( VOS_STATUS_SUCCESS == status ) |
| 3418 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3419 | /* Now copy over all the security attributes you have |
| 3420 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3421 | * */ |
| 3422 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 3423 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 3424 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 3425 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 3426 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3427 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3428 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 3429 | } |
| 3430 | } |
| 3431 | } |
| 3432 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 3433 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 3434 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 3435 | return -EINVAL; |
| 3436 | } |
| 3437 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3438 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 3439 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3440 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3441 | if (params->ssid != NULL) |
| 3442 | { |
| 3443 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 3444 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 3445 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 3446 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 3447 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3448 | #else |
| 3449 | if (ssid != NULL) |
| 3450 | { |
| 3451 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 3452 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 3453 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 3454 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 3455 | } |
| 3456 | #endif |
| 3457 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3458 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3459 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3460 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3461 | /* default value */ |
| 3462 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 3463 | pConfig->num_accept_mac = 0; |
| 3464 | pConfig->num_deny_mac = 0; |
| 3465 | |
| 3466 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 3467 | pBeacon->tail, pBeacon->tail_len); |
| 3468 | |
| 3469 | /* pIe for black list is following form: |
| 3470 | type : 1 byte |
| 3471 | length : 1 byte |
| 3472 | OUI : 4 bytes |
| 3473 | acl type : 1 byte |
| 3474 | no of mac addr in black list: 1 byte |
| 3475 | 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] | 3476 | */ |
| 3477 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3478 | { |
| 3479 | pConfig->SapMacaddr_acl = pIe[6]; |
| 3480 | pConfig->num_deny_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3481 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3482 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 3483 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 3484 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3485 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 3486 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 3487 | { |
| 3488 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 3489 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3490 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3491 | } |
| 3492 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 3493 | pBeacon->tail, pBeacon->tail_len); |
| 3494 | |
| 3495 | /* pIe for white list is following form: |
| 3496 | type : 1 byte |
| 3497 | length : 1 byte |
| 3498 | OUI : 4 bytes |
| 3499 | acl type : 1 byte |
| 3500 | no of mac addr in white list: 1 byte |
| 3501 | 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] | 3502 | */ |
| 3503 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3504 | { |
| 3505 | pConfig->SapMacaddr_acl = pIe[6]; |
| 3506 | pConfig->num_accept_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3507 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3508 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 3509 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 3510 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3511 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 3512 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 3513 | { |
| 3514 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 3515 | acl_entry++; |
| 3516 | } |
| 3517 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 3518 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3519 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 3520 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3521 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 3522 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 3523 | * This is valid only if mode is set to 11n in hostapd, either AUTO or |
| 3524 | * 11ac in .ini and 11ac is supported by both host and firmware. |
| 3525 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) |
| 3526 | */ |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 3527 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 3528 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Abhishek Singh | f0ac175 | 2014-03-05 17:47:09 +0530 | [diff] [blame] | 3529 | (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) || |
| 3530 | ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) || |
| 3531 | ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) && |
| 3532 | (sme_IsFeatureSupportedByDriver(DOT11AC)) && |
| 3533 | (sme_IsFeatureSupportedByFW(DOT11AC)) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3534 | { |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 3535 | v_U32_t operatingBand = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3536 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 3537 | ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand); |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 3538 | |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 3539 | /* If ACS disable and selected channel <= 14 |
| 3540 | * OR |
| 3541 | * ACS enabled and ACS operating band is choosen as 2.4 |
| 3542 | * AND |
| 3543 | * VHT in 2.4G Disabled |
| 3544 | * THEN |
| 3545 | * Fallback to 11N mode |
| 3546 | */ |
| 3547 | if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END) |
| 3548 | || (AUTO_CHANNEL_SELECT == pConfig->channel && |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 3549 | operatingBand == RF_SUBBAND_2_4_GHZ)) && |
Siddharth Bhal | 5cba24e | 2014-05-08 18:59:39 +0530 | [diff] [blame] | 3550 | iniConfig->enableVhtFor24GHzBand == FALSE) |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 3551 | { |
Siddharth Bhal | f42f859 | 2014-05-15 13:39:07 +0530 | [diff] [blame] | 3552 | hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"), |
| 3553 | operatingBand, pConfig->channel); |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 3554 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 3555 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3556 | } |
| 3557 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3558 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 3559 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 3560 | { |
| 3561 | sme_SelectCBMode(hHal, |
| 3562 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 3563 | pConfig->channel); |
| 3564 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3565 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 3566 | pConfig->ht_capab = |
| 3567 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 3568 | |
| 3569 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 3570 | { |
| 3571 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 3572 | return -EINVAL; |
| 3573 | } |
| 3574 | |
| 3575 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3576 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3577 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 3578 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3579 | pConfig->obssProtEnabled = |
| 3580 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3581 | |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 3582 | #ifdef WLAN_FEATURE_11W |
| 3583 | pConfig->mfpCapable = MFPCapable; |
| 3584 | pConfig->mfpRequired = MFPRequired; |
| 3585 | hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"), |
| 3586 | pConfig->mfpCapable, pConfig->mfpRequired); |
| 3587 | #endif |
| 3588 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3589 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3590 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3591 | hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"), |
| 3592 | pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int, |
| 3593 | (int)pConfig->channel); |
| 3594 | hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"), |
| 3595 | pConfig->SapHw_mode, pConfig->privacy, |
| 3596 | pConfig->authType); |
| 3597 | hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"), |
| 3598 | (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable); |
| 3599 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"), |
| 3600 | pConfig->protEnabled, pConfig->obssProtEnabled); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3601 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3602 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3603 | { |
| 3604 | //Bss already started. just return. |
| 3605 | //TODO Probably it should update some beacon params. |
| 3606 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 3607 | EXIT(); |
| 3608 | return 0; |
| 3609 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3611 | pConfig->persona = pHostapdAdapter->device_mode; |
| 3612 | |
| 3613 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 3614 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 3615 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 3616 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3617 | hddLog(LOGE,FL("SAP Start Bss fail")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3618 | return -EINVAL; |
| 3619 | } |
| 3620 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3621 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3622 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 3623 | |
| 3624 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3625 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3626 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3627 | { |
| 3628 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3629 | ("ERROR: HDD vos wait for single_event failed!!")); |
Tushnim Bhattacharyya | ad37df1 | 2013-10-02 12:01:33 -0700 | [diff] [blame] | 3630 | smeGetCommandQStatus(hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3631 | VOS_ASSERT(0); |
| 3632 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3633 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3634 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 3635 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 3636 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 3637 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 3638 | { |
| 3639 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 3640 | { |
| 3641 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 3642 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 3643 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 3644 | } |
| 3645 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 3646 | { |
| 3647 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 3648 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 3649 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 3650 | } |
| 3651 | } |
| 3652 | #endif |
| 3653 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3654 | pHostapdState->bCommit = TRUE; |
| 3655 | EXIT(); |
| 3656 | |
| 3657 | return 0; |
| 3658 | } |
| 3659 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3660 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3661 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 3662 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3663 | struct beacon_parameters *params) |
| 3664 | { |
| 3665 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3666 | hdd_context_t *pHddCtx; |
| 3667 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3668 | |
| 3669 | ENTER(); |
| 3670 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3671 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3672 | TRACE_CODE_HDD_CFG80211_ADD_BEACON, |
| 3673 | pAdapter->sessionId, params->interval)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 3674 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)", |
| 3675 | hdd_device_modetoString(pAdapter->device_mode), |
| 3676 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3677 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3678 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3679 | status = wlan_hdd_validate_context(pHddCtx); |
| 3680 | |
| 3681 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3682 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3683 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3684 | "%s: HDD context is not valid", __func__); |
| 3685 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3686 | } |
| 3687 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3688 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3689 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3690 | ) |
| 3691 | { |
| 3692 | beacon_data_t *old,*new; |
| 3693 | |
| 3694 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3695 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3696 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3697 | { |
| 3698 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 3699 | FL("already beacon info added to session(%d)"), |
| 3700 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3701 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3702 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3703 | |
| 3704 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 3705 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3706 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3707 | { |
| 3708 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3709 | "%s:Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3710 | return -EINVAL; |
| 3711 | } |
| 3712 | |
| 3713 | pAdapter->sessionCtx.ap.beacon = new; |
| 3714 | |
| 3715 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 3716 | } |
| 3717 | |
| 3718 | EXIT(); |
| 3719 | return status; |
| 3720 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3721 | |
| 3722 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3723 | struct net_device *dev, |
| 3724 | struct beacon_parameters *params) |
| 3725 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3726 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3727 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3728 | hdd_context_t *pHddCtx; |
| 3729 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3730 | |
| 3731 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3732 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3733 | TRACE_CODE_HDD_CFG80211_SET_BEACON, |
| 3734 | pAdapter->sessionId, pHddStaCtx->conn_info.authType)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 3735 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 3736 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 3737 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3738 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3739 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3740 | status = wlan_hdd_validate_context(pHddCtx); |
| 3741 | |
| 3742 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3743 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3744 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3745 | "%s: HDD context is not valid", __func__); |
| 3746 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3747 | } |
| 3748 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3749 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3750 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3751 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3752 | { |
| 3753 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3754 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3755 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3756 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3757 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3758 | { |
| 3759 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3760 | FL("session(%d) old and new heads points to NULL"), |
| 3761 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3762 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3763 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3764 | |
| 3765 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 3766 | |
| 3767 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3768 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3769 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3770 | return -EINVAL; |
| 3771 | } |
| 3772 | |
| 3773 | pAdapter->sessionCtx.ap.beacon = new; |
| 3774 | |
| 3775 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 3776 | } |
| 3777 | |
| 3778 | EXIT(); |
| 3779 | return status; |
| 3780 | } |
| 3781 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3782 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 3783 | |
| 3784 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3785 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 3786 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3787 | #else |
| 3788 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 3789 | struct net_device *dev) |
| 3790 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3791 | { |
| 3792 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3793 | hdd_context_t *pHddCtx = NULL; |
| 3794 | hdd_scaninfo_t *pScanInfo = NULL; |
| 3795 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3796 | VOS_STATUS status; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3797 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3798 | |
| 3799 | ENTER(); |
| 3800 | |
| 3801 | if (NULL == pAdapter) |
| 3802 | { |
| 3803 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 3804 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3805 | return -ENODEV; |
| 3806 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 3807 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3808 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3809 | TRACE_CODE_HDD_CFG80211_STOP_AP, |
| 3810 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3811 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3812 | status = wlan_hdd_validate_context(pHddCtx); |
| 3813 | |
| 3814 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 3815 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3816 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3817 | "%s: HDD context is not valid", __func__); |
| 3818 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 3819 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 3820 | |
| 3821 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 3822 | if (NULL == staAdapter) |
| 3823 | { |
| 3824 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 3825 | if (NULL == staAdapter) |
| 3826 | { |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 3827 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 3828 | "%s: HDD adapter context for STA/P2P-CLI is Null", |
| 3829 | __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 3830 | } |
| 3831 | } |
| 3832 | |
| 3833 | pScanInfo = &pHddCtx->scan_info; |
| 3834 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 3835 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 3836 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 3837 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3838 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3839 | ret = wlan_hdd_scan_abort(pAdapter); |
| 3840 | |
| 3841 | if (ret <= 0) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3842 | { |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3843 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3844 | FL("Timeout occurred while waiting for abortscan %ld"), ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3845 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3846 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3847 | { |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3848 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3849 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 3850 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3851 | VOS_ASSERT(pScanInfo->mScanPending); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3852 | return -EAGAIN; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3853 | } |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 3854 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3855 | } |
| 3856 | |
Arun Kumar Khandavalli | a3bd800 | 2014-01-17 16:21:19 +0530 | [diff] [blame] | 3857 | hdd_hostapd_stop(dev); |
| 3858 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3859 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3860 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3861 | ) |
| 3862 | { |
| 3863 | beacon_data_t *old; |
| 3864 | |
| 3865 | old = pAdapter->sessionCtx.ap.beacon; |
| 3866 | |
| 3867 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3868 | { |
| 3869 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3870 | FL("session(%d) beacon data points to NULL"), |
| 3871 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3872 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3873 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3874 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3875 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3876 | |
| 3877 | mutex_lock(&pHddCtx->sap_lock); |
| 3878 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 3879 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 3880 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3881 | { |
| 3882 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3883 | |
| 3884 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 3885 | |
| 3886 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 3887 | { |
| 3888 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3889 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3890 | VOS_ASSERT(0); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3891 | } |
| 3892 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3893 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 3894 | } |
| 3895 | mutex_unlock(&pHddCtx->sap_lock); |
| 3896 | |
| 3897 | if(status != VOS_STATUS_SUCCESS) |
| 3898 | { |
| 3899 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3900 | "%s:Error!!! Stopping the BSS",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3901 | return -EINVAL; |
| 3902 | } |
| 3903 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 3904 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3905 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 3906 | ==eHAL_STATUS_FAILURE) |
| 3907 | { |
| 3908 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3909 | "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] | 3910 | } |
| 3911 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 3912 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3913 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 3914 | eANI_BOOLEAN_FALSE) ) |
| 3915 | { |
| 3916 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3917 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3918 | } |
| 3919 | |
| 3920 | // Reset WNI_CFG_PROBE_RSP Flags |
| 3921 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 3922 | |
| 3923 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 3924 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 3925 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 3926 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 3927 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 3928 | { |
| 3929 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 3930 | "GO got removed"); |
| 3931 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 3932 | } |
| 3933 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3934 | } |
| 3935 | EXIT(); |
| 3936 | return status; |
| 3937 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3938 | |
| 3939 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 3940 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3941 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 3942 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3943 | struct cfg80211_ap_settings *params) |
| 3944 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3945 | hdd_adapter_t *pAdapter; |
| 3946 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3947 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3948 | |
| 3949 | ENTER(); |
| 3950 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3951 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 3952 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3953 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3954 | "%s: Device is Null", __func__); |
| 3955 | return -ENODEV; |
| 3956 | } |
| 3957 | |
| 3958 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3959 | if (NULL == pAdapter) |
| 3960 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3961 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3962 | "%s: HDD adapter is Null", __func__); |
| 3963 | return -ENODEV; |
| 3964 | } |
| 3965 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3966 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3967 | TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId, |
| 3968 | params-> beacon_interval)); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3969 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 3970 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3971 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3972 | "%s: HDD adapter magic is invalid", __func__); |
| 3973 | return -ENODEV; |
| 3974 | } |
| 3975 | |
| 3976 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3977 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3978 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3979 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3980 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3981 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3982 | "%s: HDD context is not valid", __func__); |
| 3983 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3984 | } |
| 3985 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 3986 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)", |
| 3987 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 3988 | pAdapter->device_mode); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3989 | |
| 3990 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3991 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3992 | ) |
| 3993 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3994 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3995 | |
| 3996 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 3997 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3998 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3999 | { |
| 4000 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 4001 | FL("already beacon info added to session(%d)"), |
| 4002 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4003 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4004 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4005 | |
| 4006 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 4007 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 4008 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4009 | { |
| 4010 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 4011 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4012 | return -EINVAL; |
| 4013 | } |
| 4014 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 4015 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4016 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 4017 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 4018 | params->channel, params->channel_type); |
| 4019 | #else |
| 4020 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 4021 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 4022 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4023 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 4024 | params->ssid_len, params->hidden_ssid); |
| 4025 | } |
| 4026 | |
| 4027 | EXIT(); |
| 4028 | return status; |
| 4029 | } |
| 4030 | |
| 4031 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4032 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4033 | struct net_device *dev, |
| 4034 | struct cfg80211_beacon_data *params) |
| 4035 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4036 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4037 | hdd_context_t *pHddCtx; |
| 4038 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4039 | |
| 4040 | ENTER(); |
| 4041 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4042 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4043 | TRACE_CODE_HDD_CFG80211_CHANGE_BEACON, |
| 4044 | pAdapter->sessionId, pAdapter->device_mode)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4045 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4046 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4047 | |
| 4048 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4049 | status = wlan_hdd_validate_context(pHddCtx); |
| 4050 | |
| 4051 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 4052 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4053 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4054 | "%s: HDD context is not valid", __func__); |
| 4055 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 4056 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4057 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4058 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4059 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4060 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4061 | { |
| 4062 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4063 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4064 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4065 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4066 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4067 | { |
| 4068 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4069 | FL("session(%d) beacon data points to NULL"), |
| 4070 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4071 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4072 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4073 | |
| 4074 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 4075 | |
| 4076 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4077 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4078 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4079 | return -EINVAL; |
| 4080 | } |
| 4081 | |
| 4082 | pAdapter->sessionCtx.ap.beacon = new; |
| 4083 | |
| 4084 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 4085 | } |
| 4086 | |
| 4087 | EXIT(); |
| 4088 | return status; |
| 4089 | } |
| 4090 | |
| 4091 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 4092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4093 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 4094 | static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4095 | struct net_device *dev, |
| 4096 | struct bss_parameters *params) |
| 4097 | { |
| 4098 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4099 | |
| 4100 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4101 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4102 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4103 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
| 4104 | pAdapter->sessionId, params->ap_isolate)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 4105 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 4106 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 4107 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4108 | |
| 4109 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4110 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4111 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4112 | { |
| 4113 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 4114 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4115 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4116 | { |
| 4117 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4118 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4119 | } |
| 4120 | |
| 4121 | EXIT(); |
| 4122 | return 0; |
| 4123 | } |
| 4124 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 4125 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 4126 | struct net_device *dev, |
| 4127 | struct bss_parameters *params) |
| 4128 | { |
| 4129 | int ret; |
| 4130 | |
| 4131 | vos_ssr_protect(__func__); |
| 4132 | ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
| 4133 | vos_ssr_unprotect(__func__); |
| 4134 | |
| 4135 | return ret; |
| 4136 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4137 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 4138 | * to wait for contry code completion |
| 4139 | */ |
| 4140 | void* wlan_hdd_change_country_code_cb(void *pAdapter) |
| 4141 | { |
| 4142 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 4143 | complete(&call_back_pAdapter->change_country_code); |
| 4144 | return NULL; |
| 4145 | } |
| 4146 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4147 | /* |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 4148 | * FUNCTION: __wlan_hdd_cfg80211_change_iface |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4149 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 4150 | */ |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 4151 | int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4152 | struct net_device *ndev, |
| 4153 | enum nl80211_iftype type, |
| 4154 | u32 *flags, |
| 4155 | struct vif_params *params |
| 4156 | ) |
| 4157 | { |
| 4158 | struct wireless_dev *wdev; |
| 4159 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 4160 | hdd_context_t *pHddCtx; |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 4161 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4162 | tCsrRoamProfile *pRoamProfile = NULL; |
| 4163 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4164 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4165 | eMib_dot11DesiredBssType connectedBssType; |
| 4166 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4167 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4168 | |
| 4169 | ENTER(); |
| 4170 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4171 | if (!pAdapter) |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 4172 | { |
| 4173 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4174 | "%s: Adapter context is null", __func__); |
| 4175 | return VOS_STATUS_E_FAILURE; |
| 4176 | } |
| 4177 | |
| 4178 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4179 | if (!pHddCtx) |
| 4180 | { |
| 4181 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4182 | "%s: HDD context is null", __func__); |
| 4183 | return VOS_STATUS_E_FAILURE; |
| 4184 | } |
| 4185 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4186 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4187 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
| 4188 | pAdapter->sessionId, type)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4189 | status = wlan_hdd_validate_context(pHddCtx); |
| 4190 | |
| 4191 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4192 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4193 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4194 | "%s: HDD context is not valid", __func__); |
| 4195 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4196 | } |
| 4197 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 4198 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 4199 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 4200 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4201 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4202 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4203 | wdev = ndev->ieee80211_ptr; |
| 4204 | |
| 4205 | #ifdef WLAN_BTAMP_FEATURE |
| 4206 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 4207 | (NL80211_IFTYPE_ADHOC == type)|| |
| 4208 | (NL80211_IFTYPE_AP == type)|| |
| 4209 | (NL80211_IFTYPE_P2P_GO == type)) |
| 4210 | { |
| 4211 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 4212 | // stop AMP traffic |
| 4213 | status = WLANBAP_StopAmp(); |
| 4214 | if(VOS_STATUS_SUCCESS != status ) |
| 4215 | { |
| 4216 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 4217 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4218 | "%s: Failed to stop AMP", __func__); |
| 4219 | return -EINVAL; |
| 4220 | } |
| 4221 | } |
| 4222 | #endif //WLAN_BTAMP_FEATURE |
| 4223 | /* Reset the current device mode bit mask*/ |
| 4224 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 4225 | |
| 4226 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4227 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4228 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4229 | ) |
| 4230 | { |
| 4231 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 4232 | if (!pWextState) |
| 4233 | { |
| 4234 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4235 | "%s: pWextState is null", __func__); |
| 4236 | return VOS_STATUS_E_FAILURE; |
| 4237 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4238 | pRoamProfile = &pWextState->roamProfile; |
| 4239 | LastBSSType = pRoamProfile->BSSType; |
| 4240 | |
| 4241 | switch (type) |
| 4242 | { |
| 4243 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4244 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4245 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4246 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 4247 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4248 | #ifdef WLAN_FEATURE_11AC |
| 4249 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 4250 | { |
| 4251 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 4252 | } |
| 4253 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4254 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4255 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4256 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 4257 | //Check for sub-string p2p to confirm its a p2p interface |
| 4258 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4259 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 4260 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 4261 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 4262 | } |
| 4263 | else |
| 4264 | { |
| 4265 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4266 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 4267 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 4268 | #ifdef FEATURE_WLAN_TDLS |
| 4269 | /* The open adapter for the p2p shall skip initializations in |
| 4270 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 4271 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 4272 | * tdls_init when the change_iface sets the device mode to |
| 4273 | * WLAN_HDD_P2P_CLIENT. |
| 4274 | */ |
| 4275 | |
| 4276 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 4277 | { |
| 4278 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 4279 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4280 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4281 | "%s: tdls initialization failed", __func__); |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 4282 | return -EINVAL; |
| 4283 | } |
| 4284 | } |
| 4285 | #endif |
| 4286 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4287 | break; |
| 4288 | case NL80211_IFTYPE_ADHOC: |
| 4289 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4290 | "%s: setting interface Type to ADHOC", __func__); |
| 4291 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 4292 | pRoamProfile->phyMode = |
| 4293 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 4294 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4295 | wdev->iftype = type; |
| 4296 | break; |
| 4297 | |
| 4298 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4299 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4300 | { |
| 4301 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 4302 | "%s: setting interface Type to %s", __func__, |
| 4303 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 4304 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 4305 | //Cancel any remain on channel for GO mode |
| 4306 | if (NL80211_IFTYPE_P2P_GO == type) |
| 4307 | { |
| 4308 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 4309 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 4310 | if (NL80211_IFTYPE_AP == type) |
| 4311 | { |
| 4312 | /* As Loading WLAN Driver one interface being created for p2p device |
| 4313 | * address. This will take one HW STA and the max number of clients |
| 4314 | * that can connect to softAP will be reduced by one. so while changing |
| 4315 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 4316 | * interface as it is not required in SoftAP mode. |
| 4317 | */ |
| 4318 | |
| 4319 | // Get P2P Adapter |
| 4320 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 4321 | |
| 4322 | if (pP2pAdapter) |
| 4323 | { |
| 4324 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 4325 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 4326 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 4327 | } |
| 4328 | } |
Swaroop Golti | a2e3221 | 2014-04-09 23:37:33 +0530 | [diff] [blame] | 4329 | //Disable IMPS & BMPS for SAP/GO |
| 4330 | if(VOS_STATUS_E_FAILURE == |
| 4331 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 4332 | { |
| 4333 | //Fail to Exit BMPS |
| 4334 | VOS_ASSERT(0); |
| 4335 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4336 | #ifdef FEATURE_WLAN_TDLS |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 4337 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4338 | /* A Mutex Lock is introduced while changing the mode to |
| 4339 | * protect the concurrent access for the Adapters by TDLS |
| 4340 | * module. |
| 4341 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 4342 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4343 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4344 | //De-init the adapter. |
| 4345 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 4346 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 4347 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4348 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 4349 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4350 | #ifdef FEATURE_WLAN_TDLS |
| 4351 | mutex_unlock(&pHddCtx->tdls_lock); |
| 4352 | #endif |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 4353 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 4354 | (pConfig->apRandomBssidEnabled)) |
| 4355 | { |
| 4356 | /* To meet Android requirements create a randomized |
| 4357 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 4358 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 4359 | ndev->dev_addr[0] = 0x02; |
| 4360 | ndev->dev_addr[1] = 0x1A; |
| 4361 | ndev->dev_addr[2] = 0x11; |
| 4362 | ndev->dev_addr[3] |= 0xF0; |
| 4363 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 4364 | VOS_MAC_ADDR_SIZE); |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4365 | pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n", |
| 4366 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 4367 | } |
| 4368 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4369 | hdd_set_ap_ops( pAdapter->dev ); |
| 4370 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4371 | /* This is for only SAP mode where users can |
| 4372 | * control country through ini. |
| 4373 | * P2P GO follows station country code |
| 4374 | * acquired during the STA scanning. */ |
| 4375 | if((NL80211_IFTYPE_AP == type) && |
| 4376 | (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)) |
| 4377 | { |
| 4378 | int status = 0; |
| 4379 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO, |
| 4380 | "%s: setting country code from INI ", __func__); |
| 4381 | init_completion(&pAdapter->change_country_code); |
| 4382 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 4383 | (void *)(tSmeChangeCountryCallback) |
| 4384 | wlan_hdd_change_country_code_cb, |
| 4385 | pConfig->apCntryCode, pAdapter, |
| 4386 | pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4387 | eSIR_FALSE, |
| 4388 | eSIR_TRUE); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4389 | if (eHAL_STATUS_SUCCESS == status) |
| 4390 | { |
| 4391 | /* Wait for completion */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4392 | ret = wait_for_completion_interruptible_timeout( |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4393 | &pAdapter->change_country_code, |
| 4394 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4395 | if (ret <= 0) |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4396 | { |
| 4397 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4398 | FL("SME Timed out while setting country code %ld"), |
| 4399 | ret); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 4400 | |
| 4401 | if (pHddCtx->isLogpInProgress) |
| 4402 | { |
| 4403 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4404 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 4405 | return -EAGAIN; |
| 4406 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4407 | } |
| 4408 | } |
| 4409 | else |
| 4410 | { |
| 4411 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4412 | "%s: SME Change Country code failed",__func__); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 4413 | return -EINVAL; |
| 4414 | } |
| 4415 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4416 | status = hdd_init_ap_mode(pAdapter); |
| 4417 | if(status != VOS_STATUS_SUCCESS) |
| 4418 | { |
| 4419 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4420 | "%s: Error initializing the ap mode", __func__); |
| 4421 | return -EINVAL; |
| 4422 | } |
| 4423 | hdd_set_conparam(1); |
| 4424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4425 | /*interface type changed update in wiphy structure*/ |
| 4426 | if(wdev) |
| 4427 | { |
| 4428 | wdev->iftype = type; |
| 4429 | pHddCtx->change_iface = type; |
| 4430 | } |
| 4431 | else |
| 4432 | { |
| 4433 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4434 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 4435 | return -EINVAL; |
| 4436 | } |
| 4437 | goto done; |
| 4438 | } |
| 4439 | |
| 4440 | default: |
| 4441 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 4442 | __func__); |
| 4443 | return -EOPNOTSUPP; |
| 4444 | } |
| 4445 | } |
| 4446 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4447 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4448 | ) |
| 4449 | { |
| 4450 | switch(type) |
| 4451 | { |
| 4452 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4453 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4454 | case NL80211_IFTYPE_ADHOC: |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4455 | #ifdef FEATURE_WLAN_TDLS |
| 4456 | |
| 4457 | /* A Mutex Lock is introduced while changing the mode to |
| 4458 | * protect the concurrent access for the Adapters by TDLS |
| 4459 | * module. |
| 4460 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 4461 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4462 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4463 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 4464 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4465 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 4466 | //Check for sub-string p2p to confirm its a p2p interface |
| 4467 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 4468 | { |
| 4469 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 4470 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 4471 | } |
| 4472 | else |
| 4473 | { |
| 4474 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4475 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 4476 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4477 | hdd_set_conparam(0); |
| 4478 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4479 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 4480 | hdd_set_station_ops( pAdapter->dev ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4481 | #ifdef FEATURE_WLAN_TDLS |
| 4482 | mutex_unlock(&pHddCtx->tdls_lock); |
| 4483 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 4484 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4485 | if( VOS_STATUS_SUCCESS != status ) |
| 4486 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4487 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 4488 | * This is the right place to enable back bmps_imps() |
| 4489 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 4490 | if (pHddCtx->hdd_wlan_suspended) |
| 4491 | { |
| 4492 | hdd_set_pwrparams(pHddCtx); |
| 4493 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4494 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4495 | goto done; |
| 4496 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4497 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4498 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4499 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 4500 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4501 | goto done; |
| 4502 | default: |
| 4503 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 4504 | __func__); |
| 4505 | return -EOPNOTSUPP; |
| 4506 | |
| 4507 | } |
| 4508 | |
| 4509 | } |
| 4510 | else |
| 4511 | { |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 4512 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))", |
| 4513 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 4514 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4515 | return -EOPNOTSUPP; |
| 4516 | } |
| 4517 | |
| 4518 | |
| 4519 | if(pRoamProfile) |
| 4520 | { |
| 4521 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 4522 | { |
| 4523 | /*interface type changed update in wiphy structure*/ |
| 4524 | wdev->iftype = type; |
| 4525 | |
| 4526 | /*the BSS mode changed, We need to issue disconnect |
| 4527 | if connected or in IBSS disconnect state*/ |
| 4528 | if ( hdd_connGetConnectedBssType( |
| 4529 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 4530 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 4531 | { |
| 4532 | /*need to issue a disconnect to CSR.*/ |
| 4533 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 4534 | if( eHAL_STATUS_SUCCESS == |
| 4535 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4536 | pAdapter->sessionId, |
| 4537 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4538 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4539 | ret = wait_for_completion_interruptible_timeout( |
| 4540 | &pAdapter->disconnect_comp_var, |
| 4541 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4542 | if (ret <= 0) |
| 4543 | { |
| 4544 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4545 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 4546 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4547 | } |
| 4548 | } |
| 4549 | } |
| 4550 | } |
| 4551 | |
| 4552 | done: |
| 4553 | /*set bitmask based on updated value*/ |
| 4554 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 4555 | |
| 4556 | /* Only STA mode support TM now |
| 4557 | * all other mode, TM feature should be disabled */ |
| 4558 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 4559 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 4560 | { |
| 4561 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 4562 | } |
| 4563 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4564 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4565 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4566 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 4567 | { |
| 4568 | //we are ok to do AMP |
| 4569 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 4570 | } |
| 4571 | #endif //WLAN_BTAMP_FEATURE |
| 4572 | EXIT(); |
| 4573 | return 0; |
| 4574 | } |
| 4575 | |
Mahesh A Saptasagar | 0e59c47 | 2014-04-14 19:17:41 +0530 | [diff] [blame] | 4576 | /* |
| 4577 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 4578 | * wrapper function to protect the actual implementation from SSR. |
| 4579 | */ |
| 4580 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 4581 | struct net_device *ndev, |
| 4582 | enum nl80211_iftype type, |
| 4583 | u32 *flags, |
| 4584 | struct vif_params *params |
| 4585 | ) |
| 4586 | { |
| 4587 | int ret; |
| 4588 | |
| 4589 | vos_ssr_protect(__func__); |
| 4590 | ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params); |
| 4591 | vos_ssr_unprotect(__func__); |
| 4592 | |
| 4593 | return ret; |
| 4594 | } |
| 4595 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4596 | #ifdef FEATURE_WLAN_TDLS |
| 4597 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 4598 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 4599 | { |
| 4600 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4601 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 4602 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4603 | hddTdlsPeer_t *pTdlsPeer; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4604 | long ret; |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 4605 | tANI_U16 numCurrTdlsPeers; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4606 | |
| 4607 | ENTER(); |
| 4608 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 4609 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4610 | { |
| 4611 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4612 | "Invalid arguments"); |
| 4613 | return -EINVAL; |
| 4614 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 4615 | |
| 4616 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 4617 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 4618 | { |
| 4619 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4620 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 4621 | MAC_ADDRESS_STR " Request declined.", |
| 4622 | __func__, MAC_ADDR_ARRAY(mac)); |
| 4623 | return -ENOTSUPP; |
| 4624 | } |
| 4625 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4626 | if (pHddCtx->isLogpInProgress) |
| 4627 | { |
| 4628 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4629 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 4630 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4631 | return -EBUSY; |
| 4632 | } |
| 4633 | |
Naresh Jayaram | 9c6f446 | 2014-02-13 12:20:31 +0530 | [diff] [blame] | 4634 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4635 | |
| 4636 | if ( NULL == pTdlsPeer ) { |
| 4637 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4638 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 4639 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 4640 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 4641 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4642 | |
| 4643 | /* in add station, we accept existing valid staId if there is */ |
| 4644 | if ((0 == update) && |
| 4645 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 4646 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4647 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4648 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4649 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4650 | " link_status %d. staId %d. add station ignored.", |
| 4651 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 4652 | return 0; |
| 4653 | } |
| 4654 | /* in change station, we accept only when staId is valid */ |
| 4655 | if ((1 == update) && |
| 4656 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 4657 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 4658 | { |
| 4659 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4660 | "%s: " MAC_ADDRESS_STR |
| 4661 | " link status %d. staId %d. change station %s.", |
| 4662 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 4663 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 4664 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4665 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 4666 | |
| 4667 | /* 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] | 4668 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4669 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 4670 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4671 | "%s: " MAC_ADDRESS_STR |
| 4672 | " TDLS setup is ongoing. Request declined.", |
| 4673 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 4674 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4675 | } |
| 4676 | |
| 4677 | /* first to check if we reached to maximum supported TDLS peer. |
| 4678 | TODO: for now, return -EPERM looks working fine, |
| 4679 | but need to check if any other errno fit into this category.*/ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 4680 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 4681 | if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4682 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 4683 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4684 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 4685 | " TDLS Max peer already connected. Request declined." |
| 4686 | " Num of peers (%d), Max allowed (%d).", |
| 4687 | __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers, |
| 4688 | HDD_MAX_NUM_TDLS_STA); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 4689 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4690 | } |
| 4691 | else |
| 4692 | { |
| 4693 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 4694 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4695 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4696 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 4697 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4698 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 4699 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4700 | return -EPERM; |
| 4701 | } |
| 4702 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4703 | if (0 == update) |
| 4704 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4705 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 4706 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 4707 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4708 | { |
| 4709 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4710 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 4711 | if(StaParams->htcap_present) |
| 4712 | { |
| 4713 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4714 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 4715 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4716 | "ht_capa->extended_capabilities: %0x", |
| 4717 | StaParams->HTCap.extendedHtCapInfo); |
| 4718 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4719 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4720 | "params->capability: %0x",StaParams->capability); |
| 4721 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 4722 | "params->ext_capab_len: %0x",StaParams->extn_capability[0]); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 4723 | if(StaParams->vhtcap_present) |
| 4724 | { |
| 4725 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4726 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 4727 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 4728 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 4729 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4730 | { |
| 4731 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4732 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4733 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 4734 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 4735 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 4736 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 4737 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 4738 | else if ((1 == update) && (NULL == StaParams)) |
| 4739 | { |
| 4740 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4741 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 4742 | return -EPERM; |
| 4743 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4744 | |
| 4745 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 4746 | |
| 4747 | if (!update) |
| 4748 | { |
| 4749 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4750 | pAdapter->sessionId, mac); |
| 4751 | } |
| 4752 | else |
| 4753 | { |
| 4754 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4755 | pAdapter->sessionId, mac, StaParams); |
| 4756 | } |
| 4757 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4758 | ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4759 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 4760 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4761 | if (ret <= 0) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4762 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 4763 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4764 | "%s: timeout waiting for tdls add station indication %ld", |
| 4765 | __func__, ret); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 4766 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4767 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4768 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4769 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 4770 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 4771 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4772 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 4773 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4774 | } |
| 4775 | |
| 4776 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 4777 | |
| 4778 | error: |
| 4779 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 4780 | return -EPERM; |
| 4781 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4782 | } |
| 4783 | #endif |
| 4784 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4785 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 4786 | struct net_device *dev, |
| 4787 | u8 *mac, |
| 4788 | struct station_parameters *params) |
| 4789 | { |
| 4790 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 4791 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4792 | hdd_context_t *pHddCtx; |
| 4793 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4794 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 4795 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4796 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4797 | tANI_U8 isBufSta = 0; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 4798 | tANI_U8 isOffChannelSupported = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 4799 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4800 | ENTER(); |
| 4801 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4802 | if ((NULL == pAdapter)) |
| 4803 | { |
| 4804 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4805 | "invalid adapter "); |
| 4806 | return -EINVAL; |
| 4807 | } |
| 4808 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4809 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4810 | TRACE_CODE_HDD_CHANGE_STATION, |
| 4811 | pAdapter->sessionId, params->listen_interval)); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4812 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4813 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4814 | |
| 4815 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 4816 | { |
| 4817 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4818 | "invalid HDD state or HDD station context"); |
| 4819 | return -EINVAL; |
| 4820 | } |
| 4821 | |
| 4822 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4823 | { |
| 4824 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4825 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 4826 | return -EAGAIN; |
| 4827 | } |
| 4828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4829 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 4830 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4831 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 4832 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4833 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4834 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4835 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4836 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4837 | WLANTL_STA_AUTHENTICATED); |
| 4838 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4839 | if (status != VOS_STATUS_SUCCESS) |
| 4840 | { |
| 4841 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4842 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 4843 | return -EINVAL; |
| 4844 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4845 | } |
| 4846 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 4847 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 4848 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4849 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4850 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 4851 | StaParams.capability = params->capability; |
| 4852 | StaParams.uapsd_queues = params->uapsd_queues; |
| 4853 | StaParams.max_sp = params->max_sp; |
| 4854 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 4855 | /* Convert (first channel , number of channels) tuple to |
| 4856 | * the total list of channels. This goes with the assumption |
| 4857 | * that if the first channel is < 14, then the next channels |
| 4858 | * are an incremental of 1 else an incremental of 4 till the number |
| 4859 | * of channels. |
| 4860 | */ |
| 4861 | if (0 != params->supported_channels_len) { |
| 4862 | int i = 0,j = 0,k = 0, no_of_channels = 0 ; |
| 4863 | for ( i = 0 ; i < params->supported_channels_len ; i+=2) |
| 4864 | { |
| 4865 | int wifi_chan_index; |
| 4866 | StaParams.supported_channels[j] = params->supported_channels[i]; |
| 4867 | wifi_chan_index = |
| 4868 | ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 ); |
| 4869 | no_of_channels = params->supported_channels[i+1]; |
| 4870 | for(k=1; k <= no_of_channels; k++) |
| 4871 | { |
| 4872 | StaParams.supported_channels[j+1] = |
| 4873 | StaParams.supported_channels[j] + wifi_chan_index; |
| 4874 | j+=1; |
| 4875 | } |
| 4876 | } |
| 4877 | StaParams.supported_channels_len = j; |
| 4878 | } |
| 4879 | vos_mem_copy(StaParams.supported_oper_classes, |
| 4880 | params->supported_oper_classes, |
| 4881 | params->supported_oper_classes_len); |
| 4882 | StaParams.supported_oper_classes_len = |
| 4883 | params->supported_oper_classes_len; |
| 4884 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4885 | if (0 != params->ext_capab_len) |
| 4886 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 4887 | sizeof(StaParams.extn_capability)); |
| 4888 | |
| 4889 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 4890 | { |
| 4891 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4892 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 4893 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4894 | |
| 4895 | StaParams.supported_rates_len = params->supported_rates_len; |
| 4896 | |
| 4897 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 4898 | * The supported_rates array , for all the structures propogating till Add Sta |
| 4899 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 4900 | * modified to send more rates. |
| 4901 | */ |
| 4902 | |
| 4903 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 4904 | */ |
| 4905 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 4906 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 4907 | |
| 4908 | if (0 != StaParams.supported_rates_len) { |
| 4909 | int i = 0; |
| 4910 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 4911 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4912 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4913 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 4914 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 4915 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4916 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 4917 | } |
| 4918 | |
| 4919 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 4920 | { |
| 4921 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4922 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 4923 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 4924 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4925 | if (0 != params->ext_capab_len ) { |
| 4926 | /*Define A Macro : TODO Sunil*/ |
| 4927 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 4928 | isBufSta = 1; |
| 4929 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 4930 | /* TDLS Channel Switching Support */ |
| 4931 | if ((1<<6) & StaParams.extn_capability[3]) { |
| 4932 | isOffChannelSupported = 1; |
| 4933 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4934 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 4935 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, |
| 4936 | &StaParams, isBufSta, |
| 4937 | isOffChannelSupported); |
| 4938 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 4939 | if (VOS_STATUS_SUCCESS != status) { |
| 4940 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4941 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 4942 | return -EINVAL; |
| 4943 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4944 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 4945 | |
| 4946 | if (VOS_STATUS_SUCCESS != status) { |
| 4947 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4948 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 4949 | return -EINVAL; |
| 4950 | } |
| 4951 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 4952 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 4953 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4954 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4955 | return status; |
| 4956 | } |
| 4957 | |
| 4958 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4959 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 4960 | * This function is used to initialize the key information |
| 4961 | */ |
| 4962 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 4963 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4964 | struct net_device *ndev, |
| 4965 | u8 key_index, bool pairwise, |
| 4966 | const u8 *mac_addr, |
| 4967 | struct key_params *params |
| 4968 | ) |
| 4969 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 4970 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4971 | struct net_device *ndev, |
| 4972 | u8 key_index, const u8 *mac_addr, |
| 4973 | struct key_params *params |
| 4974 | ) |
| 4975 | #endif |
| 4976 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 4977 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4978 | tCsrRoamSetKey setKey; |
| 4979 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4980 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 4981 | v_U32_t roamId= 0xFF; |
| 4982 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4983 | hdd_hostapd_state_t *pHostapdState; |
| 4984 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 4985 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4986 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4987 | |
| 4988 | ENTER(); |
| 4989 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4990 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4991 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
| 4992 | pAdapter->sessionId, params->key_len)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4993 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4994 | status = wlan_hdd_validate_context(pHddCtx); |
| 4995 | |
| 4996 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4997 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4998 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4999 | "%s: HDD context is not valid", __func__); |
| 5000 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5001 | } |
| 5002 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 5003 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 5004 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 5005 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5006 | |
| 5007 | if (CSR_MAX_NUM_KEY <= key_index) |
| 5008 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5009 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5010 | key_index); |
| 5011 | |
| 5012 | return -EINVAL; |
| 5013 | } |
| 5014 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5015 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 5016 | { |
| 5017 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 5018 | params->key_len); |
| 5019 | |
| 5020 | return -EINVAL; |
| 5021 | } |
| 5022 | |
| 5023 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5024 | "%s: called with key index = %d & key length %d", |
| 5025 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5026 | |
| 5027 | /*extract key idx, key len and key*/ |
| 5028 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 5029 | setKey.keyId = key_index; |
| 5030 | setKey.keyLength = params->key_len; |
| 5031 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 5032 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5033 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5034 | { |
| 5035 | case WLAN_CIPHER_SUITE_WEP40: |
| 5036 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5037 | break; |
| 5038 | |
| 5039 | case WLAN_CIPHER_SUITE_WEP104: |
| 5040 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 5041 | break; |
| 5042 | |
| 5043 | case WLAN_CIPHER_SUITE_TKIP: |
| 5044 | { |
| 5045 | u8 *pKey = &setKey.Key[0]; |
| 5046 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5047 | |
| 5048 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 5049 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5050 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5051 | |
| 5052 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5053 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5054 | |--------------|----------|----------| |
| 5055 | <---16bytes---><--8bytes--><--8bytes--> |
| 5056 | |
| 5057 | */ |
| 5058 | /*Sme expects the 32 bytes key to be in the below order |
| 5059 | |
| 5060 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5061 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5062 | |--------------|----------|----------| |
| 5063 | <---16bytes---><--8bytes--><--8bytes--> |
| 5064 | */ |
| 5065 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5066 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5067 | |
| 5068 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5069 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5070 | |
| 5071 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5072 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5073 | |
| 5074 | |
| 5075 | break; |
| 5076 | } |
| 5077 | |
| 5078 | case WLAN_CIPHER_SUITE_CCMP: |
| 5079 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 5080 | break; |
| 5081 | |
| 5082 | #ifdef FEATURE_WLAN_WAPI |
| 5083 | case WLAN_CIPHER_SUITE_SMS4: |
| 5084 | { |
| 5085 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 5086 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 5087 | params->key, params->key_len); |
| 5088 | return 0; |
| 5089 | } |
| 5090 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5091 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5092 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5093 | case WLAN_CIPHER_SUITE_KRK: |
| 5094 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 5095 | break; |
| 5096 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5097 | |
| 5098 | #ifdef WLAN_FEATURE_11W |
| 5099 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 5100 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 5101 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5102 | #endif |
| 5103 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5104 | default: |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5105 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5106 | __func__, params->cipher); |
| 5107 | return -EOPNOTSUPP; |
| 5108 | } |
| 5109 | |
| 5110 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 5111 | __func__, setKey.encType); |
| 5112 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5113 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5114 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5115 | (!pairwise) |
| 5116 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5117 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5118 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5119 | ) |
| 5120 | { |
| 5121 | /* set group key*/ |
| 5122 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5123 | "%s- %d: setting Broadcast key", |
| 5124 | __func__, __LINE__); |
| 5125 | setKey.keyDirection = eSIR_RX_ONLY; |
| 5126 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 5127 | } |
| 5128 | else |
| 5129 | { |
| 5130 | /* set pairwise key*/ |
| 5131 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5132 | "%s- %d: setting pairwise key", |
| 5133 | __func__, __LINE__); |
| 5134 | setKey.keyDirection = eSIR_TX_RX; |
| 5135 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 5136 | } |
| 5137 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 5138 | { |
| 5139 | setKey.keyDirection = eSIR_TX_RX; |
| 5140 | /*Set the group key*/ |
| 5141 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5142 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5143 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5144 | if ( 0 != status ) |
| 5145 | { |
| 5146 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5147 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 5148 | return -EINVAL; |
| 5149 | } |
| 5150 | /*Save the keys here and call sme_RoamSetKey for setting |
| 5151 | the PTK after peer joins the IBSS network*/ |
| 5152 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 5153 | &setKey, sizeof(tCsrRoamSetKey)); |
| 5154 | return status; |
| 5155 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5156 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 5157 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 5158 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5159 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5160 | if( pHostapdState->bssState == BSS_START ) |
| 5161 | { |
c_hpothu | 7c55da6 | 2014-01-23 18:34:02 +0530 | [diff] [blame] | 5162 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5163 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 5164 | |
| 5165 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 5166 | { |
| 5167 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5168 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 5169 | __LINE__, vos_status ); |
| 5170 | |
| 5171 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 5172 | |
| 5173 | return -EINVAL; |
| 5174 | } |
| 5175 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5176 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 5177 | |
| 5178 | if ( status != eHAL_STATUS_SUCCESS ) |
| 5179 | { |
| 5180 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5181 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 5182 | __LINE__, status ); |
| 5183 | } |
| 5184 | } |
| 5185 | |
| 5186 | /* Saving WEP keys */ |
| 5187 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 5188 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 5189 | { |
| 5190 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 5191 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 5192 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 5193 | } |
| 5194 | else |
| 5195 | { |
| 5196 | //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] | 5197 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5198 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 5199 | } |
| 5200 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5201 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 5202 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5203 | { |
| 5204 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5205 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5206 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 5207 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5208 | if (!pairwise) |
| 5209 | #else |
| 5210 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 5211 | #endif |
| 5212 | { |
| 5213 | /* set group key*/ |
| 5214 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 5215 | { |
| 5216 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5217 | "%s- %d: Perform Set key Complete", |
| 5218 | __func__, __LINE__); |
| 5219 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 5220 | } |
| 5221 | } |
| 5222 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5223 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 5224 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 5225 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 5226 | |
| 5227 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 5228 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5229 | params->key, params->key_len); |
| 5230 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 5231 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5232 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 5233 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5234 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5235 | "%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] | 5236 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 5237 | setKey.peerMac[2], setKey.peerMac[3], |
| 5238 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5239 | setKey.keyDirection); |
| 5240 | |
| 5241 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 5242 | |
| 5243 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 5244 | { |
| 5245 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5246 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 5247 | __LINE__, vos_status ); |
| 5248 | |
| 5249 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 5250 | |
| 5251 | return -EINVAL; |
| 5252 | |
| 5253 | } |
| 5254 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5255 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 5256 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 5257 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 5258 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5259 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 5260 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5261 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 5262 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 5263 | "%s: Update PreAuth Key success", __func__); |
| 5264 | return 0; |
| 5265 | } |
| 5266 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 5267 | { |
| 5268 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5269 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 5270 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5271 | } |
| 5272 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5273 | |
| 5274 | /* issue set key request to SME*/ |
| 5275 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5276 | pAdapter->sessionId, &setKey, &roamId ); |
| 5277 | |
| 5278 | if ( 0 != status ) |
| 5279 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5280 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5281 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 5282 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 5283 | return -EINVAL; |
| 5284 | } |
| 5285 | |
| 5286 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5287 | /* in case of IBSS as there was no information available about WEP keys during |
| 5288 | * 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] | 5289 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5290 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 5291 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 5292 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5293 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 5294 | ) |
| 5295 | && |
| 5296 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 5297 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 5298 | ) |
| 5299 | ) |
| 5300 | { |
| 5301 | setKey.keyDirection = eSIR_RX_ONLY; |
| 5302 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 5303 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5304 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5305 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5306 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 5307 | setKey.peerMac[2], setKey.peerMac[3], |
| 5308 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5309 | setKey.keyDirection); |
| 5310 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5311 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5312 | pAdapter->sessionId, &setKey, &roamId ); |
| 5313 | |
| 5314 | if ( 0 != status ) |
| 5315 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5316 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5317 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5318 | __func__, status); |
| 5319 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 5320 | return -EINVAL; |
| 5321 | } |
| 5322 | } |
| 5323 | } |
| 5324 | |
| 5325 | return 0; |
| 5326 | } |
| 5327 | |
| 5328 | /* |
| 5329 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 5330 | * This function is used to get the key information |
| 5331 | */ |
| 5332 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5333 | static int wlan_hdd_cfg80211_get_key( |
| 5334 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5335 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5336 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5337 | const u8 *mac_addr, void *cookie, |
| 5338 | void (*callback)(void *cookie, struct key_params*) |
| 5339 | ) |
| 5340 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5341 | static int wlan_hdd_cfg80211_get_key( |
| 5342 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5343 | struct net_device *ndev, |
| 5344 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 5345 | void (*callback)(void *cookie, struct key_params*) |
| 5346 | ) |
| 5347 | #endif |
| 5348 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5349 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5350 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5351 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 5352 | struct key_params params; |
| 5353 | |
| 5354 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5355 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 5356 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 5357 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 5358 | pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5359 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5360 | memset(¶ms, 0, sizeof(params)); |
| 5361 | |
| 5362 | if (CSR_MAX_NUM_KEY <= key_index) |
| 5363 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5364 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5365 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5366 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5367 | |
| 5368 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 5369 | { |
| 5370 | case eCSR_ENCRYPT_TYPE_NONE: |
| 5371 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 5372 | break; |
| 5373 | |
| 5374 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 5375 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 5376 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 5377 | break; |
| 5378 | |
| 5379 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 5380 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 5381 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 5382 | break; |
| 5383 | |
| 5384 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 5385 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 5386 | break; |
| 5387 | |
| 5388 | case eCSR_ENCRYPT_TYPE_AES: |
| 5389 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 5390 | break; |
| 5391 | |
| 5392 | default: |
| 5393 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 5394 | break; |
| 5395 | } |
| 5396 | |
c_hpothu | aaf1969 | 2014-05-17 17:01:48 +0530 | [diff] [blame] | 5397 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 5398 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
| 5399 | pAdapter->sessionId, params.cipher)); |
| 5400 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5401 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 5402 | params.seq_len = 0; |
| 5403 | params.seq = NULL; |
| 5404 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 5405 | callback(cookie, ¶ms); |
| 5406 | return 0; |
| 5407 | } |
| 5408 | |
| 5409 | /* |
| 5410 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 5411 | * This function is used to delete the key information |
| 5412 | */ |
| 5413 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5414 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5415 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5416 | u8 key_index, |
| 5417 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5418 | const u8 *mac_addr |
| 5419 | ) |
| 5420 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5421 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5422 | struct net_device *ndev, |
| 5423 | u8 key_index, |
| 5424 | const u8 *mac_addr |
| 5425 | ) |
| 5426 | #endif |
| 5427 | { |
| 5428 | int status = 0; |
| 5429 | |
| 5430 | //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] | 5431 | //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] | 5432 | //it is observed that this is invalidating peer |
| 5433 | //key index whenever re-key is done. This is affecting data link. |
| 5434 | //It should be ok to ignore del_key. |
| 5435 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5436 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 5437 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5438 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5439 | tCsrRoamSetKey setKey; |
| 5440 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5441 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5442 | ENTER(); |
| 5443 | |
| 5444 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 5445 | __func__,pAdapter->device_mode); |
| 5446 | |
| 5447 | if (CSR_MAX_NUM_KEY <= key_index) |
| 5448 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5449 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5450 | key_index); |
| 5451 | |
| 5452 | return -EINVAL; |
| 5453 | } |
| 5454 | |
| 5455 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 5456 | setKey.keyId = key_index; |
| 5457 | |
| 5458 | if (mac_addr) |
| 5459 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 5460 | else |
| 5461 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 5462 | |
| 5463 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 5464 | |
| 5465 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5466 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5467 | ) |
| 5468 | { |
| 5469 | |
| 5470 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5471 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 5472 | if( pHostapdState->bssState == BSS_START) |
| 5473 | { |
| 5474 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5475 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5476 | if ( status != eHAL_STATUS_SUCCESS ) |
| 5477 | { |
| 5478 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5479 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 5480 | __LINE__, status ); |
| 5481 | } |
| 5482 | } |
| 5483 | } |
| 5484 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5485 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5486 | ) |
| 5487 | { |
| 5488 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5489 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5490 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 5491 | |
| 5492 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5493 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5494 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 5495 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5496 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5497 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 5498 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5499 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5500 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5501 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5502 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5503 | if ( 0 != status ) |
| 5504 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5505 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5506 | "%s: sme_RoamSetKey failure, returned %d", |
| 5507 | __func__, status); |
| 5508 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 5509 | return -EINVAL; |
| 5510 | } |
| 5511 | } |
| 5512 | } |
| 5513 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5514 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5515 | return status; |
| 5516 | } |
| 5517 | |
| 5518 | /* |
| 5519 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 5520 | * This function is used to set the default tx key index |
| 5521 | */ |
| 5522 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5523 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 5524 | struct net_device *ndev, |
| 5525 | u8 key_index, |
| 5526 | bool unicast, bool multicast) |
| 5527 | #else |
| 5528 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 5529 | struct net_device *ndev, |
| 5530 | u8 key_index) |
| 5531 | #endif |
| 5532 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5533 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5534 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5535 | hdd_wext_state_t *pWextState; |
| 5536 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5537 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5538 | |
| 5539 | ENTER(); |
| 5540 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5541 | if ((NULL == pAdapter)) |
| 5542 | { |
| 5543 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5544 | "invalid adapter"); |
| 5545 | return -EINVAL; |
| 5546 | } |
| 5547 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5548 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 5549 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
| 5550 | pAdapter->sessionId, key_index)); |
| 5551 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5552 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5553 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5554 | |
| 5555 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 5556 | { |
| 5557 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5558 | "invalid Wext state or HDD context"); |
| 5559 | return -EINVAL; |
| 5560 | } |
| 5561 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5562 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5563 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5564 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5565 | if (CSR_MAX_NUM_KEY <= key_index) |
| 5566 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5567 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5568 | key_index); |
| 5569 | |
| 5570 | return -EINVAL; |
| 5571 | } |
| 5572 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5573 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5574 | status = wlan_hdd_validate_context(pHddCtx); |
| 5575 | |
| 5576 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5577 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5578 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5579 | "%s: HDD context is not valid", __func__); |
| 5580 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5581 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5582 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5583 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5584 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5585 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5586 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5587 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 5588 | pHddStaCtx->conn_info.ucEncryptionType) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5589 | (eCSR_ENCRYPT_TYPE_AES != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 5590 | pHddStaCtx->conn_info.ucEncryptionType) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5591 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5592 | { |
| 5593 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5594 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5595 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5596 | tCsrRoamSetKey setKey; |
| 5597 | v_U32_t roamId= 0xFF; |
| 5598 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5599 | |
| 5600 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5601 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5602 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5603 | Keys->defaultIndex = (u8)key_index; |
| 5604 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 5605 | setKey.keyId = key_index; |
| 5606 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5607 | |
| 5608 | vos_mem_copy(&setKey.Key[0], |
| 5609 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5610 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5611 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5612 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5613 | |
| 5614 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5615 | &pHddStaCtx->conn_info.bssId[0], |
| 5616 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5617 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5618 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 5619 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 5620 | eCSR_ENCRYPT_TYPE_WEP104) |
| 5621 | { |
| 5622 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 5623 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 5624 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 5625 | type(104) and switching encryption type to 40*/ |
| 5626 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 5627 | eCSR_ENCRYPT_TYPE_WEP40; |
| 5628 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 5629 | eCSR_ENCRYPT_TYPE_WEP40; |
| 5630 | } |
| 5631 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5632 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5633 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5634 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5635 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5636 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5637 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5638 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5639 | if ( 0 != status ) |
| 5640 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5641 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5642 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5643 | status); |
| 5644 | return -EINVAL; |
| 5645 | } |
| 5646 | } |
| 5647 | } |
| 5648 | |
| 5649 | /* In SoftAp mode setting key direction for default mode */ |
| 5650 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5651 | { |
| 5652 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 5653 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 5654 | (eCSR_ENCRYPT_TYPE_AES != |
| 5655 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 5656 | ) |
| 5657 | { |
| 5658 | /* Saving key direction for default key index to TX default */ |
| 5659 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 5660 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 5661 | } |
| 5662 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5663 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5664 | return status; |
| 5665 | } |
| 5666 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5667 | /* |
| 5668 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 5669 | * This function is used to inform the BSS details to nl80211 interface. |
| 5670 | */ |
| 5671 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 5672 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 5673 | { |
| 5674 | struct net_device *dev = pAdapter->dev; |
| 5675 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 5676 | struct wiphy *wiphy = wdev->wiphy; |
| 5677 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 5678 | int chan_no; |
| 5679 | int ie_length; |
| 5680 | const char *ie; |
| 5681 | unsigned int freq; |
| 5682 | struct ieee80211_channel *chan; |
| 5683 | int rssi = 0; |
| 5684 | struct cfg80211_bss *bss = NULL; |
| 5685 | |
| 5686 | ENTER(); |
| 5687 | |
| 5688 | if( NULL == pBssDesc ) |
| 5689 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5690 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5691 | return bss; |
| 5692 | } |
| 5693 | |
| 5694 | chan_no = pBssDesc->channelId; |
| 5695 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 5696 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 5697 | |
| 5698 | if( NULL == ie ) |
| 5699 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5700 | 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] | 5701 | return bss; |
| 5702 | } |
| 5703 | |
| 5704 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 5705 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 5706 | { |
| 5707 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 5708 | } |
| 5709 | else |
| 5710 | { |
| 5711 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 5712 | } |
| 5713 | #else |
| 5714 | freq = ieee80211_channel_to_frequency(chan_no); |
| 5715 | #endif |
| 5716 | |
| 5717 | chan = __ieee80211_get_channel(wiphy, freq); |
| 5718 | |
Santhosh Kumar Padma | a45fdb1 | 2014-04-15 15:54:38 +0530 | [diff] [blame] | 5719 | if (!chan) { |
| 5720 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__); |
| 5721 | return NULL; |
| 5722 | } |
| 5723 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5724 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 5725 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 5726 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 5727 | if (bss == NULL) |
| 5728 | { |
| 5729 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 5730 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5731 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 5732 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5733 | pBssDesc->capabilityInfo, |
| 5734 | pBssDesc->beaconInterval, ie, ie_length, |
| 5735 | rssi, GFP_KERNEL )); |
| 5736 | } |
| 5737 | else |
| 5738 | { |
| 5739 | return bss; |
| 5740 | } |
| 5741 | } |
| 5742 | |
| 5743 | |
| 5744 | |
| 5745 | /* |
| 5746 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 5747 | * This function is used to inform the BSS details to nl80211 interface. |
| 5748 | */ |
| 5749 | struct cfg80211_bss* |
| 5750 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 5751 | tSirBssDescription *bss_desc |
| 5752 | ) |
| 5753 | { |
| 5754 | /* |
| 5755 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 5756 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 5757 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 5758 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 5759 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 5760 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 5761 | cfg80211_inform_bss_frame. |
| 5762 | */ |
| 5763 | struct net_device *dev = pAdapter->dev; |
| 5764 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 5765 | struct wiphy *wiphy = wdev->wiphy; |
| 5766 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 5767 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 5768 | qcom_ie_age *qie_age = NULL; |
| 5769 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 5770 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5771 | 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] | 5772 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5773 | const char *ie = |
| 5774 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 5775 | unsigned int freq; |
| 5776 | struct ieee80211_channel *chan; |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 5777 | struct ieee80211_mgmt *mgmt = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5778 | struct cfg80211_bss *bss_status = NULL; |
| 5779 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 5780 | int rssi = 0; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5781 | hdd_context_t *pHddCtx; |
| 5782 | int status; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5783 | #ifdef WLAN_OPEN_SOURCE |
| 5784 | struct timespec ts; |
| 5785 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5786 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5787 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5788 | status = wlan_hdd_validate_context(pHddCtx); |
| 5789 | |
| 5790 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 5791 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5792 | { |
| 5793 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5794 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 5795 | return NULL; |
| 5796 | } |
| 5797 | |
| 5798 | |
| 5799 | if (0 != status) |
| 5800 | { |
| 5801 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5802 | "%s: HDD context is not valid", __func__); |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 5803 | return NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5804 | } |
| 5805 | |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 5806 | mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5807 | if (!mgmt) |
| 5808 | { |
| 5809 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5810 | "%s: memory allocation failed ", __func__); |
| 5811 | return NULL; |
| 5812 | } |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 5813 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5814 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5815 | |
| 5816 | #ifdef WLAN_OPEN_SOURCE |
| 5817 | /* Android does not want the timestamp from the frame. |
| 5818 | Instead it wants a monotonic increasing value */ |
| 5819 | get_monotonic_boottime(&ts); |
| 5820 | mgmt->u.probe_resp.timestamp = |
| 5821 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 5822 | #else |
| 5823 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5824 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 5825 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5826 | |
| 5827 | #endif |
| 5828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5829 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 5830 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 5831 | |
| 5832 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 5833 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 5834 | /* Assuming this is the last IE, copy at the end */ |
| 5835 | ie_length -=sizeof(qcom_ie_age); |
| 5836 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 5837 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 5838 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 5839 | qie_age->oui_1 = QCOM_OUI1; |
| 5840 | qie_age->oui_2 = QCOM_OUI2; |
| 5841 | qie_age->oui_3 = QCOM_OUI3; |
| 5842 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 5843 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 5844 | #endif |
| 5845 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5846 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 5847 | if (bss_desc->fProbeRsp) |
| 5848 | { |
| 5849 | mgmt->frame_control |= |
| 5850 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 5851 | } |
| 5852 | else |
| 5853 | { |
| 5854 | mgmt->frame_control |= |
| 5855 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 5856 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | |
| 5858 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5859 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5860 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 5861 | { |
| 5862 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 5863 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5864 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5865 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 5866 | |
| 5867 | { |
| 5868 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 5869 | } |
| 5870 | else |
| 5871 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5872 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d", |
| 5873 | __func__, chan_no); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5874 | kfree(mgmt); |
| 5875 | return NULL; |
| 5876 | } |
| 5877 | #else |
| 5878 | freq = ieee80211_channel_to_frequency(chan_no); |
| 5879 | #endif |
| 5880 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 5881 | /*when the band is changed on the fly using the GUI, three things are done |
| 5882 | * 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) |
| 5883 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 5884 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 5885 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 5886 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 5887 | * 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 |
| 5888 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 5889 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 5890 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 5891 | * So drop the bss and continue to next bss. |
| 5892 | */ |
| 5893 | if(chan == NULL) |
| 5894 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5895 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 5896 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 5897 | return NULL; |
| 5898 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5899 | /*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] | 5900 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5901 | * */ |
| 5902 | if (( eConnectionState_Associated == |
| 5903 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 5904 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 5905 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 5906 | WNI_CFG_BSSID_LEN))) |
| 5907 | { |
| 5908 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 5909 | rssi = (pAdapter->rssi * 100); |
| 5910 | } |
| 5911 | else |
| 5912 | { |
| 5913 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 5914 | } |
| 5915 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5916 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d" |
| 5917 | "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid), |
| 5918 | chan->center_freq, (int)(rssi/100)); |
| 5919 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5920 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 5921 | frame_len, rssi, GFP_KERNEL); |
| 5922 | kfree(mgmt); |
| 5923 | return bss_status; |
| 5924 | } |
| 5925 | |
| 5926 | /* |
| 5927 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 5928 | * This function is used to update the BSS data base of CFG8011 |
| 5929 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5930 | 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] | 5931 | tCsrRoamInfo *pRoamInfo |
| 5932 | ) |
| 5933 | { |
| 5934 | tCsrRoamConnectedProfile roamProfile; |
| 5935 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5936 | struct cfg80211_bss *bss = NULL; |
| 5937 | |
| 5938 | ENTER(); |
| 5939 | |
| 5940 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 5941 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 5942 | |
| 5943 | if (NULL != roamProfile.pBssDesc) |
| 5944 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5945 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5946 | &roamProfile); |
| 5947 | |
| 5948 | if (NULL == bss) |
| 5949 | { |
| 5950 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 5951 | __func__); |
| 5952 | } |
| 5953 | |
| 5954 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 5955 | } |
| 5956 | else |
| 5957 | { |
| 5958 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 5959 | __func__); |
| 5960 | } |
| 5961 | return bss; |
| 5962 | } |
| 5963 | |
| 5964 | /* |
| 5965 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 5966 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5967 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 5968 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5969 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5970 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5971 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5972 | tCsrScanResultInfo *pScanResult; |
| 5973 | eHalStatus status = 0; |
| 5974 | tScanResultHandle pResult; |
| 5975 | struct cfg80211_bss *bss_status = NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5976 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5977 | |
| 5978 | ENTER(); |
| 5979 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5980 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 5981 | TRACE_CODE_HDD_CFG80211_UPDATE_BSS, |
| 5982 | NO_SESSION, pAdapter->sessionId)); |
| 5983 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5984 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5985 | |
| 5986 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5987 | { |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5988 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5989 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 5990 | return -EAGAIN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5991 | } |
| 5992 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5993 | |
| 5994 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 5995 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 5996 | { |
| 5997 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5998 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 5999 | return VOS_STATUS_E_PERM; |
| 6000 | } |
| 6001 | |
| 6002 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6003 | /* |
| 6004 | * start getting scan results and populate cgf80211 BSS database |
| 6005 | */ |
| 6006 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 6007 | |
| 6008 | /* no scan results */ |
| 6009 | if (NULL == pResult) |
| 6010 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6011 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d", |
| 6012 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6013 | return status; |
| 6014 | } |
| 6015 | |
| 6016 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 6017 | |
| 6018 | while (pScanResult) |
| 6019 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6020 | /* |
| 6021 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 6022 | * entry already exists in bss data base of cfg80211 for that |
| 6023 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 6024 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 6025 | * mgmt packet as input. As of now there is no possibility to get |
| 6026 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6027 | * ieee80211_mgmt(probe response) and passing to c |
| 6028 | * fg80211_inform_bss_frame. |
| 6029 | * */ |
| 6030 | |
| 6031 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 6032 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6033 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6034 | |
| 6035 | if (NULL == bss_status) |
| 6036 | { |
| 6037 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6038 | "%s: NULL returned by cfg80211_inform_bss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6039 | } |
| 6040 | else |
| 6041 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6042 | cfg80211_put_bss( |
| 6043 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 6044 | wiphy, |
| 6045 | #endif |
| 6046 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6047 | } |
| 6048 | |
| 6049 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 6050 | } |
| 6051 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6052 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6053 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6054 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6055 | } |
| 6056 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6057 | void |
| 6058 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 6059 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6060 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 6061 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6062 | } /****** end hddPrintMacAddr() ******/ |
| 6063 | |
| 6064 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6065 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6066 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6067 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6068 | "%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] | 6069 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 6070 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 6071 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6072 | } /****** end hddPrintPmkId() ******/ |
| 6073 | |
| 6074 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 6075 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 6076 | |
| 6077 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 6078 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 6079 | |
| 6080 | #define dump_bssid(bssid) \ |
| 6081 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6082 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 6083 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6084 | } |
| 6085 | |
| 6086 | #define dump_pmkid(pMac, pmkid) \ |
| 6087 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6088 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 6089 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6090 | } |
| 6091 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 6092 | #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] | 6093 | /* |
| 6094 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 6095 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 6096 | */ |
| 6097 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6098 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6099 | int index, bool preauth ) |
| 6100 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6101 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6102 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 6103 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6104 | |
| 6105 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6106 | 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] | 6107 | |
| 6108 | if( NULL == pRoamInfo ) |
| 6109 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6110 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6111 | return -EINVAL; |
| 6112 | } |
| 6113 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 6114 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 6115 | { |
| 6116 | dump_bssid(pRoamInfo->bssid); |
| 6117 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6118 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 6119 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6120 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6121 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6122 | } |
| 6123 | #endif //FEATURE_WLAN_LFR |
| 6124 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 6125 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 6126 | /* |
| 6127 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth |
| 6128 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 6129 | * |
| 6130 | */ |
| 6131 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
| 6132 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
| 6133 | tCsrRoamInfo *pRoamInfo) |
| 6134 | { |
| 6135 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 6136 | union iwreq_data wrqu; |
| 6137 | |
| 6138 | ENTER(); |
| 6139 | |
| 6140 | if (NULL == pAdapter) |
| 6141 | { |
| 6142 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 6143 | return VOS_STATUS_E_FAILURE; |
| 6144 | } |
| 6145 | |
| 6146 | /* create the event */ |
| 6147 | memset(&wrqu, 0, sizeof(wrqu)); |
| 6148 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 6149 | |
| 6150 | wrqu.data.pointer = metrics_notification; |
| 6151 | wrqu.data.length = scnprintf(metrics_notification, |
| 6152 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT " |
| 6153 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 6154 | |
| 6155 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 6156 | |
| 6157 | EXIT(); |
| 6158 | |
| 6159 | return VOS_STATUS_SUCCESS; |
| 6160 | } |
| 6161 | |
| 6162 | /* |
| 6163 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status |
| 6164 | * 802.11r/LFR metrics reporting function to report preauth completion |
| 6165 | * or failure |
| 6166 | */ |
| 6167 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status( |
| 6168 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status) |
| 6169 | { |
| 6170 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 6171 | union iwreq_data wrqu; |
| 6172 | |
| 6173 | ENTER(); |
| 6174 | |
| 6175 | if (NULL == pAdapter) |
| 6176 | { |
| 6177 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 6178 | return VOS_STATUS_E_FAILURE; |
| 6179 | } |
| 6180 | |
| 6181 | /* create the event */ |
| 6182 | memset(&wrqu, 0, sizeof(wrqu)); |
| 6183 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 6184 | |
| 6185 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 6186 | "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR, |
| 6187 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 6188 | |
| 6189 | if (1 == preauth_status) |
| 6190 | strncat(metrics_notification, " TRUE", 5); |
| 6191 | else |
| 6192 | strncat(metrics_notification, " FALSE", 6); |
| 6193 | |
| 6194 | wrqu.data.pointer = metrics_notification; |
| 6195 | wrqu.data.length = strlen(metrics_notification); |
| 6196 | |
| 6197 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 6198 | |
| 6199 | EXIT(); |
| 6200 | |
| 6201 | return VOS_STATUS_SUCCESS; |
| 6202 | } |
| 6203 | |
| 6204 | /* |
| 6205 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover |
| 6206 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 6207 | * |
| 6208 | */ |
| 6209 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter, |
| 6210 | tCsrRoamInfo *pRoamInfo) |
| 6211 | { |
| 6212 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 6213 | union iwreq_data wrqu; |
| 6214 | |
| 6215 | ENTER(); |
| 6216 | |
| 6217 | if (NULL == pAdapter) |
| 6218 | { |
| 6219 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 6220 | return VOS_STATUS_E_FAILURE; |
| 6221 | } |
| 6222 | |
| 6223 | /* create the event */ |
| 6224 | memset(&wrqu, 0, sizeof(wrqu)); |
| 6225 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 6226 | |
| 6227 | wrqu.data.pointer = metrics_notification; |
| 6228 | wrqu.data.length = scnprintf(metrics_notification, |
| 6229 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER " |
| 6230 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 6231 | |
| 6232 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 6233 | |
| 6234 | EXIT(); |
| 6235 | |
| 6236 | return VOS_STATUS_SUCCESS; |
| 6237 | } |
| 6238 | #endif |
| 6239 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6240 | /* |
| 6241 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 6242 | * scanning callback function, called after finishing scan |
| 6243 | * |
| 6244 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6245 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6246 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 6247 | { |
| 6248 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6249 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6250 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6251 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6252 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6253 | struct cfg80211_scan_request *req = NULL; |
| 6254 | int ret = 0; |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 6255 | bool aborted = false; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6256 | long waitRet = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6257 | |
| 6258 | ENTER(); |
| 6259 | |
| 6260 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6261 | "%s called with halHandle = %p, pContext = %p," |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6262 | "scanID = %d, returned status = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6263 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 6264 | |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 6265 | pScanInfo->mScanPendingCounter = 0; |
| 6266 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6267 | //Block on scan req completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6268 | waitRet = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6269 | &pScanInfo->scan_req_completion_event, |
| 6270 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6271 | if (waitRet <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6272 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6273 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6274 | "%s wait on scan_req_completion_event failed %ld",__func__, waitRet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6275 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6276 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6277 | } |
| 6278 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 6279 | if (pScanInfo->mScanPending != VOS_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6280 | { |
| 6281 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6282 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6283 | } |
| 6284 | |
| 6285 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6286 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6287 | { |
| 6288 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6289 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6290 | "scanId = %d", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6291 | (int) scanId); |
| 6292 | } |
| 6293 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6294 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6295 | pAdapter); |
| 6296 | |
| 6297 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6298 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6299 | |
| 6300 | |
| 6301 | /* If any client wait scan result through WEXT |
| 6302 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6303 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6304 | { |
| 6305 | /* The other scan request waiting for current scan finish |
| 6306 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6307 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6308 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6309 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6310 | } |
| 6311 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6312 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6313 | { |
| 6314 | struct net_device *dev = pAdapter->dev; |
| 6315 | union iwreq_data wrqu; |
| 6316 | int we_event; |
| 6317 | char *msg; |
| 6318 | |
| 6319 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6320 | we_event = SIOCGIWSCAN; |
| 6321 | msg = NULL; |
| 6322 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 6323 | } |
| 6324 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6325 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6326 | |
| 6327 | /* Get the Scan Req */ |
| 6328 | req = pAdapter->request; |
| 6329 | |
| 6330 | if (!req) |
| 6331 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6332 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 6333 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6334 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6335 | } |
| 6336 | |
| 6337 | /* |
| 6338 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6339 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6340 | req->n_ssids = 0; |
| 6341 | req->n_channels = 0; |
| 6342 | req->ie = 0; |
| 6343 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6344 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6345 | /* Scan is no longer pending */ |
| 6346 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6347 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 6348 | /* |
| 6349 | * cfg80211_scan_done informing NL80211 about completion |
| 6350 | * of scanning |
| 6351 | */ |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 6352 | if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE) |
| 6353 | { |
| 6354 | aborted = true; |
| 6355 | } |
| 6356 | cfg80211_scan_done(req, aborted); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 6357 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6358 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6359 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 6360 | /* release the wake lock at the end of the scan*/ |
| 6361 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6362 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 6363 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 6364 | * immediatly after the driver gets connect request(i.e after scan) |
| 6365 | * from supplicant, this result in app's is suspending and not able |
| 6366 | * to process the connect request to AP */ |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 6367 | hdd_prevent_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 6368 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 6369 | #ifdef FEATURE_WLAN_TDLS |
c_hpothu | 3c8f8e8 | 2014-06-02 18:01:50 +0530 | [diff] [blame] | 6370 | if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)) |
| 6371 | { |
| 6372 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 6373 | } |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 6374 | #endif |
| 6375 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6376 | EXIT(); |
| 6377 | return 0; |
| 6378 | } |
| 6379 | |
| 6380 | /* |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6381 | * FUNCTION: hdd_isConnectionInProgress |
| 6382 | * Go through each adapter and check if Connection is in progress |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6383 | * |
| 6384 | */ |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6385 | v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx ) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6386 | { |
| 6387 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6388 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6389 | hdd_adapter_t *pAdapter = NULL; |
| 6390 | VOS_STATUS status = 0; |
| 6391 | v_U8_t staId = 0; |
| 6392 | v_U8_t *staMac = NULL; |
| 6393 | |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 6394 | if (TRUE == pHddCtx->btCoexModeSet) |
| 6395 | { |
| 6396 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6397 | FL("BTCoex Mode operation in progress")); |
| 6398 | return VOS_TRUE; |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 6399 | } |
| 6400 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6401 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6402 | |
| 6403 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6404 | { |
| 6405 | pAdapter = pAdapterNode->pAdapter; |
| 6406 | |
| 6407 | if( pAdapter ) |
| 6408 | { |
| 6409 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6410 | "%s: Adapter with device mode %s (%d) exists", |
| 6411 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6412 | pAdapter->device_mode); |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6413 | if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6414 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 6415 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) && |
| 6416 | (eConnectionState_Connecting == |
| 6417 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6418 | { |
| 6419 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6420 | "%s: %p(%d) Connection is in progress", __func__, |
| 6421 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
| 6422 | return VOS_TRUE; |
| 6423 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6424 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6425 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 6426 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6427 | { |
| 6428 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6429 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6430 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6431 | { |
| 6432 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 6433 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 6434 | "%s: client " MAC_ADDRESS_STR |
| 6435 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 6436 | MAC_ADDR_ARRAY(staMac)); |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6437 | return VOS_TRUE; |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6438 | } |
| 6439 | } |
| 6440 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 6441 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 6442 | { |
| 6443 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 6444 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6445 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6446 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 6447 | { |
| 6448 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 6449 | |
| 6450 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 6451 | "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the " |
| 6452 | "middle of WPS/EAPOL exchange.", __func__, |
| 6453 | MAC_ADDR_ARRAY(staMac)); |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6454 | return VOS_TRUE; |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6455 | } |
| 6456 | } |
| 6457 | } |
| 6458 | } |
| 6459 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6460 | pAdapterNode = pNext; |
| 6461 | } |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6462 | return VOS_FALSE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6463 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6464 | |
| 6465 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 6466 | * FUNCTION: __wlan_hdd_cfg80211_scan |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6467 | * this scan respond to scan trigger and update cfg80211 scan database |
| 6468 | * later, scan dump command can be used to recieve scan results |
| 6469 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 6470 | int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 6471 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 6472 | struct net_device *dev, |
| 6473 | #endif |
| 6474 | struct cfg80211_scan_request *request) |
| 6475 | { |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 6476 | hdd_adapter_t *pAdapter = NULL; |
| 6477 | hdd_context_t *pHddCtx = NULL; |
| 6478 | hdd_wext_state_t *pwextBuf = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6479 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6480 | tCsrScanRequest scanRequest; |
| 6481 | tANI_U8 *channelList = NULL, i; |
| 6482 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6483 | int status; |
| 6484 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6485 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6486 | |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 6487 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 6488 | struct net_device *dev = NULL; |
| 6489 | if (NULL == request) |
| 6490 | { |
| 6491 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6492 | "%s: scan req param null", __func__); |
| 6493 | return -EINVAL; |
| 6494 | } |
| 6495 | dev = request->wdev->netdev; |
| 6496 | #endif |
| 6497 | |
| 6498 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6499 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6500 | pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6501 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6502 | ENTER(); |
| 6503 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6504 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6505 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", |
| 6506 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6507 | pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 6508 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6509 | status = wlan_hdd_validate_context(pHddCtx); |
| 6510 | |
| 6511 | if (0 != status) |
| 6512 | { |
| 6513 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6514 | "%s: HDD context is not valid", __func__); |
| 6515 | return status; |
| 6516 | } |
| 6517 | |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 6518 | if (NULL == pwextBuf) |
| 6519 | { |
| 6520 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n", |
| 6521 | __func__); |
| 6522 | return -EIO; |
| 6523 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6524 | cfg_param = pHddCtx->cfg_ini; |
| 6525 | pScanInfo = &pHddCtx->scan_info; |
| 6526 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6527 | #ifdef WLAN_BTAMP_FEATURE |
| 6528 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6529 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6530 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 6531 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6532 | "%s: No scanning when AMP is on", __func__); |
| 6533 | return -EOPNOTSUPP; |
| 6534 | } |
| 6535 | #endif |
| 6536 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6537 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6538 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6539 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6540 | "%s: Not scanning on device_mode = %s (%d)", |
| 6541 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 6542 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6543 | return -EOPNOTSUPP; |
| 6544 | } |
| 6545 | |
| 6546 | if (TRUE == pScanInfo->mScanPending) |
| 6547 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 6548 | if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ ) |
| 6549 | { |
| 6550 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__); |
| 6551 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6552 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6553 | } |
| 6554 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6555 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6556 | //Channel and action frame is pending |
| 6557 | //Otherwise Cancel Remain On Channel and allow Scan |
| 6558 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6559 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6560 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 6561 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6562 | return -EBUSY; |
| 6563 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6564 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 6565 | /* if tdls disagree scan right now, return immediately. |
| 6566 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 6567 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 6568 | */ |
| 6569 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 6570 | wiphy, |
| 6571 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 6572 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 6573 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 6574 | request); |
| 6575 | if(status <= 0) |
| 6576 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6577 | if(!status) |
| 6578 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress." |
| 6579 | "scan rejected %d", __func__, status); |
| 6580 | else |
| 6581 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d", |
| 6582 | __func__, status); |
| 6583 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 6584 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6585 | } |
| 6586 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6587 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6588 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 6589 | { |
| 6590 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 6591 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6592 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6593 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6594 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 6595 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6596 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6597 | "%s: MAX TM Level Scan not allowed", __func__); |
| 6598 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6599 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6600 | } |
| 6601 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 6602 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6603 | /* Check if scan is allowed at this point of time. |
| 6604 | */ |
Rashmi Ramanna | b142903 | 2014-04-26 14:59:09 +0530 | [diff] [blame] | 6605 | if (hdd_isConnectionInProgress(pHddCtx)) |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 6606 | { |
| 6607 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 6608 | return -EBUSY; |
| 6609 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6611 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 6612 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6613 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
| 6614 | (int)request->n_ssids); |
| 6615 | |
| 6616 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 6617 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 6618 | * is not aging out the scan results. |
| 6619 | */ |
| 6620 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6621 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6622 | request->n_ssids = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6623 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6624 | |
| 6625 | if ((request->ssids) && (0 < request->n_ssids)) |
| 6626 | { |
| 6627 | tCsrSSIDInfo *SsidInfo; |
| 6628 | int j; |
| 6629 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 6630 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 6631 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 6632 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 6633 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 6634 | |
| 6635 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 6636 | { |
| 6637 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6638 | "%s: memory alloc failed SSIDInfo buffer", __func__); |
| 6639 | return -ENOMEM; |
| 6640 | } |
| 6641 | |
| 6642 | /* copy all the ssid's and their length */ |
| 6643 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 6644 | { |
| 6645 | /* get the ssid length */ |
| 6646 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 6647 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 6648 | SsidInfo->SSID.length); |
| 6649 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 6650 | hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s", |
| 6651 | j, SsidInfo->SSID.ssId); |
| 6652 | } |
| 6653 | /* set the scan type to active */ |
| 6654 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 6655 | } |
| 6656 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6657 | { |
Siddharth Bhal | 0c162d0 | 2014-05-06 19:50:42 +0530 | [diff] [blame] | 6658 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6659 | TRACE_CODE_HDD_CFG80211_SCAN, |
| 6660 | pAdapter->sessionId, 0)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6661 | /* set the scan type to active */ |
| 6662 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6663 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6664 | else |
| 6665 | { |
| 6666 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 6667 | scanRequest.scanType = pScanInfo->scan_mode; |
| 6668 | } |
| 6669 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
| 6670 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6671 | |
| 6672 | /* set BSSType to default type */ |
| 6673 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 6674 | |
| 6675 | /*TODO: scan the requested channels only*/ |
| 6676 | |
| 6677 | /*Right now scanning all the channels */ |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6678 | if (MAX_CHANNEL < request->n_channels) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6679 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6680 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 6681 | "No of Scan Channels exceeded limit: %d", request->n_channels); |
| 6682 | request->n_channels = MAX_CHANNEL; |
| 6683 | } |
| 6684 | |
| 6685 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6686 | "No of Scan Channels: %d", request->n_channels); |
| 6687 | |
| 6688 | |
| 6689 | if( request->n_channels ) |
| 6690 | { |
| 6691 | char chList [(request->n_channels*5)+1]; |
| 6692 | int len; |
| 6693 | channelList = vos_mem_malloc( request->n_channels ); |
| 6694 | if( NULL == channelList ) |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 6695 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6696 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6697 | "%s: memory alloc failed channelList", __func__); |
| 6698 | status = -ENOMEM; |
| 6699 | goto free_mem; |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 6700 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6701 | |
| 6702 | for( i = 0, len = 0; i < request->n_channels ; i++ ) |
| 6703 | { |
| 6704 | channelList[i] = request->channels[i]->hw_value; |
| 6705 | len += snprintf(chList+len, 5, "%d ", channelList[i]); |
| 6706 | } |
| 6707 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6708 | hddLog(VOS_TRACE_LEVEL_INFO, |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6709 | "Channel-List: %s ", chList); |
| 6710 | } |
c_hpothu | 5351230 | 2014-04-15 18:49:53 +0530 | [diff] [blame] | 6711 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6712 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 6713 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 6714 | |
| 6715 | /* set requestType to full scan */ |
| 6716 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 6717 | |
| 6718 | /* Flush the scan results(only p2p beacons) for STA scan and P2P |
| 6719 | * search (Flush on both full scan and social scan but not on single |
| 6720 | * channel scan).P2P search happens on 3 social channels (1, 6, 11) |
| 6721 | */ |
| 6722 | |
| 6723 | /* Supplicant does single channel scan after 8-way handshake |
| 6724 | * and in that case driver shoudnt flush scan results. If |
| 6725 | * driver flushes the scan results here and unfortunately if |
| 6726 | * the AP doesnt respond to our probe req then association |
| 6727 | * fails which is not desired |
| 6728 | */ |
| 6729 | |
| 6730 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 6731 | { |
| 6732 | hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results"); |
| 6733 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6734 | pAdapter->sessionId ); |
| 6735 | } |
| 6736 | |
| 6737 | if( request->ie_len ) |
| 6738 | { |
| 6739 | /* save this for future association (join requires this) */ |
| 6740 | /*TODO: Array needs to be converted to dynamic allocation, |
| 6741 | * as multiple ie.s can be sent in cfg80211_scan_request structure |
| 6742 | * CR 597966 |
| 6743 | */ |
| 6744 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 6745 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 6746 | pScanInfo->scanAddIE.length = request->ie_len; |
| 6747 | |
| 6748 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6749 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 6750 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6751 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6752 | if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6753 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6754 | pwextBuf->roamProfile.nAddIEScanLength = request->ie_len; |
| 6755 | memcpy( pwextBuf->roamProfile.addIEScan, |
| 6756 | request->ie, request->ie_len); |
| 6757 | } |
| 6758 | else |
| 6759 | { |
| 6760 | hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:" |
| 6761 | "%zu", request->ie_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6762 | } |
| 6763 | |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6764 | } |
| 6765 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 6766 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 6767 | |
| 6768 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 6769 | request->ie_len); |
| 6770 | if (pP2pIe != NULL) |
| 6771 | { |
| 6772 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 6773 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 6774 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 6775 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6776 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6777 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 6778 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 6779 | "Go nego completed to Connection is started"); |
| 6780 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 6781 | "for 8way Handshake"); |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6782 | } |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6783 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 6784 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6785 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6786 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 6787 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 6788 | "Disconnected state to Connection is started"); |
| 6789 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 6790 | "for 4way Handshake"); |
| 6791 | } |
| 6792 | #endif |
| 6793 | |
| 6794 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 6795 | if(TRUE == request->no_cck) |
| 6796 | { |
| 6797 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6798 | "%s: This is a P2P Search", __func__); |
| 6799 | scanRequest.p2pSearch = 1; |
| 6800 | |
| 6801 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 6802 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6803 | /* set requestType to P2P Discovery */ |
| 6804 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
| 6805 | } |
| 6806 | |
| 6807 | /* |
| 6808 | Skip Dfs Channel in case of P2P Search |
| 6809 | if it is set in ini file |
| 6810 | */ |
| 6811 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 6812 | { |
| 6813 | scanRequest.skipDfsChnlInP2pSearch = 1; |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 6814 | } |
| 6815 | else |
| 6816 | { |
Padma, Santhosh Kumar | 787bd5c | 2014-05-15 20:09:31 +0530 | [diff] [blame] | 6817 | scanRequest.skipDfsChnlInP2pSearch = 0; |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 6818 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6819 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 6820 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6821 | } |
| 6822 | } |
| 6823 | |
| 6824 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 6825 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 6826 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 6827 | * address the following issues. |
| 6828 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 6829 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 6830 | * for long time, this result in apps running at full power for long time. |
| 6831 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 6832 | * be stuck in full power because of resume BMPS |
| 6833 | */ |
| 6834 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6835 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6836 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 6837 | "requestType %d, scanType %d, minChnTime %d, maxChnTime %d," |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 6838 | "p2pSearch %d, skipDfsChnlInP2pSearch %d", |
| 6839 | scanRequest.requestType, scanRequest.scanType, |
| 6840 | scanRequest.minChnTime, scanRequest.maxChnTime, |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6841 | scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch); |
| 6842 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6843 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6844 | pAdapter->sessionId, &scanRequest, &scanId, |
| 6845 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6846 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6847 | if (eHAL_STATUS_SUCCESS != status) |
| 6848 | { |
| 6849 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6850 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 6851 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 6852 | if(eHAL_STATUS_RESOURCES == status) |
| 6853 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 6854 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress." |
| 6855 | "So defer the scan by informing busy",__func__); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 6856 | status = -EBUSY; |
| 6857 | } else { |
| 6858 | status = -EIO; |
| 6859 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 6860 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6861 | goto free_mem; |
| 6862 | } |
| 6863 | |
| 6864 | pScanInfo->mScanPending = TRUE; |
| 6865 | pAdapter->request = request; |
| 6866 | pScanInfo->scanId = scanId; |
| 6867 | |
| 6868 | complete(&pScanInfo->scan_req_completion_event); |
| 6869 | |
| 6870 | free_mem: |
| 6871 | if( scanRequest.SSIDs.SSIDList ) |
| 6872 | { |
| 6873 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 6874 | } |
| 6875 | |
| 6876 | if( channelList ) |
| 6877 | vos_mem_free( channelList ); |
| 6878 | |
| 6879 | EXIT(); |
| 6880 | |
| 6881 | return status; |
| 6882 | } |
| 6883 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 6884 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 6885 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 6886 | struct net_device *dev, |
| 6887 | #endif |
| 6888 | struct cfg80211_scan_request *request) |
| 6889 | { |
| 6890 | int ret; |
| 6891 | |
| 6892 | vos_ssr_protect(__func__); |
| 6893 | ret = __wlan_hdd_cfg80211_scan(wiphy, |
| 6894 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 6895 | dev, |
| 6896 | #endif |
| 6897 | request); |
| 6898 | vos_ssr_unprotect(__func__); |
| 6899 | |
| 6900 | return ret; |
| 6901 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6902 | |
| 6903 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 6904 | { |
| 6905 | v_U8_t iniDot11Mode = |
| 6906 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 6907 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 6908 | |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 6909 | hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"), |
| 6910 | iniDot11Mode); |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6911 | switch ( iniDot11Mode ) |
| 6912 | { |
| 6913 | case eHDD_DOT11_MODE_AUTO: |
| 6914 | case eHDD_DOT11_MODE_11ac: |
| 6915 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 6916 | #ifdef WLAN_FEATURE_11AC |
| 6917 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 6918 | #else |
| 6919 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 6920 | #endif |
| 6921 | break; |
| 6922 | case eHDD_DOT11_MODE_11n: |
| 6923 | case eHDD_DOT11_MODE_11n_ONLY: |
| 6924 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 6925 | break; |
| 6926 | default: |
| 6927 | hddDot11Mode = iniDot11Mode; |
| 6928 | break; |
| 6929 | } |
| 6930 | /* This call decides required channel bonding mode */ |
| 6931 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 6932 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 6933 | operationChannel); |
| 6934 | } |
| 6935 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6936 | /* |
| 6937 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6938 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6939 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6940 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6941 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6942 | { |
| 6943 | int status = 0; |
| 6944 | hdd_wext_state_t *pWextState; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 6945 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6946 | v_U32_t roamId; |
| 6947 | tCsrRoamProfile *pRoamProfile; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6948 | eCsrAuthType RSNAuthType; |
| 6949 | |
| 6950 | ENTER(); |
| 6951 | |
| 6952 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 6953 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6954 | |
| 6955 | status = wlan_hdd_validate_context(pHddCtx); |
| 6956 | if (status) |
| 6957 | { |
| 6958 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6959 | "%s: HDD context is not valid!", __func__); |
| 6960 | return status; |
| 6961 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6962 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6963 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 6964 | { |
| 6965 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 6966 | return -EINVAL; |
| 6967 | } |
| 6968 | |
| 6969 | pRoamProfile = &pWextState->roamProfile; |
| 6970 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6971 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6972 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6973 | hdd_station_ctx_t *pHddStaCtx; |
| 6974 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6975 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6976 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6977 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 6978 | { |
| 6979 | /*QoS not enabled in cfg file*/ |
| 6980 | pRoamProfile->uapsd_mask = 0; |
| 6981 | } |
| 6982 | else |
| 6983 | { |
| 6984 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6985 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6986 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 6987 | } |
| 6988 | |
| 6989 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 6990 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 6991 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6992 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6993 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 6994 | ssid, ssid_len); |
| 6995 | |
| 6996 | if (bssid) |
| 6997 | { |
| 6998 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 6999 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 7000 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7001 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 7002 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7003 | case of join failure we should send valid BSSID to supplicant |
| 7004 | */ |
| 7005 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 7006 | WNI_CFG_BSSID_LEN); |
| 7007 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 7008 | else |
| 7009 | { |
| 7010 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 7011 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7012 | |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 7013 | hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"), |
| 7014 | pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7015 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 7016 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7017 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7018 | /*set gen ie*/ |
| 7019 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 7020 | /*set auth*/ |
| 7021 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 7022 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7023 | #ifdef FEATURE_WLAN_WAPI |
| 7024 | if (pAdapter->wapi_info.nWapiMode) |
| 7025 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7026 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7027 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 7028 | { |
| 7029 | case WAPI_AUTH_MODE_PSK: |
| 7030 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7031 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7032 | pAdapter->wapi_info.wapiAuthMode); |
| 7033 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 7034 | break; |
| 7035 | } |
| 7036 | case WAPI_AUTH_MODE_CERT: |
| 7037 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7038 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7039 | pAdapter->wapi_info.wapiAuthMode); |
| 7040 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 7041 | break; |
| 7042 | } |
| 7043 | } // End of switch |
| 7044 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 7045 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 7046 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7047 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7048 | pRoamProfile->AuthType.numEntries = 1; |
| 7049 | pRoamProfile->EncryptionType.numEntries = 1; |
| 7050 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 7051 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 7052 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 7053 | } |
| 7054 | } |
| 7055 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7056 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7057 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7058 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7059 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 7060 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7061 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 7062 | sizeof (tSirGtkOffloadParams)); |
| 7063 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7064 | } |
| 7065 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7066 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 7067 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7068 | if( operatingChannel ) |
| 7069 | { |
| 7070 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 7071 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 7072 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 7073 | else |
| 7074 | { |
| 7075 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 7076 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 7077 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 7078 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 7079 | { |
| 7080 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 7081 | } |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 7082 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 7083 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 7084 | * 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] | 7085 | * 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] | 7086 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 7087 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 7088 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7089 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 7090 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7091 | { |
| 7092 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7093 | "%s: Set HDD connState to eConnectionState_Connecting", |
| 7094 | __func__); |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 7095 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 7096 | eConnectionState_Connecting); |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7097 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7098 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7099 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 7100 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7101 | if ((eHAL_STATUS_SUCCESS != status) && |
| 7102 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 7103 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 7104 | |
| 7105 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 7106 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 7107 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 7108 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 7109 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 7110 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 7111 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 7112 | |
| 7113 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 7114 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 7115 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7116 | } |
| 7117 | else |
| 7118 | { |
| 7119 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 7120 | return -EINVAL; |
| 7121 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 7122 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7123 | return status; |
| 7124 | } |
| 7125 | |
| 7126 | /* |
| 7127 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 7128 | * This function is used to set the authentication type (OPEN/SHARED). |
| 7129 | * |
| 7130 | */ |
| 7131 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 7132 | enum nl80211_auth_type auth_type) |
| 7133 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7134 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7135 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7136 | |
| 7137 | ENTER(); |
| 7138 | |
| 7139 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7140 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7141 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7142 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7143 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7144 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 7145 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 7146 | break; |
| 7147 | |
| 7148 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7149 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 7150 | case NL80211_AUTHTYPE_FT: |
| 7151 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7152 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7153 | "%s: set authentication type to OPEN", __func__); |
| 7154 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 7155 | break; |
| 7156 | |
| 7157 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7158 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7159 | "%s: set authentication type to SHARED", __func__); |
| 7160 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 7161 | break; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7162 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7163 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7164 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7165 | "%s: set authentication type to CCKM WPA", __func__); |
| 7166 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 7167 | break; |
| 7168 | #endif |
| 7169 | |
| 7170 | |
| 7171 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7172 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7173 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7174 | auth_type); |
| 7175 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 7176 | return -EINVAL; |
| 7177 | } |
| 7178 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7179 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7180 | pHddStaCtx->conn_info.authType; |
| 7181 | return 0; |
| 7182 | } |
| 7183 | |
| 7184 | /* |
| 7185 | * FUNCTION: wlan_hdd_set_akm_suite |
| 7186 | * This function is used to set the key mgmt type(PSK/8021x). |
| 7187 | * |
| 7188 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7189 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7190 | u32 key_mgmt |
| 7191 | ) |
| 7192 | { |
| 7193 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7194 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7195 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7196 | /*set key mgmt type*/ |
| 7197 | switch(key_mgmt) |
| 7198 | { |
| 7199 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7200 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 7201 | case WLAN_AKM_SUITE_FT_PSK: |
| 7202 | #endif |
| 7203 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7204 | __func__); |
| 7205 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 7206 | break; |
| 7207 | |
| 7208 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7209 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 7210 | case WLAN_AKM_SUITE_FT_8021X: |
| 7211 | #endif |
| 7212 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7213 | __func__); |
| 7214 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 7215 | break; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7216 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7217 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 7218 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 7219 | case WLAN_AKM_SUITE_CCKM: |
| 7220 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 7221 | __func__); |
| 7222 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 7223 | break; |
| 7224 | #endif |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 7225 | #ifndef WLAN_AKM_SUITE_OSEN |
| 7226 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 7227 | case WLAN_AKM_SUITE_OSEN: |
| 7228 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN", |
| 7229 | __func__); |
| 7230 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 7231 | break; |
| 7232 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7233 | |
| 7234 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7235 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7236 | __func__, key_mgmt); |
| 7237 | return -EINVAL; |
| 7238 | |
| 7239 | } |
| 7240 | return 0; |
| 7241 | } |
| 7242 | |
| 7243 | /* |
| 7244 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7245 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7246 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 7247 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7248 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 7249 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7250 | bool ucast |
| 7251 | ) |
| 7252 | { |
| 7253 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7254 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7255 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7256 | |
| 7257 | ENTER(); |
| 7258 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7259 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7260 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7261 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7262 | __func__, cipher); |
| 7263 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 7264 | } |
| 7265 | else |
| 7266 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7268 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7269 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7270 | { |
| 7271 | case IW_AUTH_CIPHER_NONE: |
| 7272 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 7273 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7274 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7275 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7276 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7277 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7278 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7279 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 7280 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7281 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7282 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7283 | case WLAN_CIPHER_SUITE_TKIP: |
| 7284 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 7285 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7286 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7287 | case WLAN_CIPHER_SUITE_CCMP: |
| 7288 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 7289 | break; |
| 7290 | #ifdef FEATURE_WLAN_WAPI |
| 7291 | case WLAN_CIPHER_SUITE_SMS4: |
| 7292 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 7293 | break; |
| 7294 | #endif |
| 7295 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7296 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7297 | case WLAN_CIPHER_SUITE_KRK: |
| 7298 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 7299 | break; |
| 7300 | #endif |
| 7301 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7302 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7303 | __func__, cipher); |
| 7304 | return -EOPNOTSUPP; |
| 7305 | } |
| 7306 | } |
| 7307 | |
| 7308 | if (ucast) |
| 7309 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7310 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7311 | __func__, encryptionType); |
| 7312 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 7313 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7314 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7315 | encryptionType; |
| 7316 | } |
| 7317 | else |
| 7318 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7319 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7320 | __func__, encryptionType); |
| 7321 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 7322 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 7323 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 7324 | } |
| 7325 | |
| 7326 | return 0; |
| 7327 | } |
| 7328 | |
| 7329 | |
| 7330 | /* |
| 7331 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 7332 | * This function is used to parse WPA/RSN IE's. |
| 7333 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7334 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 7335 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7336 | size_t ie_len |
| 7337 | ) |
| 7338 | { |
| 7339 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7340 | u8 *genie = ie; |
| 7341 | v_U16_t remLen = ie_len; |
| 7342 | #ifdef FEATURE_WLAN_WAPI |
| 7343 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 7344 | u16 *tmp; |
| 7345 | v_U16_t akmsuiteCount; |
| 7346 | int *akmlist; |
| 7347 | #endif |
| 7348 | ENTER(); |
| 7349 | |
| 7350 | /* clear previous assocAddIE */ |
| 7351 | pWextState->assocAddIE.length = 0; |
| 7352 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 7353 | pWextState->roamProfile.bOSENAssociation = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7354 | |
| 7355 | while (remLen >= 2) |
| 7356 | { |
| 7357 | v_U16_t eLen = 0; |
| 7358 | v_U8_t elementId; |
| 7359 | elementId = *genie++; |
| 7360 | eLen = *genie++; |
| 7361 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7362 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7363 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7364 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7365 | |
| 7366 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7367 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7368 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7369 | 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] | 7370 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7371 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7372 | "%s: Invalid WPA IE", __func__); |
| 7373 | return -EINVAL; |
| 7374 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7375 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7376 | { |
| 7377 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7378 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7379 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7380 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7381 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 7382 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 7383 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 7384 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7385 | VOS_ASSERT(0); |
| 7386 | return -ENOMEM; |
| 7387 | } |
| 7388 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 7389 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 7390 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7391 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7392 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 7393 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 7394 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 7395 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7396 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 7397 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7398 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 7399 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 7400 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 7401 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 7402 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 7403 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7404 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
Kiet Lam | 8da9899 | 2013-11-21 15:59:07 +0530 | [diff] [blame] | 7405 | P2P_OUI_TYPE_SIZE))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7406 | { |
| 7407 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7408 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7409 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7410 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7411 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 7412 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 7413 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 7414 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7415 | VOS_ASSERT(0); |
| 7416 | return -ENOMEM; |
| 7417 | } |
| 7418 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 7419 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 7420 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7422 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 7423 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 7424 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7425 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7426 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 7427 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7428 | /*Consider WFD IE, only for P2P Client */ |
| 7429 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7430 | { |
| 7431 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7432 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7433 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7434 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7435 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 7436 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 7437 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 7438 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7439 | VOS_ASSERT(0); |
| 7440 | return -ENOMEM; |
| 7441 | } |
| 7442 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 7443 | // WPS IE + P2P IE + WFD IE |
| 7444 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 7445 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7446 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7447 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 7448 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 7449 | } |
| 7450 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7451 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7452 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 7453 | HS20_OUI_TYPE_SIZE)) ) |
| 7454 | { |
| 7455 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7456 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 7457 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7458 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 7459 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 7460 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 7461 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 7462 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 7463 | VOS_ASSERT(0); |
| 7464 | return -ENOMEM; |
| 7465 | } |
| 7466 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 7467 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7468 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 7469 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 7470 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 7471 | } |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 7472 | /* Appending OSEN Information Element in Assiciation Request */ |
| 7473 | else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 7474 | OSEN_OUI_TYPE_SIZE)) ) |
| 7475 | { |
| 7476 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
| 7477 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)", |
| 7478 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7479 | |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 7480 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 7481 | { |
| 7482 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 7483 | "Need bigger buffer space"); |
| 7484 | VOS_ASSERT(0); |
| 7485 | return -ENOMEM; |
| 7486 | } |
| 7487 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 7488 | pWextState->assocAddIE.length += eLen + 2; |
| 7489 | |
| 7490 | pWextState->roamProfile.bOSENAssociation = VOS_TRUE; |
| 7491 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 7492 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 7493 | } |
| 7494 | |
| 7495 | break; |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 7496 | if (WLAN_HDD_IBSS == pAdapter->device_mode) { |
| 7497 | |
| 7498 | /* populating as ADDIE in beacon frames */ |
| 7499 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7500 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2, |
| 7501 | NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS) |
| 7502 | { |
| 7503 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7504 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 7505 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 7506 | { |
| 7507 | hddLog(LOGE, |
| 7508 | "Coldn't pass " |
| 7509 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
| 7510 | } |
| 7511 | }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/ |
| 7512 | else |
| 7513 | hddLog(LOGE, |
| 7514 | "Could not pass on " |
| 7515 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
| 7516 | |
| 7517 | /* IBSS mode doesn't contain params->proberesp_ies still |
| 7518 | beaconIE's need to be populated in probe response frames */ |
| 7519 | if ( (NULL != (genie - 2)) && (0 != eLen + 2) ) |
| 7520 | { |
| 7521 | u16 rem_probe_resp_ie_len = eLen + 2; |
| 7522 | u8 probe_rsp_ie_len[3] = {0}; |
| 7523 | u8 counter = 0; |
| 7524 | |
| 7525 | /* Check Probe Resp Length if it is greater then 255 then |
| 7526 | Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 |
| 7527 | & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are |
| 7528 | not able Store More then 255 bytes into One Variable */ |
| 7529 | |
| 7530 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 7531 | { |
| 7532 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 7533 | { |
| 7534 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 7535 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 7536 | } |
| 7537 | else |
| 7538 | { |
| 7539 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 7540 | rem_probe_resp_ie_len = 0; |
| 7541 | } |
| 7542 | } |
| 7543 | |
| 7544 | rem_probe_resp_ie_len = 0; |
| 7545 | |
| 7546 | if (probe_rsp_ie_len[0] > 0) |
| 7547 | { |
| 7548 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7549 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 7550 | (tANI_U8*)(genie - 2), |
| 7551 | probe_rsp_ie_len[0], NULL, |
| 7552 | eANI_BOOLEAN_FALSE) |
| 7553 | == eHAL_STATUS_FAILURE) |
| 7554 | { |
| 7555 | hddLog(LOGE, |
| 7556 | "Could not pass" |
| 7557 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
| 7558 | } |
| 7559 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 7560 | } |
| 7561 | |
| 7562 | if (probe_rsp_ie_len[1] > 0) |
| 7563 | { |
| 7564 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7565 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 7566 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 7567 | probe_rsp_ie_len[1], NULL, |
| 7568 | eANI_BOOLEAN_FALSE) |
| 7569 | == eHAL_STATUS_FAILURE) |
| 7570 | { |
| 7571 | hddLog(LOGE, |
| 7572 | "Could not pass" |
| 7573 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
| 7574 | } |
| 7575 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 7576 | } |
| 7577 | |
| 7578 | if (probe_rsp_ie_len[2] > 0) |
| 7579 | { |
| 7580 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7581 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 7582 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 7583 | probe_rsp_ie_len[2], NULL, |
| 7584 | eANI_BOOLEAN_FALSE) |
| 7585 | == eHAL_STATUS_FAILURE) |
| 7586 | { |
| 7587 | hddLog(LOGE, |
| 7588 | "Could not pass" |
| 7589 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
| 7590 | } |
| 7591 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 7592 | } |
| 7593 | |
| 7594 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7595 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 7596 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 7597 | { |
| 7598 | hddLog(LOGE, |
| 7599 | "Could not pass" |
| 7600 | "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
| 7601 | } |
| 7602 | } |
| 7603 | else |
| 7604 | { |
| 7605 | // Reset WNI_CFG_PROBE_RSP Flags |
| 7606 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 7607 | |
| 7608 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7609 | "%s: No Probe Response IE received in set beacon", |
| 7610 | __func__); |
| 7611 | } |
| 7612 | } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7613 | break; |
| 7614 | case DOT11F_EID_RSN: |
| 7615 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 7616 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 7617 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 7618 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 7619 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 7620 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7621 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 7622 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7623 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7624 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7625 | 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] | 7626 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7627 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7628 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 7629 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 7630 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 7631 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7632 | VOS_ASSERT(0); |
| 7633 | return -ENOMEM; |
| 7634 | } |
| 7635 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 7636 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7637 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7638 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 7639 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 7640 | break; |
| 7641 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7642 | #ifdef FEATURE_WLAN_WAPI |
| 7643 | case WLAN_EID_WAPI: |
| 7644 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7645 | hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7646 | pAdapter->wapi_info.nWapiMode); |
| 7647 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7648 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7649 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 7650 | tmp = tmp + 1; |
| 7651 | akmlist = (int *)(tmp); |
| 7652 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 7653 | { |
| 7654 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 7655 | } |
| 7656 | else |
| 7657 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7658 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7659 | VOS_ASSERT(0); |
| 7660 | return -EINVAL; |
| 7661 | } |
| 7662 | |
| 7663 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 7664 | { |
| 7665 | 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] | 7666 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7667 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7668 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7669 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7670 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7671 | 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] | 7672 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7673 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 7674 | } |
| 7675 | break; |
| 7676 | #endif |
| 7677 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7678 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7679 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 7680 | /* when Unknown IE is received we should break and continue |
| 7681 | * to the next IE in the buffer instead we were returning |
| 7682 | * so changing this to break */ |
| 7683 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7684 | } |
| 7685 | genie += eLen; |
| 7686 | remLen -= eLen; |
| 7687 | } |
| 7688 | EXIT(); |
| 7689 | return 0; |
| 7690 | } |
| 7691 | |
| 7692 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 7693 | * FUNCTION: hdd_isWPAIEPresent |
| 7694 | * Parse the received IE to find the WPA IE |
| 7695 | * |
| 7696 | */ |
| 7697 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 7698 | { |
| 7699 | v_U8_t eLen = 0; |
| 7700 | v_U16_t remLen = ie_len; |
| 7701 | v_U8_t elementId = 0; |
| 7702 | |
| 7703 | while (remLen >= 2) |
| 7704 | { |
| 7705 | elementId = *ie++; |
| 7706 | eLen = *ie++; |
| 7707 | remLen -= 2; |
| 7708 | if (eLen > remLen) |
| 7709 | { |
| 7710 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7711 | "%s: IE length is wrong %d", __func__, eLen); |
| 7712 | return FALSE; |
| 7713 | } |
| 7714 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 7715 | { |
| 7716 | /* OUI - 0x00 0X50 0XF2 |
| 7717 | WPA Information Element - 0x01 |
| 7718 | WPA version - 0x01*/ |
| 7719 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 7720 | return TRUE; |
| 7721 | } |
| 7722 | ie += eLen; |
| 7723 | remLen -= eLen; |
| 7724 | } |
| 7725 | return FALSE; |
| 7726 | } |
| 7727 | |
| 7728 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7729 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7730 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7731 | * parameters during connect operation. |
| 7732 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7733 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7734 | struct cfg80211_connect_params *req |
| 7735 | ) |
| 7736 | { |
| 7737 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7738 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7739 | ENTER(); |
| 7740 | |
| 7741 | /*set wpa version*/ |
| 7742 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 7743 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7744 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7745 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 7746 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7747 | { |
| 7748 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 7749 | } |
| 7750 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 7751 | { |
| 7752 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 7753 | } |
| 7754 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7755 | |
| 7756 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7757 | pWextState->wpaVersion); |
| 7758 | |
| 7759 | /*set authentication type*/ |
| 7760 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 7761 | |
| 7762 | if (0 > status) |
| 7763 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7764 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7765 | "%s: failed to set authentication type ", __func__); |
| 7766 | return status; |
| 7767 | } |
| 7768 | |
| 7769 | /*set key mgmt type*/ |
| 7770 | if (req->crypto.n_akm_suites) |
| 7771 | { |
| 7772 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 7773 | if (0 > status) |
| 7774 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7775 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7776 | __func__); |
| 7777 | return status; |
| 7778 | } |
| 7779 | } |
| 7780 | |
| 7781 | /*set pairwise cipher type*/ |
| 7782 | if (req->crypto.n_ciphers_pairwise) |
| 7783 | { |
| 7784 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 7785 | req->crypto.ciphers_pairwise[0], true); |
| 7786 | if (0 > status) |
| 7787 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7788 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7789 | "%s: failed to set unicast cipher type", __func__); |
| 7790 | return status; |
| 7791 | } |
| 7792 | } |
| 7793 | else |
| 7794 | { |
| 7795 | /*Reset previous cipher suite to none*/ |
| 7796 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 7797 | if (0 > status) |
| 7798 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7799 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7800 | "%s: failed to set unicast cipher type", __func__); |
| 7801 | return status; |
| 7802 | } |
| 7803 | } |
| 7804 | |
| 7805 | /*set group cipher type*/ |
| 7806 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 7807 | false); |
| 7808 | |
| 7809 | if (0 > status) |
| 7810 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7811 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7812 | __func__); |
| 7813 | return status; |
| 7814 | } |
| 7815 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 7816 | #ifdef WLAN_FEATURE_11W |
| 7817 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 7818 | #endif |
| 7819 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7820 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 7821 | if (req->ie_len) |
| 7822 | { |
| 7823 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 7824 | if ( 0 > status) |
| 7825 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7826 | 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] | 7827 | __func__); |
| 7828 | return status; |
| 7829 | } |
| 7830 | } |
| 7831 | |
| 7832 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7833 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7834 | { |
| 7835 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 7836 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 7837 | ) |
| 7838 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7839 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7840 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 7841 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7842 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7843 | __func__); |
| 7844 | return -EOPNOTSUPP; |
| 7845 | } |
| 7846 | else |
| 7847 | { |
| 7848 | u8 key_len = req->key_len; |
| 7849 | u8 key_idx = req->key_idx; |
| 7850 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7851 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7852 | && (CSR_MAX_NUM_KEY > key_idx) |
| 7853 | ) |
| 7854 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7855 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7856 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7857 | __func__, key_idx, key_len); |
| 7858 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7859 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7860 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7861 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7862 | (u8)key_len; |
| 7863 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 7864 | } |
| 7865 | } |
| 7866 | } |
| 7867 | } |
| 7868 | |
| 7869 | return status; |
| 7870 | } |
| 7871 | |
| 7872 | /* |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 7873 | * FUNCTION: wlan_hdd_try_disconnect |
| 7874 | * This function is used to disconnect from previous |
| 7875 | * connection |
| 7876 | */ |
| 7877 | static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter ) |
| 7878 | { |
| 7879 | long ret = 0; |
| 7880 | hdd_station_ctx_t *pHddStaCtx; |
| 7881 | eMib_dot11DesiredBssType connectedBssType; |
| 7882 | |
| 7883 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7884 | |
| 7885 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 7886 | |
| 7887 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 7888 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 7889 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
| 7890 | { |
| 7891 | /* Issue disconnect to CSR */ |
| 7892 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 7893 | if( eHAL_STATUS_SUCCESS == |
| 7894 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7895 | pAdapter->sessionId, |
| 7896 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 7897 | { |
| 7898 | ret = wait_for_completion_interruptible_timeout( |
| 7899 | &pAdapter->disconnect_comp_var, |
| 7900 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7901 | if (0 >= ret) |
| 7902 | { |
| 7903 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 7904 | return -EALREADY; |
| 7905 | } |
| 7906 | } |
| 7907 | } |
| 7908 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 7909 | { |
| 7910 | ret = wait_for_completion_interruptible_timeout( |
| 7911 | &pAdapter->disconnect_comp_var, |
| 7912 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7913 | if (0 >= ret) |
| 7914 | { |
| 7915 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 7916 | return -EALREADY; |
| 7917 | } |
| 7918 | } |
| 7919 | |
| 7920 | return 0; |
| 7921 | } |
| 7922 | |
| 7923 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 7924 | * FUNCTION: __wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7925 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7926 | * parameters during connect operation. |
| 7927 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 7928 | static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7929 | struct net_device *ndev, |
| 7930 | struct cfg80211_connect_params *req |
| 7931 | ) |
| 7932 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7933 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7934 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7935 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 7936 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7937 | |
| 7938 | ENTER(); |
| 7939 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7940 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 7941 | TRACE_CODE_HDD_CFG80211_CONNECT, |
| 7942 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7943 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 7944 | "%s: device_mode = %s (%d)", __func__, |
| 7945 | hdd_device_modetoString(pAdapter->device_mode), |
| 7946 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7947 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7948 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 7949 | if (!pHddCtx) |
| 7950 | { |
| 7951 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7952 | "%s: HDD context is null", __func__); |
| 7953 | return VOS_STATUS_E_FAILURE; |
| 7954 | } |
| 7955 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7956 | status = wlan_hdd_validate_context(pHddCtx); |
| 7957 | |
| 7958 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7959 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7960 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7961 | "%s: HDD context is not valid", __func__); |
| 7962 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7963 | } |
| 7964 | |
| 7965 | #ifdef WLAN_BTAMP_FEATURE |
| 7966 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7967 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7968 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7969 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7970 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 7971 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7972 | } |
| 7973 | #endif |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 7974 | |
| 7975 | //If Device Mode is Station Concurrent Sessions Exit BMps |
| 7976 | //P2P Mode will be taken care in Open/close adapter |
| 7977 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 7978 | (vos_concurrent_sessions_running())) |
| 7979 | { |
| 7980 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7981 | } |
| 7982 | |
| 7983 | /*Try disconnecting if already in connected state*/ |
| 7984 | status = wlan_hdd_try_disconnect(pAdapter); |
| 7985 | if ( 0 > status) |
| 7986 | { |
| 7987 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 7988 | " connection")); |
| 7989 | return -EALREADY; |
| 7990 | } |
| 7991 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7992 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7993 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7994 | |
| 7995 | if ( 0 > status) |
| 7996 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7997 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7998 | __func__); |
| 7999 | return status; |
| 8000 | } |
| 8001 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 8002 | if ( req->channel ) |
| 8003 | { |
| 8004 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 8005 | req->ssid_len, req->bssid, |
| 8006 | req->channel->hw_value); |
| 8007 | } |
| 8008 | else |
| 8009 | { |
| 8010 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8011 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 8012 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8013 | |
| 8014 | if (0 > status) |
| 8015 | { |
| 8016 | //ReEnable BMPS if disabled |
| 8017 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 8018 | (NULL != pHddCtx)) |
| 8019 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8020 | if (pHddCtx->hdd_wlan_suspended) |
| 8021 | { |
| 8022 | hdd_set_pwrparams(pHddCtx); |
| 8023 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8024 | //ReEnable Bmps and Imps back |
| 8025 | hdd_enable_bmps_imps(pHddCtx); |
| 8026 | } |
| 8027 | |
| 8028 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 8029 | return status; |
| 8030 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8031 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8032 | EXIT(); |
| 8033 | return status; |
| 8034 | } |
| 8035 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 8036 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
| 8037 | struct net_device *ndev, |
| 8038 | struct cfg80211_connect_params *req) |
| 8039 | { |
| 8040 | int ret; |
| 8041 | vos_ssr_protect(__func__); |
| 8042 | ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
| 8043 | vos_ssr_unprotect(__func__); |
| 8044 | |
| 8045 | return ret; |
| 8046 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8047 | |
| 8048 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8049 | * FUNCTION: wlan_hdd_disconnect |
| 8050 | * This function is used to issue a disconnect request to SME |
| 8051 | */ |
| 8052 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 8053 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8054 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8055 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8056 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8057 | |
| 8058 | status = wlan_hdd_validate_context(pHddCtx); |
| 8059 | |
| 8060 | if (0 != status) |
| 8061 | { |
| 8062 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8063 | "%s: HDD context is not valid", __func__); |
| 8064 | return status; |
| 8065 | } |
| 8066 | |
| 8067 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 8068 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8069 | "%s: Set HDD connState to eConnectionState_Disconnecting", |
| 8070 | __func__); |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 8071 | pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8072 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8073 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8074 | /*issue disconnect*/ |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 8075 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8076 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8077 | pAdapter->sessionId, reason); |
| 8078 | |
| 8079 | if ( 0 != status ) |
| 8080 | { |
| 8081 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8082 | "%s csrRoamDisconnect failure, returned %d", |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8083 | __func__, (int)status ); |
| 8084 | return -EINVAL; |
| 8085 | } |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 8086 | status = wait_for_completion_interruptible_timeout( |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8087 | &pAdapter->disconnect_comp_var, |
| 8088 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 8089 | if (!status) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8090 | { |
| 8091 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 8092 | "%s: Failed to disconnect, timed out", __func__); |
| 8093 | return -ETIMEDOUT; |
| 8094 | } |
| 8095 | else if (status == -ERESTARTSYS) |
| 8096 | { |
| 8097 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8098 | "%s: Failed to disconnect, wait interrupted", __func__); |
| 8099 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8100 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8101 | /*stop tx queues*/ |
| 8102 | netif_tx_disable(pAdapter->dev); |
| 8103 | netif_carrier_off(pAdapter->dev); |
Mahesh A Saptasagar | 05a357e | 2014-02-26 16:28:06 +0530 | [diff] [blame] | 8104 | return 0; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8105 | } |
| 8106 | |
| 8107 | |
| 8108 | /* |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 8109 | * FUNCTION: __wlan_hdd_cfg80211_disconnect |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8110 | * This function is used to issue a disconnect request to SME |
| 8111 | */ |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 8112 | static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8113 | struct net_device *dev, |
| 8114 | u16 reason |
| 8115 | ) |
| 8116 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8117 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 8118 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8119 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8120 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8121 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8122 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 8123 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 8124 | tANI_U8 staIdx; |
| 8125 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8126 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8127 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8128 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8129 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8130 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
| 8131 | pAdapter->sessionId, reason)); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8132 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)", |
| 8133 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 8134 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8135 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8136 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 8137 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8138 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8139 | status = wlan_hdd_validate_context(pHddCtx); |
| 8140 | |
| 8141 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8142 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8143 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8144 | "%s: HDD context is not valid", __func__); |
| 8145 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8146 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8147 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8148 | if (NULL != pRoamProfile) |
| 8149 | { |
| 8150 | /*issue disconnect request to SME, if station is in connected state*/ |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 8151 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 8152 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8153 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8154 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8155 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 8156 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8157 | switch(reason) |
| 8158 | { |
| 8159 | case WLAN_REASON_MIC_FAILURE: |
| 8160 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 8161 | break; |
| 8162 | |
| 8163 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 8164 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 8165 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 8166 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 8167 | break; |
| 8168 | |
| 8169 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 8170 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
Abhishek Singh | c3269a5 | 2014-05-21 17:22:24 +0530 | [diff] [blame] | 8171 | case WLAN_REASON_DEAUTH_LEAVING: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8172 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 8173 | break; |
| 8174 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8175 | default: |
| 8176 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 8177 | break; |
| 8178 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 8179 | pScanInfo = &pHddCtx->scan_info; |
| 8180 | if (pScanInfo->mScanPending) |
| 8181 | { |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 8182 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 8183 | "Aborting Scan"); |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 8184 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 8185 | eCSR_SCAN_ABORT_DEFAULT); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 8186 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8187 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 8188 | #ifdef FEATURE_WLAN_TDLS |
| 8189 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8190 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 8191 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8192 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 8193 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 8194 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8195 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8196 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8197 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8198 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8199 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8200 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 8201 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8202 | pAdapter->sessionId, |
| 8203 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 8204 | } |
| 8205 | } |
| 8206 | #endif |
Arun Kumar Khandavalli | 94a2bb0 | 2013-12-28 19:17:25 +0530 | [diff] [blame] | 8207 | hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8208 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 8209 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8210 | { |
| 8211 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8212 | "%s wlan_hdd_disconnect failure, returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8213 | __func__, (int)status ); |
| 8214 | return -EINVAL; |
| 8215 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8216 | } |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 8217 | else |
| 8218 | { |
| 8219 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API" |
| 8220 | "called while in %d state", __func__, |
| 8221 | pHddStaCtx->conn_info.connState); |
| 8222 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8223 | } |
| 8224 | else |
| 8225 | { |
| 8226 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 8227 | } |
| 8228 | |
| 8229 | return status; |
| 8230 | } |
| 8231 | |
Mahesh A Saptasagar | fafb7fe | 2014-05-16 13:19:37 +0530 | [diff] [blame] | 8232 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
| 8233 | struct net_device *dev, |
| 8234 | u16 reason |
| 8235 | ) |
| 8236 | { |
| 8237 | int ret; |
| 8238 | vos_ssr_protect(__func__); |
| 8239 | ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
| 8240 | vos_ssr_unprotect(__func__); |
| 8241 | |
| 8242 | return ret; |
| 8243 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 8244 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8245 | /* |
| 8246 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8247 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8248 | * settings in IBSS mode. |
| 8249 | */ |
| 8250 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8251 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8252 | struct cfg80211_ibss_params *params |
| 8253 | ) |
| 8254 | { |
| 8255 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8256 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8257 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 8258 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8259 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8260 | ENTER(); |
| 8261 | |
| 8262 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Ravi Joshi | b58ca0d | 2013-10-29 09:50:23 -0700 | [diff] [blame] | 8263 | vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8264 | |
| 8265 | if (params->ie_len && ( NULL != params->ie) ) |
| 8266 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 8267 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 8268 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8269 | { |
| 8270 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 8271 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 8272 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 8273 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8274 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 8275 | tDot11fIEWPA dot11WPAIE; |
| 8276 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 8277 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 8278 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 8279 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 8280 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 8281 | params->ie_len, DOT11F_EID_WPA); |
| 8282 | if ( NULL != ie ) |
| 8283 | { |
| 8284 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 8285 | // Unpack the WPA IE |
| 8286 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 8287 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 8288 | &ie[2+4], |
| 8289 | ie[1] - 4, |
| 8290 | &dot11WPAIE); |
| 8291 | /*Extract the multicast cipher, the encType for unicast |
| 8292 | cipher for wpa-none is none*/ |
| 8293 | encryptionType = |
| 8294 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 8295 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8296 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 8297 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8298 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 8299 | |
| 8300 | if (0 > status) |
| 8301 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8302 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8303 | __func__); |
| 8304 | return status; |
| 8305 | } |
| 8306 | } |
| 8307 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8308 | pWextState->roamProfile.AuthType.authType[0] = |
| 8309 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8310 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 8311 | |
| 8312 | if (params->privacy) |
| 8313 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8314 | /* Security enabled IBSS, At this time there is no information available |
| 8315 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8316 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8317 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8318 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8319 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8320 | *enable privacy bit in beacons */ |
| 8321 | |
| 8322 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 8323 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 8324 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 8325 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8326 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 8327 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 8328 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8329 | return status; |
| 8330 | } |
| 8331 | |
| 8332 | /* |
| 8333 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8334 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8335 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8336 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8337 | struct net_device *dev, |
| 8338 | struct cfg80211_ibss_params *params |
| 8339 | ) |
| 8340 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8341 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8342 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 8343 | tCsrRoamProfile *pRoamProfile; |
| 8344 | int status; |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 8345 | bool alloc_bssid = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8346 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8347 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8348 | |
| 8349 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8350 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8351 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8352 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
| 8353 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8354 | hddLog(VOS_TRACE_LEVEL_INFO, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8355 | "%s: device_mode = %s (%d)", __func__, |
| 8356 | hdd_device_modetoString(pAdapter->device_mode), |
| 8357 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8358 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8359 | status = wlan_hdd_validate_context(pHddCtx); |
| 8360 | |
| 8361 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8362 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8363 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8364 | "%s: HDD context is not valid", __func__); |
| 8365 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8366 | } |
| 8367 | |
| 8368 | if (NULL == pWextState) |
| 8369 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8370 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8371 | __func__); |
| 8372 | return -EIO; |
| 8373 | } |
| 8374 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 8375 | /*Try disconnecting if already in connected state*/ |
| 8376 | status = wlan_hdd_try_disconnect(pAdapter); |
| 8377 | if ( 0 > status) |
| 8378 | { |
| 8379 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 8380 | " IBSS connection")); |
| 8381 | return -EALREADY; |
| 8382 | } |
| 8383 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8384 | pRoamProfile = &pWextState->roamProfile; |
| 8385 | |
| 8386 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 8387 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8388 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8389 | "%s Interface type is not set to IBSS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8390 | return -EINVAL; |
| 8391 | } |
| 8392 | |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 8393 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 8394 | if (NULL != params->bssid) { |
| 8395 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 8396 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) { |
| 8397 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 8398 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 8399 | return -EIO; |
| 8400 | } |
| 8401 | } |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 8402 | else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0) |
| 8403 | { |
| 8404 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 8405 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 8406 | { |
| 8407 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 8408 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 8409 | return -EIO; |
| 8410 | } |
| 8411 | params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE)); |
| 8412 | if (!params->bssid) |
| 8413 | { |
| 8414 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 8415 | "%s:Failed memory allocation", __func__); |
| 8416 | return -EIO; |
| 8417 | } |
| 8418 | vos_mem_copy((v_U8_t *)params->bssid, |
| 8419 | (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0], |
| 8420 | VOS_MAC_ADDR_SIZE); |
| 8421 | alloc_bssid = VOS_TRUE; |
| 8422 | } |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 8423 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8424 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 8425 | if (NULL != |
| 8426 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 8427 | params->chandef.chan) |
| 8428 | #else |
| 8429 | params->channel) |
| 8430 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8431 | { |
| 8432 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8433 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 8434 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 8435 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8436 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8437 | |
| 8438 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8439 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 8440 | ieee80211_frequency_to_channel( |
| 8441 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 8442 | params->chandef.chan->center_freq); |
| 8443 | #else |
| 8444 | params->channel->center_freq); |
| 8445 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8446 | |
| 8447 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 8448 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8449 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8450 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 8451 | __func__); |
| 8452 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8453 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8454 | |
| 8455 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8456 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8457 | if (channelNum == validChan[indx]) |
| 8458 | { |
| 8459 | break; |
| 8460 | } |
| 8461 | } |
| 8462 | if (indx >= numChans) |
| 8463 | { |
| 8464 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8465 | __func__, channelNum); |
| 8466 | return -EINVAL; |
| 8467 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8468 | /* Set the Operational Channel */ |
| 8469 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 8470 | channelNum); |
| 8471 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 8472 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 8473 | pRoamProfile->ChannelInfo.ChannelList = |
| 8474 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8475 | } |
| 8476 | |
| 8477 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8478 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8479 | if (status < 0) |
| 8480 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8481 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8482 | __func__); |
| 8483 | return status; |
| 8484 | } |
| 8485 | |
| 8486 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8487 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 8488 | params->ssid_len, params->bssid, |
| 8489 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8490 | |
| 8491 | if (0 > status) |
| 8492 | { |
| 8493 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 8494 | return status; |
| 8495 | } |
| 8496 | |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 8497 | if (NULL != params->bssid && |
| 8498 | pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 && |
| 8499 | alloc_bssid == VOS_TRUE) |
| 8500 | { |
| 8501 | vos_mem_free(params->bssid); |
| 8502 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8503 | return 0; |
| 8504 | } |
| 8505 | |
| 8506 | /* |
| 8507 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8508 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8509 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8510 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8511 | struct net_device *dev |
| 8512 | ) |
| 8513 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8514 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8515 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 8516 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8517 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8518 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8519 | |
| 8520 | ENTER(); |
| 8521 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8522 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8523 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
| 8524 | pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8525 | status = wlan_hdd_validate_context(pHddCtx); |
| 8526 | |
| 8527 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8528 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8529 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8530 | "%s: HDD context is not valid", __func__); |
| 8531 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8532 | } |
| 8533 | |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 8534 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__, |
| 8535 | hdd_device_modetoString(pAdapter->device_mode), |
| 8536 | pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8537 | if (NULL == pWextState) |
| 8538 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8539 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8540 | __func__); |
| 8541 | return -EIO; |
| 8542 | } |
| 8543 | |
| 8544 | pRoamProfile = &pWextState->roamProfile; |
| 8545 | |
| 8546 | /* Issue disconnect only if interface type is set to IBSS */ |
| 8547 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 8548 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8549 | 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] | 8550 | __func__); |
| 8551 | return -EINVAL; |
| 8552 | } |
| 8553 | |
| 8554 | /* Issue Disconnect request */ |
| 8555 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 8556 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 8557 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 8558 | |
| 8559 | return 0; |
| 8560 | } |
| 8561 | |
| 8562 | /* |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 8563 | * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8564 | * This function is used to set the phy parameters |
| 8565 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 8566 | */ |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 8567 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8568 | u32 changed) |
| 8569 | { |
| 8570 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8571 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8572 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8573 | |
| 8574 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8575 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8576 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 8577 | NO_SESSION, wiphy->rts_threshold)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8578 | status = wlan_hdd_validate_context(pHddCtx); |
| 8579 | |
| 8580 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8581 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8582 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8583 | "%s: HDD context is not valid", __func__); |
| 8584 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8585 | } |
| 8586 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8587 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 8588 | { |
| 8589 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 8590 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 8591 | wiphy->rts_threshold; |
| 8592 | |
| 8593 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8594 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8595 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8596 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8597 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8598 | __func__, rts_threshold); |
| 8599 | return -EINVAL; |
| 8600 | } |
| 8601 | |
| 8602 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 8603 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8604 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8605 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8606 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8607 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8608 | __func__, rts_threshold); |
| 8609 | return -EIO; |
| 8610 | } |
| 8611 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8612 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8613 | rts_threshold); |
| 8614 | } |
| 8615 | |
| 8616 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 8617 | { |
| 8618 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 8619 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 8620 | wiphy->frag_threshold; |
| 8621 | |
| 8622 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8623 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8624 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8625 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8626 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8627 | frag_threshold); |
| 8628 | return -EINVAL; |
| 8629 | } |
| 8630 | |
| 8631 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 8632 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8633 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8634 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8635 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8636 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8637 | __func__, frag_threshold); |
| 8638 | return -EIO; |
| 8639 | } |
| 8640 | |
| 8641 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 8642 | frag_threshold); |
| 8643 | } |
| 8644 | |
| 8645 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 8646 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 8647 | { |
| 8648 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 8649 | wiphy->retry_short : |
| 8650 | wiphy->retry_long; |
| 8651 | |
| 8652 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 8653 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 8654 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8655 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8656 | __func__, retry_value); |
| 8657 | return -EINVAL; |
| 8658 | } |
| 8659 | |
| 8660 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 8661 | { |
| 8662 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 8663 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8664 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8665 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8666 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8667 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8668 | __func__, retry_value); |
| 8669 | return -EIO; |
| 8670 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8671 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8672 | __func__, retry_value); |
| 8673 | } |
| 8674 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 8675 | { |
| 8676 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 8677 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8678 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8679 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8680 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8681 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8682 | __func__, retry_value); |
| 8683 | return -EIO; |
| 8684 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8685 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8686 | __func__, retry_value); |
| 8687 | } |
| 8688 | } |
| 8689 | |
| 8690 | return 0; |
| 8691 | } |
| 8692 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 8693 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 8694 | u32 changed) |
| 8695 | { |
| 8696 | int ret; |
| 8697 | |
| 8698 | vos_ssr_protect(__func__); |
| 8699 | ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
| 8700 | vos_ssr_unprotect(__func__); |
| 8701 | |
| 8702 | return ret; |
| 8703 | } |
| 8704 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8705 | /* |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 8706 | * FUNCTION: __wlan_hdd_cfg80211_set_txpower |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8707 | * This function is used to set the txpower |
| 8708 | */ |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 8709 | static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 8710 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 8711 | struct wireless_dev *wdev, |
| 8712 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8713 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8714 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8715 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8716 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8717 | #endif |
| 8718 | int dbm) |
| 8719 | { |
| 8720 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8721 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8722 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 8723 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8724 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8725 | |
| 8726 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8727 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 8728 | TRACE_CODE_HDD_CFG80211_SET_TXPOWER, |
| 8729 | NO_SESSION, type )); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8730 | status = wlan_hdd_validate_context(pHddCtx); |
| 8731 | |
| 8732 | if (0 != status) |
| 8733 | { |
| 8734 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8735 | "%s: HDD context is not valid", __func__); |
| 8736 | return status; |
| 8737 | } |
| 8738 | |
| 8739 | hHal = pHddCtx->hHal; |
| 8740 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8741 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 8742 | dbm, ccmCfgSetCallback, |
| 8743 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8744 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8745 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8746 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 8747 | return -EIO; |
| 8748 | } |
| 8749 | |
| 8750 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 8751 | dbm); |
| 8752 | |
| 8753 | switch(type) |
| 8754 | { |
| 8755 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 8756 | /* Fall through */ |
| 8757 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 8758 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 8759 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8760 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 8761 | __func__); |
| 8762 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8763 | } |
| 8764 | break; |
| 8765 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8766 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8767 | __func__); |
| 8768 | return -EOPNOTSUPP; |
| 8769 | break; |
| 8770 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8771 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 8772 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8773 | return -EIO; |
| 8774 | } |
| 8775 | |
| 8776 | return 0; |
| 8777 | } |
| 8778 | |
Mahesh A Saptasagar | 179d225 | 2014-06-02 21:32:21 +0530 | [diff] [blame] | 8779 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 8780 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 8781 | struct wireless_dev *wdev, |
| 8782 | #endif |
| 8783 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
| 8784 | enum tx_power_setting type, |
| 8785 | #else |
| 8786 | enum nl80211_tx_power_setting type, |
| 8787 | #endif |
| 8788 | int dbm) |
| 8789 | { |
| 8790 | int ret; |
| 8791 | vos_ssr_protect(__func__); |
| 8792 | ret = __wlan_hdd_cfg80211_set_txpower(wiphy, |
| 8793 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 8794 | wdev, |
| 8795 | #endif |
| 8796 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
| 8797 | type, |
| 8798 | #else |
| 8799 | type, |
| 8800 | #endif |
| 8801 | dbm); |
| 8802 | vos_ssr_unprotect(__func__); |
| 8803 | |
| 8804 | return ret; |
| 8805 | } |
| 8806 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8807 | /* |
| 8808 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 8809 | * This function is used to read the txpower |
| 8810 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 8811 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 8812 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 8813 | struct wireless_dev *wdev, |
| 8814 | #endif |
| 8815 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8816 | { |
| 8817 | |
| 8818 | hdd_adapter_t *pAdapter; |
| 8819 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8820 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8821 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8822 | ENTER(); |
| 8823 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8824 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8825 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8826 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8827 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8828 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8829 | "%s: HDD context is not valid", __func__); |
| 8830 | *dbm = 0; |
| 8831 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8832 | } |
| 8833 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8834 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 8835 | if (NULL == pAdapter) |
| 8836 | { |
| 8837 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 8838 | return -ENOENT; |
| 8839 | } |
| 8840 | |
| 8841 | wlan_hdd_get_classAstats(pAdapter); |
| 8842 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 8843 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8844 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8845 | return 0; |
| 8846 | } |
| 8847 | |
| 8848 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 8849 | u8* mac, struct station_info *sinfo) |
| 8850 | { |
| 8851 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 8852 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8853 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 8854 | tANI_U32 rate_flags; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8855 | |
| 8856 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 8857 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8858 | |
| 8859 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 8860 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 8861 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 8862 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 8863 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 8864 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 8865 | tANI_U16 maxRate = 0; |
| 8866 | tANI_U16 myRate; |
| 8867 | tANI_U16 currentRate = 0; |
| 8868 | tANI_U8 maxSpeedMCS = 0; |
| 8869 | tANI_U8 maxMCSIdx = 0; |
| 8870 | tANI_U8 rateFlag = 1; |
| 8871 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 8872 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8873 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8874 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 8875 | #ifdef WLAN_FEATURE_11AC |
| 8876 | tANI_U32 vht_mcs_map; |
| 8877 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 8878 | #endif /* WLAN_FEATURE_11AC */ |
| 8879 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8880 | ENTER(); |
| 8881 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8882 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 8883 | (0 == ssidlen)) |
| 8884 | { |
| 8885 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 8886 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 8887 | /*To keep GUI happy*/ |
| 8888 | return 0; |
| 8889 | } |
| 8890 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8891 | status = wlan_hdd_validate_context(pHddCtx); |
| 8892 | |
| 8893 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8894 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8895 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8896 | "%s: HDD context is not valid", __func__); |
| 8897 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8898 | } |
| 8899 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8900 | |
Kiet Lam | 3b17fc8 | 2013-09-27 05:24:08 +0530 | [diff] [blame] | 8901 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 8902 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 8903 | |
c_hpothu | 09f1954 | 2014-05-30 21:53:31 +0530 | [diff] [blame] | 8904 | wlan_hdd_get_station_stats(pAdapter); |
| 8905 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 8906 | |
| 8907 | /*overwrite rate_flags if MAX link-speed need to be reported*/ |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 8908 | if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) || |
| 8909 | (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed && |
| 8910 | sinfo->signal >= pCfg->linkSpeedRssiHigh)) |
| 8911 | { |
| 8912 | rate_flags = pAdapter->maxRateFlags; |
| 8913 | } |
c_hpothu | 44ff4e0 | 2014-05-08 00:13:57 +0530 | [diff] [blame] | 8914 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8915 | //convert to the UI units of 100kbps |
| 8916 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 8917 | |
| 8918 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 8919 | 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] | 8920 | sinfo->signal, |
| 8921 | pCfg->reportMaxLinkSpeed, |
| 8922 | myRate, |
| 8923 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 8924 | (int) pCfg->linkSpeedRssiMid, |
| 8925 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 8926 | (int) rate_flags, |
| 8927 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8928 | #endif //LINKSPEED_DEBUG_ENABLED |
| 8929 | |
| 8930 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 8931 | { |
| 8932 | // we do not want to necessarily report the current speed |
| 8933 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 8934 | { |
| 8935 | // report the max possible speed |
| 8936 | rssidx = 0; |
| 8937 | } |
| 8938 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 8939 | { |
| 8940 | // report the max possible speed with RSSI scaling |
| 8941 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 8942 | { |
| 8943 | // report the max possible speed |
| 8944 | rssidx = 0; |
| 8945 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 8946 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8947 | { |
| 8948 | // report middle speed |
| 8949 | rssidx = 1; |
| 8950 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 8951 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 8952 | { |
| 8953 | // report middle speed |
| 8954 | rssidx = 2; |
| 8955 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8956 | else |
| 8957 | { |
| 8958 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 8959 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8960 | } |
| 8961 | } |
| 8962 | else |
| 8963 | { |
| 8964 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 8965 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8966 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 8967 | __func__, pCfg->reportMaxLinkSpeed); |
| 8968 | rssidx = 0; |
| 8969 | } |
| 8970 | |
| 8971 | maxRate = 0; |
| 8972 | |
| 8973 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 8974 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 8975 | OperationalRates, &ORLeng)) |
| 8976 | { |
| 8977 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 8978 | /*To keep GUI happy*/ |
| 8979 | return 0; |
| 8980 | } |
| 8981 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8982 | for (i = 0; i < ORLeng; i++) |
| 8983 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8984 | 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] | 8985 | { |
| 8986 | /* Validate Rate Set */ |
| 8987 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 8988 | { |
| 8989 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 8990 | break; |
| 8991 | } |
| 8992 | } |
| 8993 | /* Update MAX rate */ |
| 8994 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 8995 | } |
| 8996 | |
| 8997 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 8998 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 8999 | ExtendedRates, &ERLeng)) |
| 9000 | { |
| 9001 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 9002 | /*To keep GUI happy*/ |
| 9003 | return 0; |
| 9004 | } |
| 9005 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9006 | for (i = 0; i < ERLeng; i++) |
| 9007 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9008 | 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] | 9009 | { |
| 9010 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 9011 | { |
| 9012 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 9013 | break; |
| 9014 | } |
| 9015 | } |
| 9016 | /* Update MAX rate */ |
| 9017 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 9018 | } |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 9019 | /* Get MCS Rate Set -- |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 9020 | Only if we are always reporting max speed (or) |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 9021 | if we have good rssi */ |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 9022 | if ((0 == rssidx) || |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 9023 | (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9024 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 9025 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 9026 | MCSRates, &MCSLeng)) |
| 9027 | { |
| 9028 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 9029 | /*To keep GUI happy*/ |
| 9030 | return 0; |
| 9031 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9032 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9033 | #ifdef WLAN_FEATURE_11AC |
| 9034 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9035 | 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] | 9036 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9037 | 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] | 9038 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9039 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9040 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9041 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9042 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9043 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9044 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9045 | maxMCSIdx = 7; |
| 9046 | } |
| 9047 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 9048 | { |
| 9049 | maxMCSIdx = 8; |
| 9050 | } |
| 9051 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 9052 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9053 | //VHT20 is supporting 0~8 |
| 9054 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 9055 | maxMCSIdx = 8; |
| 9056 | else |
| 9057 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9058 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9059 | |
| 9060 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 9061 | { |
| 9062 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 9063 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 9064 | } |
| 9065 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 9066 | { |
| 9067 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 9068 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 9069 | } |
| 9070 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 9071 | { |
| 9072 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 9073 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 9074 | } |
| 9075 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9076 | maxSpeedMCS = 1; |
| 9077 | if (currentRate > maxRate) |
| 9078 | { |
| 9079 | maxRate = currentRate; |
| 9080 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9081 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9082 | } |
| 9083 | else |
| 9084 | #endif /* WLAN_FEATURE_11AC */ |
| 9085 | { |
| 9086 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 9087 | { |
| 9088 | rateFlag |= 1; |
| 9089 | } |
| 9090 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 9091 | { |
| 9092 | rateFlag |= 2; |
| 9093 | } |
| 9094 | |
| 9095 | for (i = 0; i < MCSLeng; i++) |
| 9096 | { |
| 9097 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 9098 | for (j = 0; j < temp; j++) |
| 9099 | { |
| 9100 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 9101 | { |
| 9102 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 9103 | break; |
| 9104 | } |
| 9105 | } |
| 9106 | if ((j < temp) && (currentRate > maxRate)) |
| 9107 | { |
| 9108 | maxRate = currentRate; |
| 9109 | maxSpeedMCS = 1; |
| 9110 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 9111 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9112 | } |
| 9113 | } |
| 9114 | } |
| 9115 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9116 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 9117 | { |
| 9118 | maxRate = myRate; |
| 9119 | maxSpeedMCS = 1; |
| 9120 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 9121 | } |
| 9122 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9123 | // make sure we report a value at least as big as our current rate |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 9124 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 9125 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9126 | { |
| 9127 | maxRate = myRate; |
| 9128 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 9129 | { |
| 9130 | maxSpeedMCS = 0; |
| 9131 | } |
| 9132 | else |
| 9133 | { |
| 9134 | maxSpeedMCS = 1; |
| 9135 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 9136 | } |
| 9137 | } |
| 9138 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9139 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9140 | { |
| 9141 | sinfo->txrate.legacy = maxRate; |
| 9142 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 9143 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 9144 | #endif //LINKSPEED_DEBUG_ENABLED |
| 9145 | } |
| 9146 | else |
| 9147 | { |
| 9148 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9149 | #ifdef WLAN_FEATURE_11AC |
| 9150 | sinfo->txrate.nss = 1; |
| 9151 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 9152 | { |
| 9153 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9154 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9155 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9156 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9157 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9158 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 9159 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 9160 | } |
| 9161 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 9162 | { |
| 9163 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 9164 | } |
| 9165 | #endif /* WLAN_FEATURE_11AC */ |
| 9166 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 9167 | { |
| 9168 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 9169 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 9170 | { |
| 9171 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 9172 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9173 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9174 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 9175 | { |
| 9176 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 9177 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 9178 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9179 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 9180 | pr_info("Reporting MCS rate %d flags %x\n", |
| 9181 | sinfo->txrate.mcs, |
| 9182 | sinfo->txrate.flags ); |
| 9183 | #endif //LINKSPEED_DEBUG_ENABLED |
| 9184 | } |
| 9185 | } |
| 9186 | else |
| 9187 | { |
| 9188 | // report current rate instead of max rate |
| 9189 | |
| 9190 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 9191 | { |
| 9192 | //provide to the UI in units of 100kbps |
| 9193 | sinfo->txrate.legacy = myRate; |
| 9194 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 9195 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 9196 | #endif //LINKSPEED_DEBUG_ENABLED |
| 9197 | } |
| 9198 | else |
| 9199 | { |
| 9200 | //must be MCS |
| 9201 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9202 | #ifdef WLAN_FEATURE_11AC |
| 9203 | sinfo->txrate.nss = 1; |
| 9204 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 9205 | { |
| 9206 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 9207 | } |
| 9208 | else |
| 9209 | #endif /* WLAN_FEATURE_11AC */ |
| 9210 | { |
| 9211 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 9212 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9213 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 9214 | { |
| 9215 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 9216 | } |
| 9217 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 9218 | { |
| 9219 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 9220 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 9221 | #ifdef WLAN_FEATURE_11AC |
| 9222 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 9223 | { |
| 9224 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 9225 | } |
| 9226 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9227 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 9228 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 9229 | sinfo->txrate.mcs, |
| 9230 | sinfo->txrate.flags ); |
| 9231 | #endif //LINKSPEED_DEBUG_ENABLED |
| 9232 | } |
| 9233 | } |
| 9234 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 9235 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 9236 | sinfo->tx_packets = |
| 9237 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 9238 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 9239 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 9240 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 9241 | |
| 9242 | sinfo->tx_retries = |
| 9243 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 9244 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 9245 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 9246 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 9247 | |
| 9248 | sinfo->tx_failed = |
| 9249 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 9250 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 9251 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 9252 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 9253 | |
| 9254 | sinfo->filled |= |
| 9255 | STATION_INFO_TX_PACKETS | |
| 9256 | STATION_INFO_TX_RETRIES | |
| 9257 | STATION_INFO_TX_FAILED; |
| 9258 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9259 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9260 | TRACE_CODE_HDD_CFG80211_GET_STA, |
| 9261 | pAdapter->sessionId, maxRate)); |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 9262 | EXIT(); |
| 9263 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9264 | } |
| 9265 | |
| 9266 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 9267 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9268 | { |
| 9269 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 9270 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9271 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9272 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9273 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9274 | ENTER(); |
| 9275 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9276 | if (NULL == pAdapter) |
| 9277 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9278 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9279 | return -ENODEV; |
| 9280 | } |
| 9281 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9282 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9283 | TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT, |
| 9284 | pAdapter->sessionId, timeout)); |
| 9285 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 9286 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9287 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 9288 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9289 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9290 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9292 | "%s: HDD context is not valid", __func__); |
| 9293 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9294 | } |
| 9295 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 9296 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 9297 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 9298 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 9299 | (eConnectionState_Associated == |
| 9300 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 9301 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 9302 | |
| 9303 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9304 | "offload: in cfg80211_set_power_mgmt, calling arp offload"); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 9305 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 9306 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 9307 | { |
| 9308 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9309 | "%s:Failed to enable ARPOFFLOAD Feature %d", |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 9310 | __func__, vos_status); |
| 9311 | } |
| 9312 | } |
| 9313 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9314 | /**The get power cmd from the supplicant gets updated by the nl only |
| 9315 | *on successful execution of the function call |
| 9316 | *we are oppositely mapped w.r.t mode in the driver |
| 9317 | **/ |
| 9318 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 9319 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9320 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9321 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 9322 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9323 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9324 | "%s: failed to enter bmps mode", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9325 | return -EINVAL; |
| 9326 | } |
| 9327 | return 0; |
| 9328 | } |
| 9329 | |
| 9330 | |
| 9331 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 9332 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 9333 | struct net_device *netdev, |
| 9334 | u8 key_index) |
| 9335 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9336 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9337 | return 0; |
| 9338 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9339 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9340 | |
| 9341 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 9342 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 9343 | struct net_device *dev, |
| 9344 | struct ieee80211_txq_params *params) |
| 9345 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9346 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9347 | return 0; |
| 9348 | } |
| 9349 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 9350 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 9351 | struct ieee80211_txq_params *params) |
| 9352 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9353 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9354 | return 0; |
| 9355 | } |
| 9356 | #endif //LINUX_VERSION_CODE |
| 9357 | |
| 9358 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 9359 | struct net_device *dev, u8 *mac) |
| 9360 | { |
| 9361 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9362 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9363 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9364 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9365 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9366 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9367 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9368 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9369 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9370 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9371 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9372 | return -EINVAL; |
| 9373 | } |
| 9374 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9375 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9376 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
| 9377 | pAdapter->sessionId, pAdapter->device_mode)); |
| 9378 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9379 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9380 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9381 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9382 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9383 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9384 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9385 | "%s: HDD context is not valid", __func__); |
| 9386 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9387 | } |
| 9388 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9389 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9390 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9391 | ) |
| 9392 | { |
| 9393 | if( NULL == mac ) |
| 9394 | { |
| 9395 | v_U16_t i; |
| 9396 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 9397 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 9398 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 9399 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9400 | { |
| 9401 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 9402 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9403 | "%s: Delete STA with MAC::" |
| 9404 | MAC_ADDRESS_STR, |
| 9405 | __func__, MAC_ADDR_ARRAY(macAddr)); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 9406 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 9407 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 9408 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9409 | } |
| 9410 | } |
| 9411 | } |
| 9412 | else |
| 9413 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9414 | |
| 9415 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 9416 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 9417 | { |
| 9418 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9419 | "%s: Skip this DEL STA as this is not used::" |
| 9420 | MAC_ADDRESS_STR, |
| 9421 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9422 | return -ENOENT; |
| 9423 | } |
| 9424 | |
| 9425 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 9426 | { |
| 9427 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9428 | "%s: Skip this DEL STA as deauth is in progress::" |
| 9429 | MAC_ADDRESS_STR, |
| 9430 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9431 | return -ENOENT; |
| 9432 | } |
| 9433 | |
| 9434 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 9435 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9436 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9437 | "%s: Delete STA with MAC::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9438 | MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9439 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9440 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9441 | |
| 9442 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 9443 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 9444 | { |
| 9445 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 9446 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9447 | "%s: STA removal failed for ::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9448 | MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9449 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9450 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9451 | return -ENOENT; |
| 9452 | } |
| 9453 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9454 | } |
| 9455 | } |
| 9456 | |
| 9457 | EXIT(); |
| 9458 | |
| 9459 | return 0; |
| 9460 | } |
| 9461 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 9462 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 9463 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 9464 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9465 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 9466 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 9467 | #ifdef FEATURE_WLAN_TDLS |
| 9468 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 9469 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9470 | |
| 9471 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9472 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
| 9473 | pAdapter->sessionId, params->listen_interval)); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 9474 | mask = params->sta_flags_mask; |
| 9475 | |
| 9476 | set = params->sta_flags_set; |
| 9477 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 9478 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 9479 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9480 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 9481 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 9482 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 9483 | |
| 9484 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 9485 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 9486 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 9487 | } |
| 9488 | } |
| 9489 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 9490 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9491 | } |
| 9492 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9493 | |
| 9494 | #ifdef FEATURE_WLAN_LFR |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9495 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9496 | 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] | 9497 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9498 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9499 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9500 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9501 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9502 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9503 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9504 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9505 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9506 | hdd_context_t *pHddCtx; |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9507 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR, |
| 9508 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9509 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9510 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9511 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9512 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9513 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9514 | return -EINVAL; |
| 9515 | } |
| 9516 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9517 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9518 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9519 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9520 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9521 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9522 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9523 | "%s: HDD context is not valid", __func__); |
| 9524 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9525 | } |
| 9526 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9527 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9528 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9529 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9530 | |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9531 | for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9532 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9533 | if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9534 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 9535 | { |
| 9536 | /* BSSID matched previous entry. Overwrite it. */ |
| 9537 | BSSIDMatched = 1; |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9538 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9539 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9540 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9541 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9542 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9543 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9544 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9545 | dump_bssid(pmksa->bssid); |
| 9546 | dump_pmkid(halHandle, pmksa->pmkid); |
| 9547 | break; |
| 9548 | } |
| 9549 | } |
| 9550 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 9551 | /* Check we compared all entries,if then take the first slot now */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9552 | if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0; |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 9553 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9554 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9555 | { |
| 9556 | // 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] | 9557 | vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9558 | pmksa->bssid, ETHER_ADDR_LEN); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9559 | vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9560 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9561 | CSR_RSN_PMKID_SIZE); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9562 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.", |
| 9563 | __func__, pHddStaCtx->PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9564 | dump_bssid(pmksa->bssid); |
| 9565 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9566 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9567 | // 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] | 9568 | if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) |
| 9569 | pHddStaCtx->PMKIDCacheIndex++; |
| 9570 | else |
| 9571 | pHddStaCtx->PMKIDCacheIndex = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9572 | } |
| 9573 | |
| 9574 | |
| 9575 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9576 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.", |
| 9577 | __func__, pHddStaCtx->PMKIDCacheIndex ); |
| 9578 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9579 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9580 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9581 | pHddStaCtx->PMKIDCache, |
| 9582 | pHddStaCtx->PMKIDCacheIndex); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9583 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9584 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
| 9585 | pAdapter->sessionId, result)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9586 | return 0; |
| 9587 | } |
| 9588 | |
| 9589 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9590 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9591 | 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] | 9592 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9593 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9594 | tANI_U32 j=0; |
| 9595 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9596 | hdd_station_ctx_t *pHddStaCtx; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9597 | tHalHandle halHandle; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9598 | tANI_U8 BSSIDMatched = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9599 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9600 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9601 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9602 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR, |
| 9603 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9604 | |
| 9605 | /* Validate pAdapter */ |
| 9606 | if (NULL == pAdapter) |
| 9607 | { |
| 9608 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
| 9609 | return -EINVAL; |
| 9610 | } |
| 9611 | |
| 9612 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9613 | status = wlan_hdd_validate_context(pHddCtx); |
| 9614 | |
| 9615 | if (0 != status) |
| 9616 | { |
| 9617 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9618 | "%s: HDD context is not valid", __func__); |
| 9619 | return status; |
| 9620 | } |
| 9621 | |
| 9622 | /*Retrieve halHandle*/ |
| 9623 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9624 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9625 | |
| 9626 | /*in case index is 0,no entry to delete*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9627 | if (0 == pHddStaCtx->PMKIDCacheIndex) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9628 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9629 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush")); |
| 9630 | return 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9631 | } |
| 9632 | |
| 9633 | /*find the matching PMKSA entry from j=0 to (index-1), |
| 9634 | * and delete the matched one |
| 9635 | */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9636 | for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9637 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9638 | if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9639 | pmksa->bssid, |
| 9640 | WNI_CFG_BSSID_LEN)) |
| 9641 | { |
| 9642 | /* BSSID matched entry */ |
| 9643 | BSSIDMatched = 1; |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9644 | if (j < pHddStaCtx->PMKIDCacheIndex-1) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9645 | { |
| 9646 | /*replace the matching entry with the last entry in HDD local cache*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9647 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID, |
| 9648 | pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID, |
| 9649 | VOS_MAC_ADDR_SIZE); |
| 9650 | vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID, |
| 9651 | pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID, |
| 9652 | CSR_RSN_PMKID_SIZE); |
| 9653 | } |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9654 | |
| 9655 | /*clear the last entry in HDD cache ---[index-1]*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9656 | vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID, |
| 9657 | VOS_MAC_ADDR_SIZE); |
| 9658 | vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID, |
| 9659 | CSR_RSN_PMKID_SIZE); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9660 | /*reduce the PMKID array index*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9661 | pHddStaCtx->PMKIDCacheIndex--; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9662 | /*delete the last PMKID cache in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9663 | if (eHAL_STATUS_SUCCESS != |
| 9664 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9665 | { |
| 9666 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.", |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9667 | __func__, pHddStaCtx->PMKIDCacheIndex); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9668 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9669 | } |
| 9670 | |
| 9671 | dump_bssid(pmksa->bssid); |
| 9672 | dump_pmkid(halHandle,pmksa->pmkid); |
| 9673 | |
| 9674 | break; |
| 9675 | } |
| 9676 | } |
| 9677 | |
| 9678 | /* we compare all entries,but cannot find matching entry */ |
| 9679 | if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched) |
| 9680 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9681 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9682 | "%s: No such PMKSA entry existed " MAC_ADDRESS_STR, |
| 9683 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9684 | dump_bssid(pmksa->bssid); |
| 9685 | dump_pmkid(halHandle, pmksa->pmkid); |
| 9686 | return -EINVAL; |
| 9687 | } |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9688 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9689 | } |
| 9690 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9691 | |
| 9692 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9693 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 9694 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9695 | tANI_U32 j=0; |
| 9696 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9697 | hdd_station_ctx_t *pHddStaCtx; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9698 | tHalHandle halHandle; |
| 9699 | hdd_context_t *pHddCtx; |
| 9700 | tANI_U8 *pBSSId; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9701 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9702 | |
| 9703 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__); |
| 9704 | |
| 9705 | /* Validate pAdapter */ |
| 9706 | if (NULL == pAdapter) |
| 9707 | { |
| 9708 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9709 | "%s: Invalid Adapter" ,__func__); |
| 9710 | return -EINVAL; |
| 9711 | } |
| 9712 | |
| 9713 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9714 | status = wlan_hdd_validate_context(pHddCtx); |
| 9715 | |
| 9716 | if (0 != status) |
| 9717 | { |
| 9718 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9719 | "%s: HDD context is not valid", __func__); |
| 9720 | return status; |
| 9721 | } |
| 9722 | |
| 9723 | /*Retrieve halHandle*/ |
| 9724 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9725 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9726 | |
| 9727 | /*in case index is 0,no entry to delete*/ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9728 | if (0 == pHddStaCtx->PMKIDCacheIndex) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9729 | { |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 9730 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush")); |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9731 | return 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9732 | } |
| 9733 | |
| 9734 | /*delete all the PMKSA one by one */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9735 | for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9736 | { |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9737 | pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9738 | /*delete the PMKID in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9739 | if (eHAL_STATUS_SUCCESS != |
| 9740 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9741 | { |
| 9742 | hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.", |
| 9743 | __func__,j); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9744 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9745 | } |
Kiet Lam | 8d21d5b | 2013-10-31 17:18:29 +0530 | [diff] [blame] | 9746 | /*clear the entry in HDD cache 0--index-1 */ |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9747 | vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE); |
| 9748 | vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE); |
| 9749 | } |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 9750 | |
Agarwal Ashish | 3da9524 | 2014-05-21 14:57:17 +0530 | [diff] [blame] | 9751 | pHddStaCtx->PMKIDCacheIndex = 0; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 9752 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9753 | } |
| 9754 | #endif |
| 9755 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9756 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9757 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9758 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 9759 | { |
| 9760 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9761 | hdd_station_ctx_t *pHddStaCtx; |
| 9762 | |
| 9763 | if (NULL == pAdapter) |
| 9764 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9765 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9766 | return -ENODEV; |
| 9767 | } |
| 9768 | |
| 9769 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9770 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9771 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 9772 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
| 9773 | pAdapter->sessionId, pHddStaCtx->conn_info.connState)); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9774 | // Added for debug on reception of Re-assoc Req. |
| 9775 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 9776 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9777 | 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] | 9778 | ftie->ie_len); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9779 | hddLog(LOGE, FL("Should be Re-assoc Req IEs")); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9780 | } |
| 9781 | |
| 9782 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9783 | hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9784 | ftie->ie_len); |
| 9785 | #endif |
| 9786 | |
| 9787 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 9788 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 9789 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9790 | ftie->ie_len); |
| 9791 | return 0; |
| 9792 | } |
| 9793 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9794 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9795 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9796 | |
| 9797 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 9798 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 9799 | { |
| 9800 | int ret; |
| 9801 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 9802 | hdd_context_t *pHddCtx; |
| 9803 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 9804 | ENTER(); |
| 9805 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9806 | if (NULL == pAdapter) |
| 9807 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 9808 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9809 | "%s: HDD adapter is Null", __func__); |
| 9810 | return ; |
| 9811 | } |
| 9812 | |
| 9813 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9814 | if (NULL == pHddCtx) |
| 9815 | { |
| 9816 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9817 | "%s: HDD context is Null!!!", __func__); |
| 9818 | return ; |
| 9819 | } |
| 9820 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9821 | spin_lock(&pHddCtx->schedScan_lock); |
| 9822 | if (TRUE == pHddCtx->isWiphySuspended) |
| 9823 | { |
| 9824 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 9825 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9826 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9827 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 9828 | return ; |
| 9829 | } |
| 9830 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9831 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9832 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 9833 | |
| 9834 | if (0 > ret) |
| 9835 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 9836 | |
| 9837 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9838 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9839 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9840 | } |
| 9841 | |
| 9842 | /* |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9843 | * FUNCTION: wlan_hdd_is_pno_allowed |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 9844 | * Disallow pno if any session is active |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9845 | */ |
| 9846 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter) |
| 9847 | { |
| 9848 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9849 | hdd_adapter_t *pTempAdapter = NULL; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9850 | hdd_station_ctx_t *pStaCtx; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9851 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9852 | int status = 0; |
| 9853 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 9854 | |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 9855 | /* The current firmware design does not allow PNO during any |
| 9856 | * active sessions. Hence, determine the active sessions |
| 9857 | * and return a failure. |
| 9858 | */ |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9859 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)) |
| 9860 | { |
| 9861 | pTempAdapter = pAdapterNode->pAdapter; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9862 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9863 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9864 | if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode) |
| 9865 | && (eConnectionState_NotConnected != pStaCtx->conn_info.connState)) |
| 9866 | || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode) |
| 9867 | || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode) |
| 9868 | || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode) |
| 9869 | ) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9870 | { |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9871 | return eHAL_STATUS_FAILURE; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9872 | } |
| 9873 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9874 | pAdapterNode = pNext; |
| 9875 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9876 | return eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9877 | } |
| 9878 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 9879 | void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status) |
| 9880 | { |
| 9881 | hdd_adapter_t *pAdapter = callbackContext; |
| 9882 | hdd_context_t *pHddCtx; |
| 9883 | |
| 9884 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 9885 | { |
| 9886 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9887 | FL("Invalid adapter or adapter has invalid magic")); |
| 9888 | return; |
| 9889 | } |
| 9890 | |
| 9891 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9892 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
| 9893 | { |
| 9894 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9895 | FL("HDD context is not valid")); |
| 9896 | return; |
| 9897 | } |
| 9898 | |
| 9899 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9900 | FL("PNO enable response status = %d"), status); |
| 9901 | |
| 9902 | pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 9903 | complete(&pAdapter->pno_comp_var); |
| 9904 | } |
| 9905 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9906 | /* |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 9907 | * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start |
| 9908 | * Function to enable PNO |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9909 | */ |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 9910 | static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9911 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 9912 | { |
| 9913 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9914 | tpSirPNOScanReq pPnoRequest = NULL; |
| 9915 | hdd_context_t *pHddCtx; |
| 9916 | tHalHandle hHal; |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 9917 | v_U32_t i, indx, num_ch, tempInterval; |
Sushant Kaushik | d62d978 | 2014-02-19 15:39:40 +0530 | [diff] [blame] | 9918 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 9919 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9920 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 9921 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 9922 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9923 | |
| 9924 | if (NULL == pAdapter) |
| 9925 | { |
| 9926 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9927 | "%s: HDD adapter is Null", __func__); |
| 9928 | return -ENODEV; |
| 9929 | } |
| 9930 | |
| 9931 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9932 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9933 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9934 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9935 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9936 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9937 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 9938 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9939 | } |
| 9940 | |
| 9941 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9942 | if (NULL == hHal) |
| 9943 | { |
| 9944 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9945 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9946 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9947 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9948 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 9949 | ret = wlan_hdd_scan_abort(pAdapter); |
| 9950 | if (ret <= 0) |
| 9951 | { |
| 9952 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9953 | "%s: aborting the existing scan is unsuccessfull", __func__); |
| 9954 | return -EBUSY; |
| 9955 | } |
| 9956 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9957 | if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter)) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9958 | { |
Vinay Krishna Eranna | cbf75f4 | 2014-02-26 17:35:20 +0530 | [diff] [blame] | 9959 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 9960 | FL("Cannot handle sched_scan")); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 9961 | return -EBUSY; |
| 9962 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9963 | |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 9964 | if (TRUE == pHddCtx->isPnoEnable) |
| 9965 | { |
| 9966 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 9967 | FL("already PNO is enabled")); |
| 9968 | return -EBUSY; |
| 9969 | } |
| 9970 | pHddCtx->isPnoEnable = TRUE; |
| 9971 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9972 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 9973 | if (NULL == pPnoRequest) |
| 9974 | { |
| 9975 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9976 | "%s: vos_mem_malloc failed", __func__); |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 9977 | pHddCtx->isPnoEnable = FALSE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 9978 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9979 | } |
| 9980 | |
Madan Mohan Koyyalamudi | c3f0435 | 2013-09-26 19:21:48 +0530 | [diff] [blame] | 9981 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9982 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 9983 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 9984 | |
| 9985 | if (( !pPnoRequest->ucNetworksCount ) || |
| 9986 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 9987 | { |
| 9988 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 9989 | "%s: Network input is not correct %d Max Network supported is %d", |
| 9990 | __func__, pPnoRequest->ucNetworksCount, |
| 9991 | SIR_PNO_MAX_SUPP_NETWORKS); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 9992 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9993 | goto error; |
| 9994 | } |
| 9995 | |
| 9996 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 9997 | { |
| 9998 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 9999 | "%s: Incorrect number of channels %d", |
| 10000 | __func__, request->n_channels); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10001 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10002 | goto error; |
| 10003 | } |
| 10004 | |
| 10005 | /* Framework provides one set of channels(all) |
| 10006 | * common for all saved profile */ |
| 10007 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 10008 | channels_allowed, &num_channels_allowed)) |
| 10009 | { |
| 10010 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10011 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10012 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10013 | goto error; |
| 10014 | } |
| 10015 | /* Checking each channel against allowed channel list */ |
| 10016 | num_ch = 0; |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10017 | if (request->n_channels) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10018 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10019 | char chList [(request->n_channels*5)+1]; |
| 10020 | int len; |
| 10021 | for (i = 0, len = 0; i < request->n_channels; i++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10022 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10023 | for (indx = 0; indx < num_channels_allowed; indx++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10024 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10025 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 10026 | { |
| 10027 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 10028 | len += snprintf(chList+len, 5, "%d ", |
| 10029 | request->channels[i]->hw_value); |
| 10030 | break ; |
| 10031 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10032 | } |
| 10033 | } |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10034 | hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList); |
| 10035 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10036 | |
| 10037 | /* Filling per profile params */ |
| 10038 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 10039 | { |
| 10040 | pPnoRequest->aNetworks[i].ssId.length = |
| 10041 | request->match_sets[i].ssid.ssid_len; |
| 10042 | |
| 10043 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 10044 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 10045 | { |
| 10046 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10047 | "%s: SSID Len %d is not correct for network %d", |
| 10048 | __func__, pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10049 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10050 | goto error; |
| 10051 | } |
| 10052 | |
| 10053 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 10054 | request->match_sets[i].ssid.ssid, |
| 10055 | request->match_sets[i].ssid.ssid_len); |
Sushant Kaushik | 1e406c3 | 2014-05-09 15:57:52 +0530 | [diff] [blame] | 10056 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10057 | "%s: SSID of network %d is %s ", __func__, |
| 10058 | i, pPnoRequest->aNetworks[i].ssId.ssId); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10059 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 10060 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 10061 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 10062 | |
| 10063 | /*Copying list of valid channel into request */ |
| 10064 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 10065 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 10066 | |
| 10067 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 10068 | } |
| 10069 | |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 10070 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 10071 | "request->ie_len = %zu", request->ie_len); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 10072 | if ((0 < request->ie_len) && (NULL != request->ie)) |
| 10073 | { |
| 10074 | pPnoRequest->us24GProbeTemplateLen = request->ie_len; |
| 10075 | memcpy(&pPnoRequest->p24GProbeTemplate, request->ie, |
| 10076 | pPnoRequest->us24GProbeTemplateLen); |
| 10077 | |
| 10078 | pPnoRequest->us5GProbeTemplateLen = request->ie_len; |
| 10079 | memcpy(&pPnoRequest->p5GProbeTemplate, request->ie, |
| 10080 | pPnoRequest->us5GProbeTemplateLen); |
| 10081 | } |
| 10082 | |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 10083 | /* Driver gets only one time interval which is hardcoded in |
| 10084 | * supplicant for 10000ms. Taking power consumption into account 6 timers |
| 10085 | * will be used, Timervalue is increased exponentially i.e 10,20,40, |
| 10086 | * 80,160,320 secs. And number of scan cycle for each timer |
| 10087 | * is configurable through INI param gPNOScanTimerRepeatValue. |
| 10088 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 10089 | * will be repeated after each interval specified by supplicant |
| 10090 | * till PNO is disabled. |
| 10091 | */ |
| 10092 | if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue) |
| 10093 | pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 10094 | else |
| 10095 | pPnoRequest->scanTimers.ucScanTimersCount = |
| 10096 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 10097 | |
| 10098 | tempInterval = (request->interval)/1000; |
| 10099 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10100 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 10101 | tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue); |
| 10102 | for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++) |
| 10103 | { |
| 10104 | pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat = |
| 10105 | pHddCtx->cfg_ini->configPNOScanTimerRepeatValue; |
| 10106 | pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval; |
| 10107 | tempInterval *= 2; |
| 10108 | } |
| 10109 | //Repeat last timer until pno disabled. |
| 10110 | pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
| 10111 | |
Madan Mohan Koyyalamudi | d206c7b | 2013-09-26 22:54:51 +0530 | [diff] [blame] | 10112 | pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10113 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 10114 | INIT_COMPLETION(pAdapter->pno_comp_var); |
| 10115 | pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb; |
| 10116 | pPnoRequest->callbackContext = pAdapter; |
| 10117 | pAdapter->pno_req_status = 0; |
| 10118 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10119 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10120 | "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d", |
| 10121 | pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO, |
| 10122 | pPnoRequest->scanTimers.ucScanTimersCount); |
| 10123 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10124 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10125 | pPnoRequest, pAdapter->sessionId, |
| 10126 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 10127 | if (eHAL_STATUS_SUCCESS != status) |
| 10128 | { |
| 10129 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 10130 | "%s: Failed to enable PNO", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10131 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10132 | goto error; |
| 10133 | } |
| 10134 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 10135 | ret = wait_for_completion_timeout( |
| 10136 | &pAdapter->pno_comp_var, |
| 10137 | msecs_to_jiffies(WLAN_WAIT_TIME_PNO)); |
| 10138 | if (0 >= ret) |
| 10139 | { |
| 10140 | // Did not receive the response for PNO enable in time. |
| 10141 | // Assuming the PNO enable was success. |
| 10142 | // Returning error from here, because we timeout, results |
| 10143 | // in side effect of Wifi (Wifi Setting) not to work. |
| 10144 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10145 | FL("Timed out waiting for PNO to be Enabled")); |
| 10146 | ret = 0; |
| 10147 | goto error; |
| 10148 | } |
| 10149 | |
| 10150 | ret = pAdapter->pno_req_status; |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 10151 | return ret; |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 10152 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10153 | error: |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 10154 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10155 | FL("PNO scanRequest offloaded ret = %d"), ret); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10156 | vos_mem_free(pPnoRequest); |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 10157 | pHddCtx->isPnoEnable = FALSE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10158 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10159 | } |
| 10160 | |
| 10161 | /* |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 10162 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 10163 | * NL interface to enable PNO |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10164 | */ |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 10165 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 10166 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 10167 | { |
| 10168 | int ret; |
| 10169 | |
| 10170 | vos_ssr_protect(__func__); |
| 10171 | ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request); |
| 10172 | vos_ssr_unprotect(__func__); |
| 10173 | |
| 10174 | return ret; |
| 10175 | } |
| 10176 | |
| 10177 | /* |
| 10178 | * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop |
| 10179 | * Function to disable PNO |
| 10180 | */ |
| 10181 | static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10182 | struct net_device *dev) |
| 10183 | { |
| 10184 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 10185 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10186 | hdd_context_t *pHddCtx; |
| 10187 | tHalHandle hHal; |
| 10188 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10189 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10190 | |
| 10191 | ENTER(); |
| 10192 | |
| 10193 | if (NULL == pAdapter) |
| 10194 | { |
| 10195 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10196 | "%s: HDD adapter is Null", __func__); |
| 10197 | return -ENODEV; |
| 10198 | } |
| 10199 | |
| 10200 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10201 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10202 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10203 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 10204 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10205 | "%s: HDD context is Null", __func__); |
| 10206 | return -ENODEV; |
| 10207 | } |
| 10208 | |
| 10209 | /* The return 0 is intentional when isLogpInProgress and |
| 10210 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 10211 | * failure in sched_scan_stop , especially for a case where the unload |
| 10212 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 10213 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 10214 | * success. If it returns a failure , then its next invocation due to the |
| 10215 | * clean up of the second interface will have the dev pointer corresponding |
| 10216 | * to the first one leading to a crash. |
| 10217 | */ |
| 10218 | if (pHddCtx->isLogpInProgress) |
| 10219 | { |
| 10220 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10221 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 10222 | return ret; |
| 10223 | } |
| 10224 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 10225 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10226 | { |
| 10227 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10228 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 10229 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10230 | } |
| 10231 | |
| 10232 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 10233 | if (NULL == hHal) |
| 10234 | { |
| 10235 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10236 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 10237 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10238 | } |
| 10239 | |
| 10240 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 10241 | if (NULL == pPnoRequest) |
| 10242 | { |
| 10243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10244 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10245 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10246 | } |
| 10247 | |
| 10248 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 10249 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 10250 | pPnoRequest->ucNetworksCount = 0; |
| 10251 | |
| 10252 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 10253 | pAdapter->sessionId, |
| 10254 | NULL, pAdapter); |
| 10255 | if (eHAL_STATUS_SUCCESS != status) |
| 10256 | { |
| 10257 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10258 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10259 | ret = -EINVAL; |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 10260 | goto error; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10261 | } |
c_hpothu | 37f2131 | 2014-04-09 21:49:54 +0530 | [diff] [blame] | 10262 | pHddCtx->isPnoEnable = FALSE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10263 | |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 10264 | error: |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 10265 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 10266 | FL("PNO scan disabled ret = %d"), ret); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10267 | vos_mem_free(pPnoRequest); |
| 10268 | |
| 10269 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 10270 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10271 | } |
| 10272 | |
Mahesh A Saptasagar | 6cc3856 | 2014-05-23 21:22:17 +0530 | [diff] [blame] | 10273 | /* |
| 10274 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 10275 | * NL interface to disable PNO |
| 10276 | */ |
| 10277 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 10278 | struct net_device *dev) |
| 10279 | { |
| 10280 | int ret; |
| 10281 | |
| 10282 | vos_ssr_protect(__func__); |
| 10283 | ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev); |
| 10284 | vos_ssr_unprotect(__func__); |
| 10285 | |
| 10286 | return ret; |
| 10287 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 10288 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 10289 | |
| 10290 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10291 | #ifdef FEATURE_WLAN_TDLS |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 10292 | #if TDLS_MGMT_VERSION2 |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10293 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 10294 | u8 *peer, u8 action_code, u8 dialog_token, |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 10295 | u16 status_code, u32 peer_capability, const u8 *buf, size_t len) |
| 10296 | #else |
| 10297 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 10298 | u8 *peer, u8 action_code, u8 dialog_token, |
| 10299 | u16 status_code, const u8 *buf, size_t len) |
| 10300 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10301 | { |
| 10302 | |
| 10303 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10304 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10305 | u8 peerMac[6]; |
| 10306 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 10307 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10308 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 10309 | long rc; |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 10310 | #if !(TDLS_MGMT_VERSION2) |
| 10311 | u32 peer_capability = 0; |
| 10312 | #endif |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10313 | tANI_U16 numCurrTdlsPeers; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10314 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10315 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10316 | TRACE_CODE_HDD_CFG80211_TDLS_MGMT, |
| 10317 | pAdapter->sessionId, action_code)); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10318 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10319 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 10320 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10321 | "Invalid arguments"); |
| 10322 | return -EINVAL; |
| 10323 | } |
| 10324 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 10325 | if (pHddCtx->isLogpInProgress) |
| 10326 | { |
| 10327 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10328 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 10329 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 10330 | return -EBUSY; |
| 10331 | } |
| 10332 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 10333 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10334 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 10335 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 10336 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 10337 | MAC_ADDRESS_STR " action %d declined.", |
| 10338 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10339 | return -ENOTSUPP; |
| 10340 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10341 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 10342 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 10343 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 10344 | { |
| 10345 | /* if tdls_mode is disabled to respond to peer's request */ |
| 10346 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 10347 | { |
| 10348 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 10349 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 10350 | " TDLS mode is disabled. action %d declined.", |
| 10351 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 10352 | |
| 10353 | return -ENOTSUPP; |
| 10354 | } |
| 10355 | } |
| 10356 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10357 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 10358 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10359 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10360 | { |
| 10361 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10362 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 10363 | " TDLS setup is ongoing. action %d declined.", |
| 10364 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 10365 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10366 | } |
| 10367 | } |
| 10368 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10369 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 10370 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10371 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10372 | numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 10373 | if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10374 | { |
| 10375 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 10376 | we return error code at 'add_station()'. Hence we have this |
| 10377 | check again in addtion to add_station(). |
| 10378 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10379 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10380 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10381 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10382 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10383 | " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).", |
| 10384 | __func__, MAC_ADDR_ARRAY(peer), action_code, |
| 10385 | numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 10386 | return -EINVAL; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10387 | } |
| 10388 | else |
| 10389 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10390 | /* maximum reached. tweak to send error code to peer and return |
| 10391 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10392 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10393 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10394 | "%s: " MAC_ADDRESS_STR |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10395 | " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).", |
| 10396 | __func__, MAC_ADDR_ARRAY(peer), status_code, |
| 10397 | numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 10398 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10399 | /* fall through to send setup resp with failure status |
| 10400 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10401 | } |
| 10402 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10403 | else |
| 10404 | { |
| 10405 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10406 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 10407 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10408 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10409 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 10410 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 10411 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10412 | return -EPERM; |
| 10413 | } |
| 10414 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10415 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10416 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10417 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 10418 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 10419 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Kumar Khandavalli | 9fb625e | 2014-03-17 16:07:40 +0530 | [diff] [blame] | 10420 | "%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] | 10421 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 10422 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 10423 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10424 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10425 | /*Except teardown responder will not be used so just make 0*/ |
| 10426 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 10427 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10428 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 10429 | |
| 10430 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10431 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 10432 | |
| 10433 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 10434 | responder = pTdlsPeer->is_responder; |
| 10435 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10436 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 10437 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Kumar Khandavalli | 9fb625e | 2014-03-17 16:07:40 +0530 | [diff] [blame] | 10438 | "%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] | 10439 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 10440 | dialog_token, status_code, len); |
| 10441 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10442 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10443 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10444 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 10445 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 10446 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10447 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 10448 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 10449 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10450 | { |
| 10451 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 10452 | { |
| 10453 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 10454 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10455 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 10456 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 10457 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 10458 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10459 | } |
| 10460 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10461 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 10462 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 10463 | { |
| 10464 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10465 | "%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] | 10466 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 10467 | return -EBUSY; |
| 10468 | } |
| 10469 | |
| 10470 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10471 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 10472 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10473 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Pradeep Reddy POTTETI | ca171f8 | 2014-03-21 14:17:35 +0530 | [diff] [blame] | 10474 | 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] | 10475 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10476 | if (VOS_STATUS_SUCCESS != status) |
| 10477 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10478 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10479 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10480 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10481 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 10482 | return -EINVAL; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10483 | } |
| 10484 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 10485 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 10486 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 10487 | |
| 10488 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10489 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 10490 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 10491 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %u", |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 10492 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10493 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 10494 | |
| 10495 | if (pHddCtx->isLogpInProgress) |
| 10496 | { |
| 10497 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10498 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 10499 | return -EAGAIN; |
| 10500 | } |
| 10501 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 10502 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 10503 | return -EINVAL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10504 | } |
| 10505 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 10506 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10507 | { |
| 10508 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 10509 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10510 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10511 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10512 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 10513 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10514 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10515 | } |
| 10516 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 10517 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 10518 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 10519 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10520 | |
| 10521 | return 0; |
| 10522 | } |
| 10523 | |
| 10524 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 10525 | u8 *peer, enum nl80211_tdls_operation oper) |
| 10526 | { |
| 10527 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10528 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10529 | int status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10530 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10531 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10532 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10533 | TRACE_CODE_HDD_CFG80211_TDLS_OPER, |
| 10534 | pAdapter->sessionId, oper)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10535 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10536 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 10537 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10538 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10539 | return -EINVAL; |
| 10540 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 10541 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10542 | status = wlan_hdd_validate_context(pHddCtx); |
| 10543 | |
| 10544 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 10545 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10546 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10547 | "%s: HDD context is not valid", __func__); |
| 10548 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 10549 | } |
| 10550 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10551 | |
| 10552 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 10553 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10554 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 10555 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10556 | "TDLS Disabled in INI OR not enabled in FW. " |
| 10557 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10558 | return -ENOTSUPP; |
| 10559 | } |
| 10560 | |
| 10561 | switch (oper) { |
| 10562 | case NL80211_TDLS_ENABLE_LINK: |
| 10563 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10564 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10565 | long ret; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 10566 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10567 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10568 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 10569 | |
| 10570 | if ( NULL == pTdlsPeer ) { |
| 10571 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 10572 | " (oper %d) not exsting. ignored", |
| 10573 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 10574 | return -EINVAL; |
| 10575 | } |
| 10576 | |
| 10577 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10578 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 10579 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 10580 | "NL80211_TDLS_ENABLE_LINK"); |
| 10581 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 10582 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 10583 | { |
| 10584 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 10585 | MAC_ADDRESS_STR " failed", |
| 10586 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 10587 | return -EINVAL; |
| 10588 | } |
| 10589 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10590 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10591 | { |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 10592 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 10593 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 10594 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 10595 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 10596 | return -EINVAL; |
| 10597 | } |
| 10598 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 10599 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 10600 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10601 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 10602 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 10603 | * register with the TL on after the response for this operation |
| 10604 | * is received . |
| 10605 | */ |
| 10606 | ret = wait_for_completion_interruptible_timeout( |
| 10607 | &pAdapter->tdls_link_establish_req_comp, |
| 10608 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 10609 | if (ret <= 0) |
| 10610 | { |
| 10611 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10612 | "%s: Link Establish Request Faled Status %ld", |
| 10613 | __func__, ret); |
| 10614 | return -EINVAL; |
| 10615 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 10616 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 10617 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 10618 | /* Mark TDLS client Authenticated .*/ |
| 10619 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 10620 | pTdlsPeer->staId, |
| 10621 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 10622 | if (VOS_STATUS_SUCCESS == status) |
| 10623 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 10624 | if (pTdlsPeer->is_responder == 0) |
| 10625 | { |
| 10626 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 10627 | |
| 10628 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 10629 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 10630 | WAIT_TIME_TDLS_INITIATOR); |
| 10631 | /* suspend initiator TX until it receives direct packet from the |
| 10632 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 10633 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 10634 | &staId, NULL); |
| 10635 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 10636 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 10637 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10638 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 10639 | |
| 10640 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 10641 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 10642 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 10643 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 10644 | int ac; |
| 10645 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 10646 | WLANTL_AC_VI, |
| 10647 | WLANTL_AC_BK, |
| 10648 | WLANTL_AC_BE }; |
| 10649 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 10650 | for(ac=0; ac < 4; ac++) |
| 10651 | { |
| 10652 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 10653 | pTdlsPeer->staId, ucAc[ac], |
| 10654 | tlTid[ac], tlTid[ac], 0, 0, |
| 10655 | WLANTL_BI_DIR ); |
| 10656 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 10657 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10658 | } |
| 10659 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10660 | } |
| 10661 | break; |
| 10662 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10663 | { |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10664 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 10665 | |
| 10666 | if ( NULL == pTdlsPeer ) { |
| 10667 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 10668 | " (oper %d) not exsting. ignored", |
| 10669 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 10670 | return -EINVAL; |
| 10671 | } |
| 10672 | |
| 10673 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10674 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 10675 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 10676 | "NL80211_TDLS_DISABLE_LINK"); |
| 10677 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10678 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10679 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 10680 | long status; |
| 10681 | |
| 10682 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 10683 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10684 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10685 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 10686 | |
| 10687 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 10688 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 10689 | if (status <= 0) |
| 10690 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10691 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 10692 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10693 | "%s: Del station failed status %ld", |
| 10694 | __func__, status); |
| 10695 | return -EPERM; |
| 10696 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 10697 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10698 | } |
| 10699 | else |
| 10700 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10701 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10702 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10703 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 10704 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 10705 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10706 | case NL80211_TDLS_TEARDOWN: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10707 | { |
| 10708 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10709 | " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR, |
| 10710 | __func__, MAC_ADDR_ARRAY(peer)); |
| 10711 | |
| 10712 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 10713 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 10714 | |
| 10715 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10716 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 10717 | __func__); |
| 10718 | return -ENOTSUPP; |
| 10719 | } |
| 10720 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10721 | |
| 10722 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 10723 | |
| 10724 | if ( NULL == pTdlsPeer ) { |
| 10725 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR |
| 10726 | " peer not exsting", |
| 10727 | __func__, MAC_ADDR_ARRAY(peer)); |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 10728 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10729 | } |
| 10730 | else { |
| 10731 | wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, |
| 10732 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 10733 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 10734 | |
| 10735 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) |
| 10736 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10737 | break; |
| 10738 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10739 | case NL80211_TDLS_SETUP: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10740 | { |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 10741 | hddTdlsPeer_t *pTdlsPeer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10742 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10743 | " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR, |
| 10744 | __func__, MAC_ADDR_ARRAY(peer)); |
| 10745 | |
| 10746 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 10747 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 10748 | |
| 10749 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10750 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 10751 | __func__); |
| 10752 | return -ENOTSUPP; |
| 10753 | } |
| 10754 | |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 10755 | /* To cater the requirement of establishing the TDLS link |
| 10756 | * irrespective of the data traffic , get an entry of TDLS peer. |
| 10757 | */ |
| 10758 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer); |
| 10759 | if (pTdlsPeer == NULL) { |
| 10760 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10761 | "%s: peer " MAC_ADDRESS_STR " not existing", |
| 10762 | __func__, MAC_ADDR_ARRAY(peer)); |
| 10763 | return -EINVAL; |
| 10764 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 10765 | |
| 10766 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) { |
| 10767 | |
| 10768 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10769 | " %s TDLS Add Force Peer Failed", |
| 10770 | __func__); |
| 10771 | return -EINVAL; |
| 10772 | } |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 10773 | break; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 10774 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10775 | case NL80211_TDLS_DISCOVERY_REQ: |
| 10776 | /* We don't support in-driver setup/teardown/discovery */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10777 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 10778 | "%s: We don't support in-driver setup/teardown/discovery " |
| 10779 | ,__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10780 | return -ENOTSUPP; |
| 10781 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10782 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10783 | "%s: unsupported event",__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10784 | return -ENOTSUPP; |
| 10785 | } |
| 10786 | return 0; |
| 10787 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 10788 | |
| 10789 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 10790 | struct net_device *dev, u8 *peer) |
| 10791 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 10792 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10793 | "tdls send discover req: "MAC_ADDRESS_STR, |
| 10794 | MAC_ADDR_ARRAY(peer)); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 10795 | |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 10796 | #if TDLS_MGMT_VERSION2 |
| 10797 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 10798 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0); |
| 10799 | #else |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 10800 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 10801 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
Sunil Dutt Undekari | eacac6f | 2014-03-21 14:08:53 +0530 | [diff] [blame] | 10802 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 10803 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 10804 | #endif |
| 10805 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10806 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 10807 | /* |
| 10808 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 10809 | * Callback rountine called upon receiving response for |
| 10810 | * get offload info |
| 10811 | */ |
| 10812 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 10813 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 10814 | { |
| 10815 | |
| 10816 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10817 | tANI_U8 tempReplayCounter[8]; |
| 10818 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10819 | |
| 10820 | ENTER(); |
| 10821 | |
| 10822 | if (NULL == pAdapter) |
| 10823 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 10824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10825 | "%s: HDD adapter is Null", __func__); |
| 10826 | return ; |
| 10827 | } |
| 10828 | |
| 10829 | if (NULL == pGtkOffloadGetInfoRsp) |
| 10830 | { |
| 10831 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10832 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 10833 | return ; |
| 10834 | } |
| 10835 | |
| 10836 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 10837 | { |
| 10838 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10839 | "%s: wlan Failed to get replay counter value", |
| 10840 | __func__); |
| 10841 | return ; |
| 10842 | } |
| 10843 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10844 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10845 | /* Update replay counter */ |
| 10846 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 10847 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 10848 | |
| 10849 | { |
| 10850 | /* changing from little to big endian since supplicant |
| 10851 | * works on big endian format |
| 10852 | */ |
| 10853 | int i; |
| 10854 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 10855 | |
| 10856 | for (i = 0; i < 8; i++) |
| 10857 | { |
| 10858 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 10859 | } |
| 10860 | } |
| 10861 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10862 | /* Update replay counter to NL */ |
| 10863 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10864 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10865 | } |
| 10866 | |
| 10867 | /* |
| 10868 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 10869 | * This function is used to offload GTK rekeying job to the firmware. |
| 10870 | */ |
| 10871 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 10872 | struct cfg80211_gtk_rekey_data *data) |
| 10873 | { |
| 10874 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10875 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 10876 | hdd_station_ctx_t *pHddStaCtx; |
| 10877 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10878 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10879 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10880 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 10881 | |
| 10882 | ENTER(); |
| 10883 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10884 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10885 | if (NULL == pAdapter) |
| 10886 | { |
| 10887 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10888 | "%s: HDD adapter is Null", __func__); |
| 10889 | return -ENODEV; |
| 10890 | } |
| 10891 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10892 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 10893 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
| 10894 | pAdapter->sessionId, pAdapter->device_mode)); |
| 10895 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10896 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10897 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10898 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10899 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 10900 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10901 | "%s: HDD context is not valid", __func__); |
| 10902 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10903 | } |
| 10904 | |
| 10905 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10906 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 10907 | if (NULL == hHal) |
| 10908 | { |
| 10909 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10910 | "%s: HAL context is Null!!!", __func__); |
| 10911 | return -EAGAIN; |
| 10912 | } |
| 10913 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10914 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 10915 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 10916 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 10917 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10918 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10919 | { |
| 10920 | /* changing from big to little endian since driver |
| 10921 | * works on little endian format |
| 10922 | */ |
| 10923 | tANI_U8 *p = |
| 10924 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 10925 | int i; |
| 10926 | |
| 10927 | for (i = 0; i < 8; i++) |
| 10928 | { |
| 10929 | p[7-i] = data->replay_ctr[i]; |
| 10930 | } |
| 10931 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10932 | |
| 10933 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 10934 | { |
| 10935 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10936 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 10937 | sizeof (tSirGtkOffloadParams)); |
| 10938 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10939 | pAdapter->sessionId); |
| 10940 | |
| 10941 | if (eHAL_STATUS_SUCCESS != status) |
| 10942 | { |
| 10943 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10944 | "%s: sme_SetGTKOffload failed, returned %d", |
| 10945 | __func__, status); |
| 10946 | return status; |
| 10947 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10948 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10949 | "%s: sme_SetGTKOffload successfull", __func__); |
| 10950 | } |
| 10951 | else |
| 10952 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10953 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10954 | "%s: wlan not suspended GTKOffload request is stored", |
| 10955 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10956 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 10957 | |
| 10958 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 10959 | } |
| 10960 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 10961 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 10962 | /* |
| 10963 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 10964 | * This function is used to set access control policy |
| 10965 | */ |
| 10966 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 10967 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 10968 | { |
| 10969 | int i; |
| 10970 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 10971 | hdd_hostapd_state_t *pHostapdState; |
| 10972 | tsap_Config_t *pConfig; |
| 10973 | v_CONTEXT_t pVosContext = NULL; |
| 10974 | hdd_context_t *pHddCtx; |
| 10975 | int status; |
| 10976 | |
| 10977 | ENTER(); |
| 10978 | |
| 10979 | if (NULL == pAdapter) |
| 10980 | { |
| 10981 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10982 | "%s: HDD adapter is Null", __func__); |
| 10983 | return -ENODEV; |
| 10984 | } |
| 10985 | |
| 10986 | if (NULL == params) |
| 10987 | { |
| 10988 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10989 | "%s: params is Null", __func__); |
| 10990 | return -EINVAL; |
| 10991 | } |
| 10992 | |
| 10993 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10994 | status = wlan_hdd_validate_context(pHddCtx); |
| 10995 | |
| 10996 | if (0 != status) |
| 10997 | { |
| 10998 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10999 | "%s: HDD context is not valid", __func__); |
| 11000 | return status; |
| 11001 | } |
| 11002 | |
| 11003 | pVosContext = pHddCtx->pvosContext; |
| 11004 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 11005 | |
| 11006 | if (NULL == pHostapdState) |
| 11007 | { |
| 11008 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11009 | "%s: pHostapdState is Null", __func__); |
| 11010 | return -EINVAL; |
| 11011 | } |
| 11012 | |
| 11013 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 11014 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 11015 | |
| 11016 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 11017 | { |
| 11018 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 11019 | |
| 11020 | /* default value */ |
| 11021 | pConfig->num_accept_mac = 0; |
| 11022 | pConfig->num_deny_mac = 0; |
| 11023 | |
| 11024 | /** |
| 11025 | * access control policy |
| 11026 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 11027 | * listed in hostapd.deny file. |
| 11028 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 11029 | * listed in hostapd.accept file. |
| 11030 | */ |
| 11031 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 11032 | { |
| 11033 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 11034 | } |
| 11035 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 11036 | { |
| 11037 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 11038 | } |
| 11039 | else |
| 11040 | { |
| 11041 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11042 | "%s:Acl Policy : %d is not supported", |
| 11043 | __func__, params->acl_policy); |
| 11044 | return -ENOTSUPP; |
| 11045 | } |
| 11046 | |
| 11047 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 11048 | { |
| 11049 | pConfig->num_accept_mac = params->n_acl_entries; |
| 11050 | for (i = 0; i < params->n_acl_entries; i++) |
| 11051 | { |
| 11052 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11053 | "** Add ACL MAC entry %i in WhiletList :" |
| 11054 | MAC_ADDRESS_STR, i, |
| 11055 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 11056 | |
| 11057 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 11058 | sizeof(qcmacaddr)); |
| 11059 | } |
| 11060 | } |
| 11061 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 11062 | { |
| 11063 | pConfig->num_deny_mac = params->n_acl_entries; |
| 11064 | for (i = 0; i < params->n_acl_entries; i++) |
| 11065 | { |
| 11066 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11067 | "** Add ACL MAC entry %i in BlackList :" |
| 11068 | MAC_ADDRESS_STR, i, |
| 11069 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 11070 | |
| 11071 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 11072 | sizeof(qcmacaddr)); |
| 11073 | } |
| 11074 | } |
| 11075 | |
| 11076 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 11077 | { |
| 11078 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11079 | "%s: SAP Set Mac Acl fail", __func__); |
| 11080 | return -EINVAL; |
| 11081 | } |
| 11082 | } |
| 11083 | else |
| 11084 | { |
| 11085 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 11086 | "%s: Invalid device_mode = %s (%d)", |
| 11087 | __func__, hdd_device_modetoString(pAdapter->device_mode), |
| 11088 | pAdapter->device_mode); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 11089 | return -EINVAL; |
| 11090 | } |
| 11091 | |
| 11092 | return 0; |
| 11093 | } |
| 11094 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11095 | #ifdef WLAN_NL80211_TESTMODE |
| 11096 | #ifdef FEATURE_WLAN_LPHB |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11097 | void wlan_hdd_cfg80211_lphb_ind_handler |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11098 | ( |
| 11099 | void *pAdapter, |
| 11100 | void *indCont |
| 11101 | ) |
| 11102 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11103 | tSirLPHBInd *lphbInd; |
| 11104 | struct sk_buff *skb; |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 11105 | hdd_context_t *pHddCtxt; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11106 | |
| 11107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11108 | "LPHB indication arrived"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11109 | |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 11110 | if (pAdapter == NULL) |
| 11111 | { |
| 11112 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11113 | "%s: pAdapter is NULL\n",__func__); |
| 11114 | return; |
| 11115 | } |
| 11116 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11117 | if (NULL == indCont) |
| 11118 | { |
| 11119 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11120 | "LPHB IND, invalid argument"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11121 | return; |
| 11122 | } |
| 11123 | |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 11124 | pHddCtxt = (hdd_context_t *)pAdapter; |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11125 | lphbInd = (tSirLPHBInd *)indCont; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11126 | skb = cfg80211_testmode_alloc_event_skb( |
c_hpothu | 73f35e6 | 2014-04-18 13:40:08 +0530 | [diff] [blame] | 11127 | pHddCtxt->wiphy, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11128 | sizeof(tSirLPHBInd), |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11129 | GFP_ATOMIC); |
| 11130 | if (!skb) |
| 11131 | { |
| 11132 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11133 | "LPHB timeout, NL buffer alloc fail"); |
| 11134 | return; |
| 11135 | } |
| 11136 | |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 11137 | 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] | 11138 | { |
| 11139 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11140 | "WLAN_HDD_TM_ATTR_CMD put fail"); |
| 11141 | goto nla_put_failure; |
| 11142 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 11143 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11144 | { |
| 11145 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11146 | "WLAN_HDD_TM_ATTR_TYPE put fail"); |
| 11147 | goto nla_put_failure; |
| 11148 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 11149 | if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11150 | sizeof(tSirLPHBInd), lphbInd)) |
| 11151 | { |
| 11152 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11153 | "WLAN_HDD_TM_ATTR_DATA put fail"); |
| 11154 | goto nla_put_failure; |
| 11155 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11156 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 11157 | return; |
| 11158 | |
| 11159 | nla_put_failure: |
| 11160 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11161 | "NLA Put fail"); |
| 11162 | kfree_skb(skb); |
| 11163 | |
| 11164 | return; |
| 11165 | } |
| 11166 | #endif /* FEATURE_WLAN_LPHB */ |
| 11167 | |
| 11168 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 11169 | { |
| 11170 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 11171 | int err = 0; |
| 11172 | #ifdef FEATURE_WLAN_LPHB |
| 11173 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11174 | eHalStatus smeStatus; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11175 | #endif /* FEATURE_WLAN_LPHB */ |
| 11176 | |
| 11177 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 11178 | if (err) |
| 11179 | { |
| 11180 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11181 | "%s Testmode INV ATTR", __func__); |
| 11182 | return err; |
| 11183 | } |
| 11184 | |
| 11185 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 11186 | { |
| 11187 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11188 | "%s Testmode INV CMD", __func__); |
| 11189 | return -EINVAL; |
| 11190 | } |
| 11191 | |
| 11192 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 11193 | { |
| 11194 | #ifdef FEATURE_WLAN_LPHB |
| 11195 | /* Low Power Heartbeat configuration request */ |
| 11196 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 11197 | { |
| 11198 | int buf_len; |
| 11199 | void *buf; |
| 11200 | tSirLPHBReq *hb_params = NULL; |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 11201 | tSirLPHBReq *hb_params_temp = NULL; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11202 | |
| 11203 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 11204 | { |
| 11205 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11206 | "%s Testmode INV DATA", __func__); |
| 11207 | return -EINVAL; |
| 11208 | } |
| 11209 | |
| 11210 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 11211 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 11212 | |
| 11213 | hb_params_temp =(tSirLPHBReq *)buf; |
| 11214 | if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) && |
| 11215 | (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0)) |
| 11216 | return -EINVAL; |
| 11217 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11218 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 11219 | if (NULL == hb_params) |
| 11220 | { |
| 11221 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11222 | "%s Request Buffer Alloc Fail", __func__); |
| 11223 | return -EINVAL; |
| 11224 | } |
| 11225 | |
| 11226 | vos_mem_copy(hb_params, buf, buf_len); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11227 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 11228 | hb_params, |
| 11229 | wlan_hdd_cfg80211_lphb_ind_handler); |
| 11230 | if (eHAL_STATUS_SUCCESS != smeStatus) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11231 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 11232 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11233 | "LPHB Config Fail, disable"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11234 | vos_mem_free(hb_params); |
| 11235 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11236 | return 0; |
| 11237 | } |
| 11238 | #endif /* FEATURE_WLAN_LPHB */ |
| 11239 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11240 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11241 | "%s: unsupported event",__func__); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11242 | return -EOPNOTSUPP; |
| 11243 | } |
| 11244 | |
| 11245 | return err; |
| 11246 | } |
| 11247 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 11248 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11249 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 11250 | struct net_device *dev, |
| 11251 | int idx, struct survey_info *survey) |
| 11252 | { |
| 11253 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 11254 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 11255 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11256 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 11257 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11258 | v_S7_t snr,rssi; |
| 11259 | int status, i, j, filled = 0; |
| 11260 | |
| 11261 | ENTER(); |
| 11262 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11263 | if (NULL == pAdapter) |
| 11264 | { |
| 11265 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11266 | "%s: HDD adapter is Null", __func__); |
| 11267 | return -ENODEV; |
| 11268 | } |
| 11269 | |
| 11270 | if (NULL == wiphy) |
| 11271 | { |
| 11272 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11273 | "%s: wiphy is Null", __func__); |
| 11274 | return -ENODEV; |
| 11275 | } |
| 11276 | |
| 11277 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11278 | status = wlan_hdd_validate_context(pHddCtx); |
| 11279 | |
| 11280 | if (0 != status) |
| 11281 | { |
| 11282 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11283 | "%s: HDD context is not valid", __func__); |
| 11284 | return status; |
| 11285 | } |
| 11286 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 11287 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11288 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11289 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 11290 | 0 != pAdapter->survey_idx || |
| 11291 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11292 | { |
| 11293 | /* The survey dump ops when implemented completely is expected to |
| 11294 | * return a survey of all channels and the ops is called by the |
| 11295 | * kernel with incremental values of the argument 'idx' till it |
| 11296 | * returns -ENONET. But we can only support the survey for the |
| 11297 | * operating channel for now. survey_idx is used to track |
| 11298 | * that the ops is called only once and then return -ENONET for |
| 11299 | * the next iteration |
| 11300 | */ |
| 11301 | pAdapter->survey_idx = 0; |
| 11302 | return -ENONET; |
| 11303 | } |
| 11304 | |
| 11305 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 11306 | |
| 11307 | wlan_hdd_get_snr(pAdapter, &snr); |
| 11308 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 11309 | |
| 11310 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 11311 | hdd_wlan_get_freq(channel, &freq); |
| 11312 | |
| 11313 | |
| 11314 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 11315 | { |
| 11316 | if (NULL == wiphy->bands[i]) |
| 11317 | { |
| 11318 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 11319 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 11320 | continue; |
| 11321 | } |
| 11322 | |
| 11323 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 11324 | { |
| 11325 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 11326 | |
| 11327 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 11328 | { |
| 11329 | survey->channel = &band->channels[j]; |
| 11330 | /* The Rx BDs contain SNR values in dB for the received frames |
| 11331 | * while the supplicant expects noise. So we calculate and |
| 11332 | * return the value of noise (dBm) |
| 11333 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 11334 | */ |
| 11335 | survey->noise = rssi - snr; |
| 11336 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 11337 | filled = 1; |
| 11338 | } |
| 11339 | } |
| 11340 | } |
| 11341 | |
| 11342 | if (filled) |
| 11343 | pAdapter->survey_idx = 1; |
| 11344 | else |
| 11345 | { |
| 11346 | pAdapter->survey_idx = 0; |
| 11347 | return -ENONET; |
| 11348 | } |
| 11349 | |
| 11350 | return 0; |
| 11351 | } |
| 11352 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11353 | /* |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 11354 | * FUNCTION: __wlan_hdd_cfg80211_resume_wlan |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11355 | * this is called when cfg80211 driver resume |
| 11356 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 11357 | */ |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 11358 | int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11359 | { |
| 11360 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 11361 | hdd_adapter_t *pAdapter; |
| 11362 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 11363 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 11364 | |
| 11365 | ENTER(); |
| 11366 | |
| 11367 | if ( NULL == pHddCtx ) |
| 11368 | { |
| 11369 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11370 | "%s: HddCtx validation failed", __func__); |
| 11371 | return 0; |
| 11372 | } |
| 11373 | |
| 11374 | if (pHddCtx->isLogpInProgress) |
| 11375 | { |
| 11376 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11377 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 11378 | return 0; |
| 11379 | } |
| 11380 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 11381 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11382 | { |
| 11383 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11384 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 11385 | return 0; |
| 11386 | } |
| 11387 | |
| 11388 | spin_lock(&pHddCtx->schedScan_lock); |
| 11389 | pHddCtx->isWiphySuspended = FALSE; |
| 11390 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 11391 | { |
| 11392 | spin_unlock(&pHddCtx->schedScan_lock); |
| 11393 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11394 | "%s: Return resume is not due to PNO indication", __func__); |
| 11395 | return 0; |
| 11396 | } |
| 11397 | // Reset flag to avoid updatating cfg80211 data old results again |
| 11398 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 11399 | spin_unlock(&pHddCtx->schedScan_lock); |
| 11400 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 11401 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11402 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11403 | |
| 11404 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11405 | { |
| 11406 | pAdapter = pAdapterNode->pAdapter; |
| 11407 | if ( (NULL != pAdapter) && |
| 11408 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 11409 | { |
| 11410 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 11411 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11412 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 11413 | "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 11414 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11415 | else |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 11416 | { |
| 11417 | /* Acquire wakelock to handle the case where APP's tries to |
| 11418 | * suspend immediately after updating the scan results. Whis |
| 11419 | * results in app's is in suspended state and not able to |
| 11420 | * process the connect request to AP |
| 11421 | */ |
| 11422 | hdd_prevent_suspend_timeout(2000); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11423 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 11424 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11425 | |
| 11426 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11427 | "%s : cfg80211 scan result database updated", __func__); |
| 11428 | |
| 11429 | return 0; |
| 11430 | |
| 11431 | } |
| 11432 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11433 | pAdapterNode = pNext; |
| 11434 | } |
| 11435 | |
| 11436 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11437 | "%s: Failed to find Adapter", __func__); |
| 11438 | return 0; |
| 11439 | } |
| 11440 | |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 11441 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 11442 | { |
| 11443 | int ret; |
| 11444 | |
| 11445 | vos_ssr_protect(__func__); |
| 11446 | ret = __wlan_hdd_cfg80211_resume_wlan(wiphy); |
| 11447 | vos_ssr_unprotect(__func__); |
| 11448 | |
| 11449 | return ret; |
| 11450 | } |
| 11451 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11452 | /* |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 11453 | * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11454 | * this is called when cfg80211 driver suspends |
| 11455 | */ |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 11456 | int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11457 | struct cfg80211_wowlan *wow) |
| 11458 | { |
| 11459 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 11460 | |
| 11461 | ENTER(); |
| 11462 | if (NULL == pHddCtx) |
| 11463 | { |
| 11464 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11465 | "%s: HddCtx validation failed", __func__); |
| 11466 | return 0; |
| 11467 | } |
| 11468 | |
| 11469 | pHddCtx->isWiphySuspended = TRUE; |
| 11470 | |
| 11471 | EXIT(); |
| 11472 | |
| 11473 | return 0; |
| 11474 | } |
| 11475 | |
Mahesh A Saptasagar | bcc5b66 | 2014-06-02 21:46:23 +0530 | [diff] [blame] | 11476 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 11477 | struct cfg80211_wowlan *wow) |
| 11478 | { |
| 11479 | int ret; |
| 11480 | |
| 11481 | vos_ssr_protect(__func__); |
| 11482 | ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow); |
| 11483 | vos_ssr_unprotect(__func__); |
| 11484 | |
| 11485 | return ret; |
| 11486 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11487 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 11488 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11489 | { |
| 11490 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 11491 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 11492 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 11493 | .change_station = wlan_hdd_change_station, |
| 11494 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 11495 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 11496 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 11497 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11498 | #else |
| 11499 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 11500 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 11501 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11502 | #endif |
| 11503 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 11504 | .add_key = wlan_hdd_cfg80211_add_key, |
| 11505 | .get_key = wlan_hdd_cfg80211_get_key, |
| 11506 | .del_key = wlan_hdd_cfg80211_del_key, |
| 11507 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 11508 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11509 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 11510 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11511 | .scan = wlan_hdd_cfg80211_scan, |
| 11512 | .connect = wlan_hdd_cfg80211_connect, |
| 11513 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 11514 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 11515 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 11516 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 11517 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 11518 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11519 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 11520 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 11521 | .mgmt_tx = wlan_hdd_mgmt_tx, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11522 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11523 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 11524 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 11525 | .set_txq_params = wlan_hdd_set_txq_params, |
| 11526 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11527 | .get_station = wlan_hdd_cfg80211_get_station, |
| 11528 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 11529 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 11530 | .add_station = wlan_hdd_cfg80211_add_station, |
| 11531 | #ifdef FEATURE_WLAN_LFR |
| 11532 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 11533 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 11534 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 11535 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 11536 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 11537 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 11538 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 11539 | #ifdef FEATURE_WLAN_TDLS |
| 11540 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 11541 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 11542 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 11543 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 11544 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 11545 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 11546 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 11547 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 11548 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 11549 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11550 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 11551 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 11552 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 11553 | #ifdef WLAN_NL80211_TESTMODE |
| 11554 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 11555 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11556 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11557 | }; |
| 11558 | |