Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 21 | |
| 22 | /**======================================================================== |
| 23 | |
| 24 | \file wlan_hdd_cfg80211.c |
| 25 | |
| 26 | \brief WLAN Host Device Driver implementation |
| 27 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 28 | Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 30 | Qualcomm Technologies Confidential and Proprietary. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | |
| 32 | ========================================================================*/ |
| 33 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 34 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 36 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | |
| 38 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 39 | This section contains comments describing changes made to the module. |
| 40 | Notice that changes are listed in reverse chronological order. |
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 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | |
| 45 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 46 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 48 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 49 | |
| 50 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 51 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | ==========================================================================*/ |
| 53 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | |
| 55 | #include <linux/version.h> |
| 56 | #include <linux/module.h> |
| 57 | #include <linux/kernel.h> |
| 58 | #include <linux/init.h> |
| 59 | #include <linux/wireless.h> |
| 60 | #include <wlan_hdd_includes.h> |
| 61 | #include <net/arp.h> |
| 62 | #include <net/cfg80211.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <wlan_hdd_wowl.h> |
| 65 | #include <aniGlobal.h> |
| 66 | #include "ccmApi.h" |
| 67 | #include "sirParams.h" |
| 68 | #include "dot11f.h" |
| 69 | #include "wlan_hdd_assoc.h" |
| 70 | #include "wlan_hdd_wext.h" |
| 71 | #include "sme_Api.h" |
| 72 | #include "wlan_hdd_p2p.h" |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_hostapd.h" |
| 75 | #include "sapInternal.h" |
| 76 | #include "wlan_hdd_softap_tx_rx.h" |
| 77 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 78 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 79 | #include "wlan_hdd_power.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 80 | #ifdef WLAN_BTAMP_FEATURE |
| 81 | #include "bap_hdd_misc.h" |
| 82 | #endif |
| 83 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 84 | #ifdef FEATURE_WLAN_TDLS |
| 85 | #include "wlan_hdd_tdls.h" |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 86 | #include "wlan_hdd_wmm.h" |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 87 | #include "wlan_qct_wda.h" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 88 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 89 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 90 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 91 | |
| 92 | #define g_mode_rates_size (12) |
| 93 | #define a_mode_rates_size (8) |
| 94 | #define FREQ_BASE_80211G (2407) |
| 95 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 96 | #define MAX_SCAN_SSID 9 |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 97 | #define MAX_PENDING_LOG 5 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 98 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 99 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 100 | |
| 101 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 102 | .band = IEEE80211_BAND_2GHZ, \ |
| 103 | .center_freq = (freq), \ |
| 104 | .hw_value = (chan),\ |
| 105 | .flags = (flag), \ |
| 106 | .max_antenna_gain = 0 ,\ |
| 107 | .max_power = 30, \ |
| 108 | } |
| 109 | |
| 110 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 111 | .band = IEEE80211_BAND_5GHZ, \ |
| 112 | .center_freq = (freq), \ |
| 113 | .hw_value = (chan),\ |
| 114 | .flags = (flag), \ |
| 115 | .max_antenna_gain = 0 ,\ |
| 116 | .max_power = 30, \ |
| 117 | } |
| 118 | |
| 119 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 120 | {\ |
| 121 | .bitrate = rate, \ |
| 122 | .hw_value = rate_id, \ |
| 123 | .flags = flag, \ |
| 124 | } |
| 125 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 126 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 127 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 128 | #else |
| 129 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 130 | #endif |
| 131 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 132 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 133 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 134 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 135 | #endif |
| 136 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 137 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 138 | { |
| 139 | WLAN_CIPHER_SUITE_WEP40, |
| 140 | WLAN_CIPHER_SUITE_WEP104, |
| 141 | WLAN_CIPHER_SUITE_TKIP, |
| 142 | #ifdef FEATURE_WLAN_CCX |
| 143 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 144 | WLAN_CIPHER_SUITE_KRK, |
| 145 | WLAN_CIPHER_SUITE_CCMP, |
| 146 | #else |
| 147 | WLAN_CIPHER_SUITE_CCMP, |
| 148 | #endif |
| 149 | #ifdef FEATURE_WLAN_WAPI |
| 150 | WLAN_CIPHER_SUITE_SMS4, |
| 151 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 152 | #ifdef WLAN_FEATURE_11W |
| 153 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 154 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 155 | }; |
| 156 | |
| 157 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 158 | { |
| 159 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 160 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 161 | } |
| 162 | |
| 163 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 164 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 165 | HDD2GHZCHAN(2412, 1, 0) , |
| 166 | HDD2GHZCHAN(2417, 2, 0) , |
| 167 | HDD2GHZCHAN(2422, 3, 0) , |
| 168 | HDD2GHZCHAN(2427, 4, 0) , |
| 169 | HDD2GHZCHAN(2432, 5, 0) , |
| 170 | HDD2GHZCHAN(2437, 6, 0) , |
| 171 | HDD2GHZCHAN(2442, 7, 0) , |
| 172 | HDD2GHZCHAN(2447, 8, 0) , |
| 173 | HDD2GHZCHAN(2452, 9, 0) , |
| 174 | HDD2GHZCHAN(2457, 10, 0) , |
| 175 | HDD2GHZCHAN(2462, 11, 0) , |
| 176 | HDD2GHZCHAN(2467, 12, 0) , |
| 177 | HDD2GHZCHAN(2472, 13, 0) , |
| 178 | HDD2GHZCHAN(2484, 14, 0) , |
| 179 | }; |
| 180 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 181 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 182 | { |
| 183 | HDD2GHZCHAN(2412, 1, 0) , |
| 184 | HDD2GHZCHAN(2437, 6, 0) , |
| 185 | HDD2GHZCHAN(2462, 11, 0) , |
| 186 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 187 | |
| 188 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 189 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 190 | HDD5GHZCHAN(4920, 240, 0) , |
| 191 | HDD5GHZCHAN(4940, 244, 0) , |
| 192 | HDD5GHZCHAN(4960, 248, 0) , |
| 193 | HDD5GHZCHAN(4980, 252, 0) , |
| 194 | HDD5GHZCHAN(5040, 208, 0) , |
| 195 | HDD5GHZCHAN(5060, 212, 0) , |
| 196 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 197 | HDD5GHZCHAN(5180, 36, 0) , |
| 198 | HDD5GHZCHAN(5200, 40, 0) , |
| 199 | HDD5GHZCHAN(5220, 44, 0) , |
| 200 | HDD5GHZCHAN(5240, 48, 0) , |
| 201 | HDD5GHZCHAN(5260, 52, 0) , |
| 202 | HDD5GHZCHAN(5280, 56, 0) , |
| 203 | HDD5GHZCHAN(5300, 60, 0) , |
| 204 | HDD5GHZCHAN(5320, 64, 0) , |
| 205 | HDD5GHZCHAN(5500,100, 0) , |
| 206 | HDD5GHZCHAN(5520,104, 0) , |
| 207 | HDD5GHZCHAN(5540,108, 0) , |
| 208 | HDD5GHZCHAN(5560,112, 0) , |
| 209 | HDD5GHZCHAN(5580,116, 0) , |
| 210 | HDD5GHZCHAN(5600,120, 0) , |
| 211 | HDD5GHZCHAN(5620,124, 0) , |
| 212 | HDD5GHZCHAN(5640,128, 0) , |
| 213 | HDD5GHZCHAN(5660,132, 0) , |
| 214 | HDD5GHZCHAN(5680,136, 0) , |
| 215 | HDD5GHZCHAN(5700,140, 0) , |
Leo Chang | 80de3c2 | 2013-11-26 10:52:12 -0800 | [diff] [blame] | 216 | #ifdef FEATURE_WLAN_CH144 |
| 217 | HDD5GHZCHAN(5720,144, 0) , |
| 218 | #endif /* FEATURE_WLAN_CH144 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 219 | HDD5GHZCHAN(5745,149, 0) , |
| 220 | HDD5GHZCHAN(5765,153, 0) , |
| 221 | HDD5GHZCHAN(5785,157, 0) , |
| 222 | HDD5GHZCHAN(5805,161, 0) , |
| 223 | HDD5GHZCHAN(5825,165, 0) , |
| 224 | }; |
| 225 | |
| 226 | static struct ieee80211_rate g_mode_rates[] = |
| 227 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 228 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 229 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 230 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 231 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 232 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 233 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 234 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 235 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 236 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 237 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 238 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 240 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 241 | |
| 242 | static struct ieee80211_rate a_mode_rates[] = |
| 243 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 244 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 245 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 246 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 247 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 248 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 249 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 250 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 251 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 252 | }; |
| 253 | |
| 254 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 255 | { |
| 256 | .channels = hdd_channels_2_4_GHZ, |
| 257 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 258 | .band = IEEE80211_BAND_2GHZ, |
| 259 | .bitrates = g_mode_rates, |
| 260 | .n_bitrates = g_mode_rates_size, |
| 261 | .ht_cap.ht_supported = 1, |
| 262 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 263 | | IEEE80211_HT_CAP_GRN_FLD |
| 264 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 265 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 266 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 267 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 268 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 269 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 270 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 271 | }; |
| 272 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 273 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 274 | { |
| 275 | .channels = hdd_social_channels_2_4_GHZ, |
| 276 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 277 | .band = IEEE80211_BAND_2GHZ, |
| 278 | .bitrates = g_mode_rates, |
| 279 | .n_bitrates = g_mode_rates_size, |
| 280 | .ht_cap.ht_supported = 1, |
| 281 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 282 | | IEEE80211_HT_CAP_GRN_FLD |
| 283 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 284 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 285 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 286 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 287 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 288 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 289 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 290 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 291 | |
| 292 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 293 | { |
| 294 | .channels = hdd_channels_5_GHZ, |
| 295 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 296 | .band = IEEE80211_BAND_5GHZ, |
| 297 | .bitrates = a_mode_rates, |
| 298 | .n_bitrates = a_mode_rates_size, |
| 299 | .ht_cap.ht_supported = 1, |
| 300 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 301 | | IEEE80211_HT_CAP_GRN_FLD |
| 302 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 303 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 304 | | IEEE80211_HT_CAP_SGI_40 |
| 305 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 306 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 307 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 308 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 309 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 310 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 311 | }; |
| 312 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 313 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 314 | TX/RX direction for each kind of interface */ |
| 315 | static const struct ieee80211_txrx_stypes |
| 316 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 317 | [NL80211_IFTYPE_STATION] = { |
| 318 | .tx = 0xffff, |
| 319 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 320 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 321 | }, |
| 322 | [NL80211_IFTYPE_AP] = { |
| 323 | .tx = 0xffff, |
| 324 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 325 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 326 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 327 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 328 | BIT(SIR_MAC_MGMT_AUTH) | |
| 329 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 330 | BIT(SIR_MAC_MGMT_ACTION), |
| 331 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 332 | [NL80211_IFTYPE_ADHOC] = { |
| 333 | .tx = 0xffff, |
| 334 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 335 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 336 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 337 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 338 | BIT(SIR_MAC_MGMT_AUTH) | |
| 339 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 340 | BIT(SIR_MAC_MGMT_ACTION), |
| 341 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 342 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 343 | .tx = 0xffff, |
| 344 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 345 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 346 | }, |
| 347 | [NL80211_IFTYPE_P2P_GO] = { |
| 348 | /* This is also same as for SoftAP */ |
| 349 | .tx = 0xffff, |
| 350 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 351 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 352 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 353 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 354 | BIT(SIR_MAC_MGMT_AUTH) | |
| 355 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 356 | BIT(SIR_MAC_MGMT_ACTION), |
| 357 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 358 | }; |
| 359 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 360 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 361 | static const struct ieee80211_iface_limit |
| 362 | wlan_hdd_iface_limit[] = { |
| 363 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 364 | /* max = 3 ; Our driver create two interfaces during driver init |
| 365 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 366 | * interface until a group is formed. In JB architecture, once the |
| 367 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 368 | * Client. |
| 369 | * When supplicant remove the group, it first issue a set interface |
| 370 | * cmd to change the mode back to Station. In JB this works fine as |
| 371 | * we advertize two station type interface during driver init. |
| 372 | * Some vendors create separate interface for P2P GO/Client, |
| 373 | * after group formation(Third one). But while group remove |
| 374 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 375 | * But as we advertized only two sta type interfaces nl80211 was |
| 376 | * returning error for the third one which was leading to failure in |
| 377 | * delete interface. Ideally while removing the group, supplicant |
| 378 | * should not try to change the 3rd interface mode to Station type. |
| 379 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 380 | * interface type to 3 |
| 381 | */ |
| 382 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 383 | .types = BIT(NL80211_IFTYPE_STATION), |
| 384 | }, |
| 385 | { |
| 386 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 387 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 388 | }, |
| 389 | { |
| 390 | .max = 1, |
| 391 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 392 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 393 | }, |
| 394 | }; |
| 395 | |
| 396 | /* By default, only single channel concurrency is allowed */ |
| 397 | static struct ieee80211_iface_combination |
| 398 | wlan_hdd_iface_combination = { |
| 399 | .limits = wlan_hdd_iface_limit, |
| 400 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 401 | /* |
| 402 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 403 | * and p2p0 interfaces during driver init |
| 404 | * Some vendors create separate interface for P2P operations. |
| 405 | * wlan0: STA interface |
| 406 | * p2p0: P2P Device interface, action frames goes |
| 407 | * through this interface. |
| 408 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 409 | * created for p2p operations(GO/CLIENT interface). |
| 410 | */ |
| 411 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 412 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 413 | .beacon_int_infra_match = false, |
| 414 | }; |
| 415 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 416 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 417 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 418 | |
| 419 | /* Data rate 100KBPS based on IE Index */ |
| 420 | struct index_data_rate_type |
| 421 | { |
| 422 | v_U8_t beacon_rate_index; |
| 423 | v_U16_t supported_rate[4]; |
| 424 | }; |
| 425 | |
| 426 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 427 | The IDX field is the rate index |
| 428 | The HI field is the rate when RSSI is strong or being ignored |
| 429 | (in this case we report actual rate) |
| 430 | The MID field is the rate when RSSI is moderate |
| 431 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 432 | The LO field is the rate when RSSI is low |
| 433 | (in this case we don't report rates, actual current rate used) |
| 434 | */ |
| 435 | static const struct |
| 436 | { |
| 437 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 438 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 439 | } supported_data_rate[] = |
| 440 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 441 | /* IDX HI HM LM LO (RSSI-based index */ |
| 442 | {2, { 10, 10, 10, 0}}, |
| 443 | {4, { 20, 20, 10, 0}}, |
| 444 | {11, { 55, 20, 10, 0}}, |
| 445 | {12, { 60, 55, 20, 0}}, |
| 446 | {18, { 90, 55, 20, 0}}, |
| 447 | {22, {110, 55, 20, 0}}, |
| 448 | {24, {120, 90, 60, 0}}, |
| 449 | {36, {180, 120, 60, 0}}, |
| 450 | {44, {220, 180, 60, 0}}, |
| 451 | {48, {240, 180, 90, 0}}, |
| 452 | {66, {330, 180, 90, 0}}, |
| 453 | {72, {360, 240, 90, 0}}, |
| 454 | {96, {480, 240, 120, 0}}, |
| 455 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 456 | }; |
| 457 | |
| 458 | /* MCS Based rate table */ |
| 459 | static struct index_data_rate_type supported_mcs_rate[] = |
| 460 | { |
| 461 | /* MCS L20 L40 S20 S40 */ |
| 462 | {0, {65, 135, 72, 150}}, |
| 463 | {1, {130, 270, 144, 300}}, |
| 464 | {2, {195, 405, 217, 450}}, |
| 465 | {3, {260, 540, 289, 600}}, |
| 466 | {4, {390, 810, 433, 900}}, |
| 467 | {5, {520, 1080, 578, 1200}}, |
| 468 | {6, {585, 1215, 650, 1350}}, |
| 469 | {7, {650, 1350, 722, 1500}} |
| 470 | }; |
| 471 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 472 | #ifdef WLAN_FEATURE_11AC |
| 473 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 474 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 475 | |
| 476 | struct index_vht_data_rate_type |
| 477 | { |
| 478 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 479 | v_U16_t supported_VHT80_rate[2]; |
| 480 | v_U16_t supported_VHT40_rate[2]; |
| 481 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 482 | }; |
| 483 | |
| 484 | typedef enum |
| 485 | { |
| 486 | DATA_RATE_11AC_MAX_MCS_7, |
| 487 | DATA_RATE_11AC_MAX_MCS_8, |
| 488 | DATA_RATE_11AC_MAX_MCS_9, |
| 489 | DATA_RATE_11AC_MAX_MCS_NA |
| 490 | } eDataRate11ACMaxMcs; |
| 491 | |
| 492 | /* MCS Based VHT rate table */ |
| 493 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 494 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 495 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 496 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 497 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 498 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 499 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 500 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 501 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 502 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 503 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 504 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 505 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 506 | }; |
| 507 | #endif /* WLAN_FEATURE_11AC */ |
| 508 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 509 | extern struct net_device_ops net_ops_struct; |
| 510 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 511 | #ifdef WLAN_NL80211_TESTMODE |
| 512 | enum wlan_hdd_tm_attr |
| 513 | { |
| 514 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 515 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 516 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 517 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 518 | /* keep last */ |
| 519 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 520 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 521 | }; |
| 522 | |
| 523 | enum wlan_hdd_tm_cmd |
| 524 | { |
| 525 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 526 | }; |
| 527 | |
| 528 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 529 | |
| 530 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 531 | { |
| 532 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 533 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 534 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 535 | }; |
| 536 | #endif /* WLAN_NL80211_TESTMODE */ |
| 537 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 538 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 539 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 540 | * This function is called by hdd_wlan_startup() |
| 541 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 542 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 543 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 544 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 545 | { |
| 546 | struct wiphy *wiphy; |
| 547 | ENTER(); |
| 548 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 549 | /* |
| 550 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 551 | */ |
| 552 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 553 | |
| 554 | if (!wiphy) |
| 555 | { |
| 556 | /* Print error and jump into err label and free the memory */ |
| 557 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 558 | return NULL; |
| 559 | } |
| 560 | |
| 561 | return wiphy; |
| 562 | } |
| 563 | |
| 564 | /* |
| 565 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 566 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 567 | * private ioctl to change the band value |
| 568 | */ |
| 569 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 570 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 571 | int i, j; |
| 572 | eNVChannelEnabledType channelEnabledState; |
| 573 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 574 | ENTER(); |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 575 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 576 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 577 | |
| 578 | if (NULL == wiphy->bands[i]) |
| 579 | { |
| 580 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 581 | __func__, i); |
| 582 | continue; |
| 583 | } |
| 584 | |
| 585 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 586 | { |
| 587 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 588 | |
| 589 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 590 | band->channels[j].hw_value); |
| 591 | |
| 592 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 593 | { |
| 594 | // Enable Social channels for P2P |
| 595 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 596 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 597 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 598 | else |
| 599 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 600 | continue; |
| 601 | } |
| 602 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 603 | { |
| 604 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 605 | continue; |
| 606 | } |
| 607 | |
| 608 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 609 | NV_CHANNEL_INVALID == channelEnabledState) |
| 610 | { |
| 611 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 612 | } |
| 613 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 614 | { |
| 615 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 616 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 621 | |IEEE80211_CHAN_RADAR); |
| 622 | } |
| 623 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 624 | } |
| 625 | return 0; |
| 626 | } |
| 627 | /* |
| 628 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 629 | * This function is called by hdd_wlan_startup() |
| 630 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 631 | * This function is used to initialize and register wiphy structure. |
| 632 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 633 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 634 | struct wiphy *wiphy, |
| 635 | hdd_config_t *pCfg |
| 636 | ) |
| 637 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 638 | int i, j; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 639 | ENTER(); |
| 640 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 641 | /* Now bind the underlying wlan device with wiphy */ |
| 642 | set_wiphy_dev(wiphy, dev); |
| 643 | |
| 644 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 645 | |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 646 | #ifndef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 647 | /* the flag for the other case would be initialzed in |
| 648 | vos_init_wiphy_from_nv_bin */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 649 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 650 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 651 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 652 | /* This will disable updating of NL channels from passive to |
| 653 | * active if a beacon is received on passive channel. */ |
| 654 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Amar Singhal | f007319 | 2013-09-20 12:34:56 -0700 | [diff] [blame] | 655 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 656 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 657 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 658 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 659 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 660 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 661 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 662 | | WIPHY_FLAG_OFFCHAN_TX; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 663 | wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 664 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 665 | |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 666 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 667 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 668 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 669 | || pCfg->isFastRoamIniFeatureEnabled |
| 670 | #endif |
| 671 | #ifdef FEATURE_WLAN_CCX |
| 672 | || pCfg->isCcxIniFeatureEnabled |
| 673 | #endif |
| 674 | ) |
| 675 | { |
| 676 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 677 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 678 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 679 | #ifdef FEATURE_WLAN_TDLS |
| 680 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 681 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 682 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 683 | #ifdef FEATURE_WLAN_SCAN_PNO |
Hardik Kantilal Patel | 3dfd879 | 2013-11-13 20:34:57 +0530 | [diff] [blame] | 684 | if (pCfg->configPNOScanSupport) |
| 685 | { |
| 686 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 687 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
| 688 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 689 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
| 690 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 691 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 692 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 693 | #ifdef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 694 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 695 | driver can still register regulatory callback and |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 696 | it will get regulatory settings in wiphy->band[], but |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 697 | driver need to determine what to do with both |
| 698 | regulatory settings */ |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 699 | |
| 700 | wiphy->reg_notifier = wlan_hdd_linux_reg_notifier; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 701 | #else |
| 702 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 703 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 704 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 705 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 706 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 707 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 708 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 709 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 711 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 712 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 714 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 715 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 716 | | BIT(NL80211_IFTYPE_AP); |
| 717 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 718 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 719 | if( pCfg->enableMCC ) |
| 720 | { |
| 721 | /* Currently, supports up to two channels */ |
| 722 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 723 | |
| 724 | if( !pCfg->allowMCCGODiffBI ) |
| 725 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 726 | |
| 727 | } |
| 728 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 729 | wiphy->n_iface_combinations = 1; |
| 730 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 731 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 732 | /* Before registering we need to update the ht capabilitied based |
| 733 | * on ini values*/ |
| 734 | if( !pCfg->ShortGI20MhzEnable ) |
| 735 | { |
| 736 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 737 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 738 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 739 | } |
| 740 | |
| 741 | if( !pCfg->ShortGI40MhzEnable ) |
| 742 | { |
| 743 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 744 | } |
| 745 | |
| 746 | if( !pCfg->nChannelBondingMode5GHz ) |
| 747 | { |
| 748 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 749 | } |
| 750 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 751 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 752 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 753 | |
| 754 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 755 | { |
| 756 | |
| 757 | if (NULL == wiphy->bands[i]) |
| 758 | { |
| 759 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 760 | __func__, i); |
| 761 | continue; |
| 762 | } |
| 763 | |
| 764 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 765 | { |
| 766 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 767 | |
| 768 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 769 | { |
| 770 | // Enable social channels for P2P |
| 771 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 772 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 773 | else |
| 774 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 775 | continue; |
| 776 | } |
| 777 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 778 | { |
| 779 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 780 | continue; |
| 781 | } |
| 782 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 783 | } |
| 784 | /*Initialise the supported cipher suite details*/ |
| 785 | wiphy->cipher_suites = hdd_cipher_suites; |
| 786 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 787 | |
| 788 | /*signal strength in mBm (100*dBm) */ |
| 789 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 790 | |
| 791 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 792 | wiphy->max_remain_on_channel_duration = 1000; |
| 793 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 794 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 795 | EXIT(); |
| 796 | return 0; |
| 797 | } |
| 798 | |
| 799 | /* In this function we are registering wiphy. */ |
| 800 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 801 | { |
| 802 | ENTER(); |
| 803 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 804 | if (0 > wiphy_register(wiphy)) |
| 805 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 806 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 807 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 808 | return -EIO; |
| 809 | } |
| 810 | |
| 811 | EXIT(); |
| 812 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 813 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 814 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 815 | /* In this function we are updating channel list when, |
| 816 | regulatory domain is FCC and country code is US. |
| 817 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 818 | As per FCC smart phone is not a indoor device. |
| 819 | GO should not opeate on indoor channels */ |
| 820 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 821 | { |
| 822 | int j; |
| 823 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 824 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 825 | //Default counrtycode from NV at the time of wiphy initialization. |
| 826 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 827 | &defaultCountryCode[0])) |
| 828 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 829 | hddLog(LOGE, FL("Failed to get default country code from NV")); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 830 | } |
| 831 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 832 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 833 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 834 | { |
| 835 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 836 | return; |
| 837 | } |
| 838 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 839 | { |
| 840 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 841 | // Mark UNII -1 band channel as passive |
| 842 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 843 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 848 | /* In this function we will do all post VOS start initialization. |
| 849 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 850 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 851 | */ |
| 852 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 853 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 854 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 855 | /* Register for all P2P action, public action etc frames */ |
| 856 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 857 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 858 | ENTER(); |
| 859 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 860 | /* Right now we are registering these frame when driver is getting |
| 861 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 862 | frame register ops, we will move this code as a part of that */ |
| 863 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 864 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 865 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 866 | |
| 867 | /* GAS Initial Response */ |
| 868 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 869 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 870 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 871 | /* GAS Comeback Request */ |
| 872 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 873 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 874 | |
| 875 | /* GAS Comeback Response */ |
| 876 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 877 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 878 | |
| 879 | /* P2P Public Action */ |
| 880 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 881 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 882 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 883 | |
| 884 | /* P2P Action */ |
| 885 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 886 | (v_U8_t*)P2P_ACTION_FRAME, |
| 887 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 888 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 889 | /* WNM BSS Transition Request frame */ |
| 890 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 891 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 892 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 893 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 894 | #ifdef WLAN_FEATURE_11W |
| 895 | /* SA Query Response Action Frame */ |
| 896 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 897 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 898 | SA_QUERY_FRAME_RSP_SIZE ); |
| 899 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 903 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 904 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 905 | /* Register for all P2P action, public action etc frames */ |
| 906 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 907 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 908 | ENTER(); |
| 909 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 910 | /* Right now we are registering these frame when driver is getting |
| 911 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 912 | frame register ops, we will move this code as a part of that */ |
| 913 | /* GAS Initial Request */ |
| 914 | |
| 915 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 916 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 917 | |
| 918 | /* GAS Initial Response */ |
| 919 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 920 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 921 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 922 | /* GAS Comeback Request */ |
| 923 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 924 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 925 | |
| 926 | /* GAS Comeback Response */ |
| 927 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 928 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 929 | |
| 930 | /* P2P Public Action */ |
| 931 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 932 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 933 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 934 | |
| 935 | /* P2P Action */ |
| 936 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 937 | (v_U8_t*)P2P_ACTION_FRAME, |
| 938 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 939 | |
| 940 | #ifdef WLAN_FEATURE_11W |
| 941 | /* SA Query Response Action Frame */ |
| 942 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 943 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 944 | SA_QUERY_FRAME_RSP_SIZE ); |
| 945 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | #ifdef FEATURE_WLAN_WAPI |
| 949 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 950 | const u8 *mac_addr, u8 *key , int key_Len) |
| 951 | { |
| 952 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 953 | tCsrRoamSetKey setKey; |
| 954 | v_BOOL_t isConnected = TRUE; |
| 955 | int status = 0; |
| 956 | v_U32_t roamId= 0xFF; |
| 957 | tANI_U8 *pKeyPtr = NULL; |
| 958 | int n = 0; |
| 959 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 960 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 961 | __func__,pAdapter->device_mode); |
| 962 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 963 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 964 | setKey.keyId = key_index; // Store Key ID |
| 965 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 966 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 967 | setKey.paeRole = 0 ; // the PAE role |
| 968 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 969 | { |
| 970 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 971 | } |
| 972 | else |
| 973 | { |
| 974 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 975 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 976 | } |
| 977 | setKey.keyLength = key_Len; |
| 978 | pKeyPtr = setKey.Key; |
| 979 | memcpy( pKeyPtr, key, key_Len); |
| 980 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 981 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 982 | __func__, key_Len); |
| 983 | for (n = 0 ; n < key_Len; n++) |
| 984 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 985 | __func__,n,setKey.Key[n]); |
| 986 | |
| 987 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 988 | if ( isConnected ) |
| 989 | { |
| 990 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 991 | pAdapter->sessionId, &setKey, &roamId ); |
| 992 | } |
| 993 | if ( status != 0 ) |
| 994 | { |
| 995 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 996 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 997 | __LINE__, status ); |
| 998 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 999 | } |
| 1000 | } |
| 1001 | #endif /* FEATURE_WLAN_WAPI*/ |
| 1002 | |
| 1003 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1004 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1005 | beacon_data_t **ppBeacon, |
| 1006 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1007 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1008 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1009 | beacon_data_t **ppBeacon, |
| 1010 | struct cfg80211_beacon_data *params, |
| 1011 | int dtim_period) |
| 1012 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1013 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1014 | int size; |
| 1015 | beacon_data_t *beacon = NULL; |
| 1016 | beacon_data_t *old = NULL; |
| 1017 | int head_len,tail_len; |
| 1018 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1019 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1020 | if (params->head && !params->head_len) |
| 1021 | return -EINVAL; |
| 1022 | |
| 1023 | old = pAdapter->sessionCtx.ap.beacon; |
| 1024 | |
| 1025 | if (!params->head && !old) |
| 1026 | return -EINVAL; |
| 1027 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1028 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 1029 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 1030 | if (!params->dtim_period) |
| 1031 | return -EINVAL; |
| 1032 | #endif |
| 1033 | |
| 1034 | if(params->head) |
| 1035 | head_len = params->head_len; |
| 1036 | else |
| 1037 | head_len = old->head_len; |
| 1038 | |
| 1039 | if(params->tail || !old) |
| 1040 | tail_len = params->tail_len; |
| 1041 | else |
| 1042 | tail_len = old->tail_len; |
| 1043 | |
| 1044 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 1045 | |
| 1046 | beacon = kzalloc(size, GFP_KERNEL); |
| 1047 | |
| 1048 | if( beacon == NULL ) |
| 1049 | return -ENOMEM; |
| 1050 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1051 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1052 | if(params->dtim_period || !old ) |
| 1053 | beacon->dtim_period = params->dtim_period; |
| 1054 | else |
| 1055 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1056 | #else |
| 1057 | if(dtim_period || !old ) |
| 1058 | beacon->dtim_period = dtim_period; |
| 1059 | else |
| 1060 | beacon->dtim_period = old->dtim_period; |
| 1061 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1062 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1063 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 1064 | beacon->tail = beacon->head + head_len; |
| 1065 | beacon->head_len = head_len; |
| 1066 | beacon->tail_len = tail_len; |
| 1067 | |
| 1068 | if(params->head) { |
| 1069 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1070 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1071 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1072 | if(old) |
| 1073 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1074 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1075 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1076 | if(params->tail) { |
| 1077 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1078 | } |
| 1079 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1080 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1082 | } |
| 1083 | |
| 1084 | *ppBeacon = beacon; |
| 1085 | |
| 1086 | kfree(old); |
| 1087 | |
| 1088 | return 0; |
| 1089 | |
| 1090 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1091 | |
| 1092 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1093 | { |
| 1094 | int left = length; |
| 1095 | v_U8_t *ptr = pIes; |
| 1096 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1097 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1098 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1099 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1100 | elem_id = ptr[0]; |
| 1101 | elem_len = ptr[1]; |
| 1102 | left -= 2; |
| 1103 | if(elem_len > left) |
| 1104 | { |
| 1105 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1106 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1107 | eid,elem_len,left); |
| 1108 | return NULL; |
| 1109 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1110 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1111 | { |
| 1112 | return ptr; |
| 1113 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1114 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1115 | left -= elem_len; |
| 1116 | ptr += (elem_len + 2); |
| 1117 | } |
| 1118 | return NULL; |
| 1119 | } |
| 1120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1121 | /* Check if rate is 11g rate or not */ |
| 1122 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1123 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 1124 | 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] | 1125 | u8 i; |
| 1126 | for (i = 0; i < 8; i++) |
| 1127 | { |
| 1128 | if(rate == gRateArray[i]) |
| 1129 | return TRUE; |
| 1130 | } |
| 1131 | return FALSE; |
| 1132 | } |
| 1133 | |
| 1134 | /* Check for 11g rate and set proper 11g only mode */ |
| 1135 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1136 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1137 | { |
| 1138 | u8 i, num_rates = pIe[0]; |
| 1139 | |
| 1140 | pIe += 1; |
| 1141 | for ( i = 0; i < num_rates; i++) |
| 1142 | { |
| 1143 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1144 | { |
| 1145 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1146 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1147 | if (pIe[i] & BASIC_RATE_MASK) |
| 1148 | { |
| 1149 | /* If we have 11g rate as basic rate, it means mode |
| 1150 | is 11g only mode. |
| 1151 | */ |
| 1152 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1153 | *pCheckRatesfor11g = FALSE; |
| 1154 | } |
| 1155 | } |
| 1156 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1157 | { |
| 1158 | *require_ht = TRUE; |
| 1159 | } |
| 1160 | } |
| 1161 | return; |
| 1162 | } |
| 1163 | |
| 1164 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1165 | { |
| 1166 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1167 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1168 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1169 | u8 checkRatesfor11g = TRUE; |
| 1170 | u8 require_ht = FALSE; |
| 1171 | u8 *pIe=NULL; |
| 1172 | |
| 1173 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1174 | |
| 1175 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1176 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1177 | if (pIe != NULL) |
| 1178 | { |
| 1179 | pIe += 1; |
| 1180 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1181 | &pConfig->SapHw_mode); |
| 1182 | } |
| 1183 | |
| 1184 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1185 | WLAN_EID_EXT_SUPP_RATES); |
| 1186 | if (pIe != NULL) |
| 1187 | { |
| 1188 | |
| 1189 | pIe += 1; |
| 1190 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1191 | &pConfig->SapHw_mode); |
| 1192 | } |
| 1193 | |
| 1194 | if( pConfig->channel > 14 ) |
| 1195 | { |
| 1196 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1197 | } |
| 1198 | |
| 1199 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1200 | WLAN_EID_HT_CAPABILITY); |
| 1201 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1202 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1203 | { |
| 1204 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1205 | if(require_ht) |
| 1206 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1207 | } |
| 1208 | } |
| 1209 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1210 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1211 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1212 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1213 | v_U16_t ielen = 0; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1214 | v_U8_t *pIe = NULL; |
| 1215 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1216 | |
| 1217 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1218 | pBeacon->tail, pBeacon->tail_len); |
| 1219 | |
| 1220 | if (pIe) |
| 1221 | { |
| 1222 | ielen = pIe[1] + 2; |
| 1223 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1224 | { |
| 1225 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1226 | } |
| 1227 | else |
| 1228 | { |
| 1229 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1230 | return -EINVAL; |
| 1231 | } |
| 1232 | *total_ielen += ielen; |
| 1233 | } |
| 1234 | return 0; |
| 1235 | } |
| 1236 | |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1237 | static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter, |
| 1238 | v_U8_t *genie, v_U8_t *total_ielen) |
| 1239 | { |
| 1240 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1241 | int left = pBeacon->tail_len; |
| 1242 | v_U8_t *ptr = pBeacon->tail; |
| 1243 | v_U8_t elem_id, elem_len; |
| 1244 | v_U16_t ielen = 0; |
| 1245 | |
| 1246 | if ( NULL == ptr || 0 == left ) |
| 1247 | return; |
| 1248 | |
| 1249 | while (left >= 2) |
| 1250 | { |
| 1251 | elem_id = ptr[0]; |
| 1252 | elem_len = ptr[1]; |
| 1253 | left -= 2; |
| 1254 | if (elem_len > left) |
| 1255 | { |
| 1256 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1257 | "****Invalid IEs eid = %d elem_len=%d left=%d*****", |
| 1258 | elem_id, elem_len, left); |
| 1259 | return; |
| 1260 | } |
| 1261 | if (IE_EID_VENDOR == elem_id) |
| 1262 | { |
| 1263 | /* skipping the VSIE's which we don't want to include or |
| 1264 | * it will be included by existing code |
| 1265 | */ |
| 1266 | if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) && |
| 1267 | #ifdef WLAN_FEATURE_WFD |
| 1268 | (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) && |
| 1269 | #endif |
| 1270 | (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1271 | (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1272 | (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) && |
| 1273 | (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1274 | (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0)) |
| 1275 | { |
| 1276 | ielen = ptr[1] + 2; |
| 1277 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1278 | { |
| 1279 | vos_mem_copy(&genie[*total_ielen], ptr, ielen); |
| 1280 | *total_ielen += ielen; |
| 1281 | } |
| 1282 | else |
| 1283 | { |
| 1284 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1285 | "IE Length is too big " |
| 1286 | "IEs eid=%d elem_len=%d total_ie_lent=%d", |
| 1287 | elem_id, elem_len, *total_ielen); |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | left -= elem_len; |
| 1293 | ptr += (elem_len + 2); |
| 1294 | } |
| 1295 | return; |
| 1296 | } |
| 1297 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1298 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1299 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1300 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1301 | #else |
| 1302 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1303 | struct cfg80211_beacon_data *params) |
| 1304 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1305 | { |
| 1306 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1307 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1308 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1309 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1310 | |
| 1311 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1312 | |
| 1313 | if(genie == NULL) { |
| 1314 | |
| 1315 | return -ENOMEM; |
| 1316 | } |
| 1317 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1318 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1319 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1320 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1321 | ret = -EINVAL; |
| 1322 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1323 | } |
| 1324 | |
| 1325 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1326 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1327 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1328 | { |
| 1329 | ret = -EINVAL; |
| 1330 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1331 | } |
| 1332 | #endif |
| 1333 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1334 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1335 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1336 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1337 | ret = -EINVAL; |
| 1338 | goto done; |
| 1339 | } |
| 1340 | |
| 1341 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1342 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1343 | wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1344 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1345 | |
| 1346 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1347 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1348 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1349 | { |
| 1350 | hddLog(LOGE, |
| 1351 | "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] | 1352 | ret = -EINVAL; |
| 1353 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1357 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1358 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1359 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1360 | ==eHAL_STATUS_FAILURE) |
| 1361 | { |
| 1362 | hddLog(LOGE, |
| 1363 | "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] | 1364 | ret = -EINVAL; |
| 1365 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1366 | } |
| 1367 | |
| 1368 | // Added for ProResp IE |
| 1369 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1370 | { |
| 1371 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1372 | u8 probe_rsp_ie_len[3] = {0}; |
| 1373 | u8 counter = 0; |
| 1374 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1375 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1376 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1377 | Store More then 255 bytes into One Variable. |
| 1378 | */ |
| 1379 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1380 | { |
| 1381 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1382 | { |
| 1383 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1384 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1385 | } |
| 1386 | else |
| 1387 | { |
| 1388 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1389 | rem_probe_resp_ie_len = 0; |
| 1390 | } |
| 1391 | } |
| 1392 | |
| 1393 | rem_probe_resp_ie_len = 0; |
| 1394 | |
| 1395 | if (probe_rsp_ie_len[0] > 0) |
| 1396 | { |
| 1397 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1398 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1399 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1400 | probe_rsp_ie_len[0], NULL, |
| 1401 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1402 | { |
| 1403 | hddLog(LOGE, |
| 1404 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1405 | ret = -EINVAL; |
| 1406 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | } |
| 1408 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1409 | } |
| 1410 | |
| 1411 | if (probe_rsp_ie_len[1] > 0) |
| 1412 | { |
| 1413 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1414 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1415 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1416 | probe_rsp_ie_len[1], NULL, |
| 1417 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1418 | { |
| 1419 | hddLog(LOGE, |
| 1420 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1421 | ret = -EINVAL; |
| 1422 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1423 | } |
| 1424 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1425 | } |
| 1426 | |
| 1427 | if (probe_rsp_ie_len[2] > 0) |
| 1428 | { |
| 1429 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1430 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1431 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1432 | probe_rsp_ie_len[2], NULL, |
| 1433 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1434 | { |
| 1435 | hddLog(LOGE, |
| 1436 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1437 | ret = -EINVAL; |
| 1438 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1439 | } |
| 1440 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1441 | } |
| 1442 | |
| 1443 | if (probe_rsp_ie_len[1] == 0 ) |
| 1444 | { |
| 1445 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1446 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1447 | eANI_BOOLEAN_FALSE) ) |
| 1448 | { |
| 1449 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1450 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | if (probe_rsp_ie_len[2] == 0 ) |
| 1455 | { |
| 1456 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1457 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1458 | eANI_BOOLEAN_FALSE) ) |
| 1459 | { |
| 1460 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1461 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1462 | } |
| 1463 | } |
| 1464 | |
| 1465 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1466 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1467 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1468 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1469 | == eHAL_STATUS_FAILURE) |
| 1470 | { |
| 1471 | hddLog(LOGE, |
| 1472 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1473 | ret = -EINVAL; |
| 1474 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1475 | } |
| 1476 | } |
| 1477 | else |
| 1478 | { |
| 1479 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1480 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1481 | |
| 1482 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1483 | "%s: No Probe Response IE received in set beacon", |
| 1484 | __func__); |
| 1485 | } |
| 1486 | |
| 1487 | // Added for AssocResp IE |
| 1488 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1489 | { |
| 1490 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1491 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1492 | params->assocresp_ies_len, NULL, |
| 1493 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1494 | { |
| 1495 | hddLog(LOGE, |
| 1496 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1497 | ret = -EINVAL; |
| 1498 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1499 | } |
| 1500 | |
| 1501 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1502 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1503 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1504 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1505 | == eHAL_STATUS_FAILURE) |
| 1506 | { |
| 1507 | hddLog(LOGE, |
| 1508 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1509 | ret = -EINVAL; |
| 1510 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1511 | } |
| 1512 | } |
| 1513 | else |
| 1514 | { |
| 1515 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1516 | "%s: No Assoc Response IE received in set beacon", |
| 1517 | __func__); |
| 1518 | |
| 1519 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1520 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1521 | eANI_BOOLEAN_FALSE) ) |
| 1522 | { |
| 1523 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1524 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1525 | } |
| 1526 | } |
| 1527 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1528 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1529 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1530 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1531 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1532 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1533 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1534 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1535 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1536 | * wlan_hdd_cfg80211_set_channel() |
| 1537 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1538 | * channel list. |
| 1539 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 1540 | 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] | 1541 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1542 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1543 | v_U32_t num_ch = 0; |
| 1544 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1545 | u32 indx = 0; |
| 1546 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1547 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1548 | 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] | 1549 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1550 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1551 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1552 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1553 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1554 | /* Validate the channel */ |
| 1555 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1556 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1557 | if ( channel == rfChannels[count].channelNum ) |
| 1558 | { |
| 1559 | fValidChannel = TRUE; |
| 1560 | break; |
| 1561 | } |
| 1562 | } |
| 1563 | if (fValidChannel != TRUE) |
| 1564 | { |
| 1565 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1566 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1567 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1568 | } |
| 1569 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1570 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1571 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1572 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1573 | valid_ch, &num_ch)) |
| 1574 | { |
| 1575 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1576 | "%s: failed to get valid channel list", __func__); |
| 1577 | return VOS_STATUS_E_FAILURE; |
| 1578 | } |
| 1579 | for (indx = 0; indx < num_ch; indx++) |
| 1580 | { |
| 1581 | if (channel == valid_ch[indx]) |
| 1582 | { |
| 1583 | break; |
| 1584 | } |
| 1585 | } |
| 1586 | |
| 1587 | if (indx >= num_ch) |
| 1588 | { |
| 1589 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1590 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1591 | return VOS_STATUS_E_FAILURE; |
| 1592 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1593 | } |
| 1594 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1595 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1596 | } |
| 1597 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1598 | /** |
| 1599 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1600 | * This function is used to set the channel number |
| 1601 | */ |
| 1602 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1603 | struct ieee80211_channel *chan, |
| 1604 | enum nl80211_channel_type channel_type |
| 1605 | ) |
| 1606 | { |
| 1607 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1608 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1609 | hdd_adapter_t *pAdapter = NULL; |
| 1610 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1611 | hdd_context_t *pHddCtx; |
| 1612 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1613 | |
| 1614 | ENTER(); |
| 1615 | |
| 1616 | if( NULL == dev ) |
| 1617 | { |
| 1618 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1619 | "%s: Called with dev = NULL.", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1620 | return -ENODEV; |
| 1621 | } |
| 1622 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1623 | |
| 1624 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1625 | "%s: device_mode = %d freq = %d", __func__, |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1626 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1627 | |
| 1628 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1629 | status = wlan_hdd_validate_context(pHddCtx); |
| 1630 | |
| 1631 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1632 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1633 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1634 | "%s: HDD context is not valid", __func__); |
| 1635 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1636 | } |
| 1637 | |
| 1638 | /* |
| 1639 | * Do freq to chan conversion |
| 1640 | * TODO: for 11a |
| 1641 | */ |
| 1642 | |
| 1643 | channel = ieee80211_frequency_to_channel(freq); |
| 1644 | |
| 1645 | /* Check freq range */ |
| 1646 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1647 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1648 | { |
| 1649 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1650 | "%s: Channel [%d] is outside valid range from %d to %d", |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1651 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1652 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1653 | return -EINVAL; |
| 1654 | } |
| 1655 | |
| 1656 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1657 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1658 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1659 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1660 | { |
| 1661 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1662 | { |
| 1663 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1664 | "%s: Invalid Channel [%d]", __func__, channel); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1665 | return -EINVAL; |
| 1666 | } |
| 1667 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1668 | "%s: set channel to [%d] for device mode =%d", |
| 1669 | __func__, channel,pAdapter->device_mode); |
| 1670 | } |
| 1671 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1672 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1673 | ) |
| 1674 | { |
| 1675 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1676 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1677 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1678 | |
| 1679 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1680 | { |
| 1681 | /* Link is up then return cant set channel*/ |
| 1682 | hddLog( VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1683 | "%s: IBSS Associated, can't set the channel", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1684 | return -EINVAL; |
| 1685 | } |
| 1686 | |
| 1687 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1688 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1689 | pRoamProfile->ChannelInfo.ChannelList = |
| 1690 | &pHddStaCtx->conn_info.operationChannel; |
| 1691 | } |
| 1692 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1693 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1694 | ) |
| 1695 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1696 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1697 | { |
| 1698 | if(VOS_STATUS_SUCCESS != |
| 1699 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1700 | { |
| 1701 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1702 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1703 | return -EINVAL; |
| 1704 | } |
| 1705 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1706 | } |
| 1707 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1708 | { |
| 1709 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1710 | |
| 1711 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1712 | channel set by supplicant |
| 1713 | */ |
| 1714 | if ( cfg_param->apAutoChannelSelection ) |
| 1715 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1716 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1717 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1718 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1719 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1720 | __func__, pAdapter->device_mode); |
| 1721 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1722 | else |
| 1723 | { |
| 1724 | if(VOS_STATUS_SUCCESS != |
| 1725 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1726 | { |
| 1727 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1728 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1729 | return -EINVAL; |
| 1730 | } |
| 1731 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1732 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1733 | } |
| 1734 | } |
| 1735 | else |
| 1736 | { |
| 1737 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1738 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1739 | return -EINVAL; |
| 1740 | } |
| 1741 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1742 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1743 | } |
| 1744 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1745 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1746 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1747 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1748 | #else |
| 1749 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1750 | struct cfg80211_beacon_data *params, |
| 1751 | const u8 *ssid, size_t ssid_len, |
| 1752 | enum nl80211_hidden_ssid hidden_ssid) |
| 1753 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1754 | { |
| 1755 | tsap_Config_t *pConfig; |
| 1756 | beacon_data_t *pBeacon = NULL; |
| 1757 | struct ieee80211_mgmt *pMgmt_frame; |
| 1758 | v_U8_t *pIe=NULL; |
| 1759 | v_U16_t capab_info; |
| 1760 | eCsrAuthType RSNAuthType; |
| 1761 | eCsrEncryptionType RSNEncryptType; |
| 1762 | eCsrEncryptionType mcRSNEncryptType; |
| 1763 | int status = VOS_STATUS_SUCCESS; |
| 1764 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1765 | hdd_hostapd_state_t *pHostapdState; |
| 1766 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1767 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1768 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1769 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1770 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1771 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1772 | |
| 1773 | ENTER(); |
| 1774 | |
| 1775 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1776 | |
| 1777 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1778 | |
| 1779 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1780 | |
| 1781 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1782 | |
| 1783 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1784 | |
| 1785 | //channel is already set in the set_channel Call back |
| 1786 | //pConfig->channel = pCommitConfig->channel; |
| 1787 | |
| 1788 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1789 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1790 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1791 | |
| 1792 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1793 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1794 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1795 | pConfig->dtim_period); |
| 1796 | |
| 1797 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1798 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1799 | { |
| 1800 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1801 | WLAN_EID_COUNTRY); |
Kiet Lam | 083504c | 2013-11-25 14:17:45 +0530 | [diff] [blame] | 1802 | if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0) |
| 1803 | { |
| 1804 | tANI_BOOLEAN restartNeeded; |
| 1805 | pConfig->ieee80211d = 1; |
| 1806 | vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3); |
| 1807 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1808 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
| 1809 | } |
| 1810 | else if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1811 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1812 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1813 | pConfig->ieee80211d = 1; |
| 1814 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1815 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1816 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1817 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1818 | else |
| 1819 | { |
| 1820 | pConfig->ieee80211d = 0; |
| 1821 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1822 | /* |
| 1823 | * If auto channel is configured i.e. channel is 0, |
| 1824 | * so skip channel validation. |
| 1825 | */ |
| 1826 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1827 | { |
| 1828 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1829 | { |
| 1830 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1831 | "%s: Invalid Channel [%d]", __func__, pConfig->channel); |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1832 | return -EINVAL; |
| 1833 | } |
| 1834 | } |
| 1835 | else |
| 1836 | { |
| 1837 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1838 | { |
| 1839 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1840 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1841 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1842 | } |
| 1843 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1844 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1845 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1846 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1847 | { |
| 1848 | pConfig->ieee80211d = 0; |
| 1849 | } |
| 1850 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1851 | |
| 1852 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1853 | |
| 1854 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1855 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1856 | |
| 1857 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1858 | |
| 1859 | /*Set wps station to configured*/ |
| 1860 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1861 | |
| 1862 | if(pIe) |
| 1863 | { |
| 1864 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1865 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1866 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1867 | return -EINVAL; |
| 1868 | } |
| 1869 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1870 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1871 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1872 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1873 | * WPS state |
| 1874 | */ |
| 1875 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1876 | { |
| 1877 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1878 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1879 | { |
| 1880 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1881 | } |
| 1882 | } |
| 1883 | } |
| 1884 | else |
| 1885 | { |
| 1886 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1887 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1888 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1889 | |
| 1890 | pConfig->RSNWPAReqIELength = 0; |
| 1891 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1892 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1893 | WLAN_EID_RSN); |
| 1894 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1895 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1896 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1897 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1898 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1899 | /* The actual processing may eventually be more extensive than |
| 1900 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1901 | * by the app. |
| 1902 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1903 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1904 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1905 | &RSNEncryptType, |
| 1906 | &mcRSNEncryptType, |
| 1907 | &RSNAuthType, |
| 1908 | pConfig->pRSNWPAReqIE[1]+2, |
| 1909 | pConfig->pRSNWPAReqIE ); |
| 1910 | |
| 1911 | if( VOS_STATUS_SUCCESS == status ) |
| 1912 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1913 | /* Now copy over all the security attributes you have |
| 1914 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1915 | * */ |
| 1916 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1917 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1918 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1919 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1920 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1921 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1922 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1923 | } |
| 1924 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1925 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1926 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1927 | pBeacon->tail, pBeacon->tail_len); |
| 1928 | |
| 1929 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1930 | { |
| 1931 | if (pConfig->pRSNWPAReqIE) |
| 1932 | { |
| 1933 | /*Mixed mode WPA/WPA2*/ |
| 1934 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1935 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1936 | } |
| 1937 | else |
| 1938 | { |
| 1939 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1940 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1941 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1942 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1943 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1944 | &RSNEncryptType, |
| 1945 | &mcRSNEncryptType, |
| 1946 | &RSNAuthType, |
| 1947 | pConfig->pRSNWPAReqIE[1]+2, |
| 1948 | pConfig->pRSNWPAReqIE ); |
| 1949 | |
| 1950 | if( VOS_STATUS_SUCCESS == status ) |
| 1951 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1952 | /* Now copy over all the security attributes you have |
| 1953 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1954 | * */ |
| 1955 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1956 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1957 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1958 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1959 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1960 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1961 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1962 | } |
| 1963 | } |
| 1964 | } |
| 1965 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1966 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1967 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1968 | return -EINVAL; |
| 1969 | } |
| 1970 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1971 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1972 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1973 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1974 | if (params->ssid != NULL) |
| 1975 | { |
| 1976 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1977 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1978 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1979 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1980 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1981 | #else |
| 1982 | if (ssid != NULL) |
| 1983 | { |
| 1984 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1985 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1986 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1987 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1988 | } |
| 1989 | #endif |
| 1990 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1991 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1992 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1993 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1994 | /* default value */ |
| 1995 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1996 | pConfig->num_accept_mac = 0; |
| 1997 | pConfig->num_deny_mac = 0; |
| 1998 | |
| 1999 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 2000 | pBeacon->tail, pBeacon->tail_len); |
| 2001 | |
| 2002 | /* pIe for black list is following form: |
| 2003 | type : 1 byte |
| 2004 | length : 1 byte |
| 2005 | OUI : 4 bytes |
| 2006 | acl type : 1 byte |
| 2007 | no of mac addr in black list: 1 byte |
| 2008 | 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] | 2009 | */ |
| 2010 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2011 | { |
| 2012 | pConfig->SapMacaddr_acl = pIe[6]; |
| 2013 | pConfig->num_deny_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2014 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2015 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2016 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 2017 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2018 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2019 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 2020 | { |
| 2021 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2022 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2023 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2024 | } |
| 2025 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 2026 | pBeacon->tail, pBeacon->tail_len); |
| 2027 | |
| 2028 | /* pIe for white list is following form: |
| 2029 | type : 1 byte |
| 2030 | length : 1 byte |
| 2031 | OUI : 4 bytes |
| 2032 | acl type : 1 byte |
| 2033 | no of mac addr in white list: 1 byte |
| 2034 | 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] | 2035 | */ |
| 2036 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2037 | { |
| 2038 | pConfig->SapMacaddr_acl = pIe[6]; |
| 2039 | pConfig->num_accept_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2040 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2041 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2042 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 2043 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2044 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2045 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 2046 | { |
| 2047 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2048 | acl_entry++; |
| 2049 | } |
| 2050 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2051 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2052 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 2053 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2054 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2055 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 2056 | * This is valid only if mode is set to 11n in hostapd, either AUTO or |
| 2057 | * 11ac in .ini and 11ac is supported by both host and firmware. |
| 2058 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) |
| 2059 | */ |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2060 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 2061 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2062 | (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) || |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2063 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 2064 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) && |
| 2065 | (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2066 | { |
| 2067 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 2068 | |
| 2069 | /* Disable VHT support in 2.4 GHz band */ |
| 2070 | if (pConfig->channel <= 14 && |
| 2071 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE) |
| 2072 | { |
| 2073 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 2074 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2075 | } |
| 2076 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2077 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 2078 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 2079 | { |
| 2080 | sme_SelectCBMode(hHal, |
| 2081 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 2082 | pConfig->channel); |
| 2083 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2084 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 2085 | pConfig->ht_capab = |
| 2086 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 2087 | |
| 2088 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 2089 | { |
| 2090 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 2091 | return -EINVAL; |
| 2092 | } |
| 2093 | |
| 2094 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2095 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2096 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 2097 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2098 | pConfig->obssProtEnabled = |
| 2099 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2100 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2101 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2102 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2103 | hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"), |
| 2104 | pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int, |
| 2105 | (int)pConfig->channel); |
| 2106 | hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"), |
| 2107 | pConfig->SapHw_mode, pConfig->privacy, |
| 2108 | pConfig->authType); |
| 2109 | hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"), |
| 2110 | (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable); |
| 2111 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"), |
| 2112 | pConfig->protEnabled, pConfig->obssProtEnabled); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2113 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2114 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2115 | { |
| 2116 | //Bss already started. just return. |
| 2117 | //TODO Probably it should update some beacon params. |
| 2118 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 2119 | EXIT(); |
| 2120 | return 0; |
| 2121 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2122 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2123 | pConfig->persona = pHostapdAdapter->device_mode; |
| 2124 | |
| 2125 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 2126 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 2127 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 2128 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2129 | hddLog(LOGE,FL("SAP Start Bss fail")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2130 | return -EINVAL; |
| 2131 | } |
| 2132 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2133 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2134 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2135 | |
| 2136 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2137 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2138 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2139 | { |
| 2140 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2141 | ("ERROR: HDD vos wait for single_event failed!!")); |
Tushnim Bhattacharyya | ad37df1 | 2013-10-02 12:01:33 -0700 | [diff] [blame] | 2142 | smeGetCommandQStatus(hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2143 | VOS_ASSERT(0); |
| 2144 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2145 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2146 | //Succesfully started Bss update the state bit. |
| 2147 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2148 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2149 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2150 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2151 | { |
| 2152 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2153 | { |
| 2154 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2155 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2156 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2157 | } |
| 2158 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2159 | { |
| 2160 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2161 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2162 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2163 | } |
| 2164 | } |
| 2165 | #endif |
| 2166 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2167 | pHostapdState->bCommit = TRUE; |
| 2168 | EXIT(); |
| 2169 | |
| 2170 | return 0; |
| 2171 | } |
| 2172 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2173 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2174 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2175 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2176 | struct beacon_parameters *params) |
| 2177 | { |
| 2178 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2179 | hdd_context_t *pHddCtx; |
| 2180 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2181 | |
| 2182 | ENTER(); |
| 2183 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2184 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d",pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2185 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2186 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2187 | status = wlan_hdd_validate_context(pHddCtx); |
| 2188 | |
| 2189 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2190 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2191 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2192 | "%s: HDD context is not valid", __func__); |
| 2193 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2194 | } |
| 2195 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2196 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2197 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2198 | ) |
| 2199 | { |
| 2200 | beacon_data_t *old,*new; |
| 2201 | |
| 2202 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2203 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2204 | if (old) |
| 2205 | return -EALREADY; |
| 2206 | |
| 2207 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2208 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2209 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2210 | { |
| 2211 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2212 | "%s:Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2213 | return -EINVAL; |
| 2214 | } |
| 2215 | |
| 2216 | pAdapter->sessionCtx.ap.beacon = new; |
| 2217 | |
| 2218 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2219 | } |
| 2220 | |
| 2221 | EXIT(); |
| 2222 | return status; |
| 2223 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2224 | |
| 2225 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2226 | struct net_device *dev, |
| 2227 | struct beacon_parameters *params) |
| 2228 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2229 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2230 | hdd_context_t *pHddCtx; |
| 2231 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2232 | |
| 2233 | ENTER(); |
| 2234 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2235 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2236 | __func__,pAdapter->device_mode); |
| 2237 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2238 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2239 | status = wlan_hdd_validate_context(pHddCtx); |
| 2240 | |
| 2241 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2242 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2244 | "%s: HDD context is not valid", __func__); |
| 2245 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2246 | } |
| 2247 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2248 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2249 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2250 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2251 | { |
| 2252 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2253 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2254 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2255 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2256 | if (!old) |
| 2257 | return -ENOENT; |
| 2258 | |
| 2259 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2260 | |
| 2261 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2262 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2263 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2264 | return -EINVAL; |
| 2265 | } |
| 2266 | |
| 2267 | pAdapter->sessionCtx.ap.beacon = new; |
| 2268 | |
| 2269 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2270 | } |
| 2271 | |
| 2272 | EXIT(); |
| 2273 | return status; |
| 2274 | } |
| 2275 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2276 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2277 | |
| 2278 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2279 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2280 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2281 | #else |
| 2282 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2283 | struct net_device *dev) |
| 2284 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2285 | { |
| 2286 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2287 | hdd_context_t *pHddCtx = NULL; |
| 2288 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2289 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2290 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2291 | |
| 2292 | ENTER(); |
| 2293 | |
| 2294 | if (NULL == pAdapter) |
| 2295 | { |
| 2296 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2297 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2298 | return -ENODEV; |
| 2299 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2300 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2301 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2302 | status = wlan_hdd_validate_context(pHddCtx); |
| 2303 | |
| 2304 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2305 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2306 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2307 | "%s: HDD context is not valid", __func__); |
| 2308 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2309 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2310 | |
| 2311 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2312 | if (NULL == staAdapter) |
| 2313 | { |
| 2314 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2315 | if (NULL == staAdapter) |
| 2316 | { |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 2317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2318 | "%s: HDD adapter context for STA/P2P-CLI is Null", |
| 2319 | __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2320 | } |
| 2321 | } |
| 2322 | |
| 2323 | pScanInfo = &pHddCtx->scan_info; |
| 2324 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2325 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2326 | __func__,pAdapter->device_mode); |
| 2327 | |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 2328 | if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2329 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2330 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 2331 | hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2332 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2333 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2334 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2335 | if (!status) |
| 2336 | { |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 2337 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2338 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2339 | __func__); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame^] | 2340 | |
| 2341 | if (pHddCtx->isLogpInProgress) |
| 2342 | { |
| 2343 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2344 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 2345 | return -EAGAIN; |
| 2346 | } |
| 2347 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2348 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2349 | } |
| 2350 | } |
| 2351 | |
Arun Kumar Khandavalli | a3bd800 | 2014-01-17 16:21:19 +0530 | [diff] [blame] | 2352 | hdd_hostapd_stop(dev); |
| 2353 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2354 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2355 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2356 | ) |
| 2357 | { |
| 2358 | beacon_data_t *old; |
| 2359 | |
| 2360 | old = pAdapter->sessionCtx.ap.beacon; |
| 2361 | |
| 2362 | if (!old) |
| 2363 | return -ENOENT; |
| 2364 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2365 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2366 | |
| 2367 | mutex_lock(&pHddCtx->sap_lock); |
| 2368 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2369 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2370 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2371 | { |
| 2372 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2373 | |
| 2374 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2375 | |
| 2376 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2377 | { |
| 2378 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2379 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2380 | VOS_ASSERT(0); |
| 2381 | } |
| 2382 | } |
| 2383 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2384 | } |
| 2385 | mutex_unlock(&pHddCtx->sap_lock); |
| 2386 | |
| 2387 | if(status != VOS_STATUS_SUCCESS) |
| 2388 | { |
| 2389 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2390 | "%s:Error!!! Stopping the BSS",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2391 | return -EINVAL; |
| 2392 | } |
| 2393 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2394 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2395 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2396 | ==eHAL_STATUS_FAILURE) |
| 2397 | { |
| 2398 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2399 | "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] | 2400 | } |
| 2401 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2402 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2403 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2404 | eANI_BOOLEAN_FALSE) ) |
| 2405 | { |
| 2406 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2407 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2408 | } |
| 2409 | |
| 2410 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2411 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2412 | |
| 2413 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2414 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2415 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2416 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2417 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2418 | { |
| 2419 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2420 | "GO got removed"); |
| 2421 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2422 | } |
| 2423 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2424 | } |
| 2425 | EXIT(); |
| 2426 | return status; |
| 2427 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2428 | |
| 2429 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2430 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2431 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2432 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2433 | struct cfg80211_ap_settings *params) |
| 2434 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2435 | hdd_adapter_t *pAdapter; |
| 2436 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2437 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2438 | |
| 2439 | ENTER(); |
| 2440 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2441 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2442 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2443 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2444 | "%s: Device is Null", __func__); |
| 2445 | return -ENODEV; |
| 2446 | } |
| 2447 | |
| 2448 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2449 | if (NULL == pAdapter) |
| 2450 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2451 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2452 | "%s: HDD adapter is Null", __func__); |
| 2453 | return -ENODEV; |
| 2454 | } |
| 2455 | |
| 2456 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2457 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2458 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2459 | "%s: HDD adapter magic is invalid", __func__); |
| 2460 | return -ENODEV; |
| 2461 | } |
| 2462 | |
| 2463 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2464 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2465 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2466 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2467 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2468 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2469 | "%s: HDD context is not valid", __func__); |
| 2470 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2471 | } |
| 2472 | |
| 2473 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2474 | __func__, pAdapter->device_mode); |
| 2475 | |
| 2476 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2477 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2478 | ) |
| 2479 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2480 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2481 | |
| 2482 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2483 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2484 | if (old) |
| 2485 | return -EALREADY; |
| 2486 | |
| 2487 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2488 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2489 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2490 | { |
| 2491 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2492 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2493 | return -EINVAL; |
| 2494 | } |
| 2495 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2496 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2497 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 2498 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2499 | params->channel, params->channel_type); |
| 2500 | #else |
| 2501 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 2502 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2503 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2504 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2505 | params->ssid_len, params->hidden_ssid); |
| 2506 | } |
| 2507 | |
| 2508 | EXIT(); |
| 2509 | return status; |
| 2510 | } |
| 2511 | |
| 2512 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2513 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2514 | struct net_device *dev, |
| 2515 | struct cfg80211_beacon_data *params) |
| 2516 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2517 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2518 | hdd_context_t *pHddCtx; |
| 2519 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2520 | |
| 2521 | ENTER(); |
| 2522 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2523 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2524 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2525 | |
| 2526 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2527 | status = wlan_hdd_validate_context(pHddCtx); |
| 2528 | |
| 2529 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2530 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2531 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2532 | "%s: HDD context is not valid", __func__); |
| 2533 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2534 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2535 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2536 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2537 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2538 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2539 | { |
| 2540 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2541 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2542 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2543 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2544 | if (!old) |
| 2545 | return -ENOENT; |
| 2546 | |
| 2547 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2548 | |
| 2549 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2550 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2551 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2552 | return -EINVAL; |
| 2553 | } |
| 2554 | |
| 2555 | pAdapter->sessionCtx.ap.beacon = new; |
| 2556 | |
| 2557 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2558 | } |
| 2559 | |
| 2560 | EXIT(); |
| 2561 | return status; |
| 2562 | } |
| 2563 | |
| 2564 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2565 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2566 | |
| 2567 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2568 | struct net_device *dev, |
| 2569 | struct bss_parameters *params) |
| 2570 | { |
| 2571 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2572 | |
| 2573 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2574 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2575 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2576 | __func__,pAdapter->device_mode); |
| 2577 | |
| 2578 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2579 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2580 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2581 | { |
| 2582 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2583 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2584 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2585 | { |
| 2586 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2587 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2588 | } |
| 2589 | |
| 2590 | EXIT(); |
| 2591 | return 0; |
| 2592 | } |
| 2593 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2594 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 2595 | * to wait for contry code completion |
| 2596 | */ |
| 2597 | void* wlan_hdd_change_country_code_cb(void *pAdapter) |
| 2598 | { |
| 2599 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 2600 | complete(&call_back_pAdapter->change_country_code); |
| 2601 | return NULL; |
| 2602 | } |
| 2603 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2604 | /* |
| 2605 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2606 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2607 | */ |
| 2608 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2609 | struct net_device *ndev, |
| 2610 | enum nl80211_iftype type, |
| 2611 | u32 *flags, |
| 2612 | struct vif_params *params |
| 2613 | ) |
| 2614 | { |
| 2615 | struct wireless_dev *wdev; |
| 2616 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2617 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2618 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2619 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2620 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2621 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2622 | eMib_dot11DesiredBssType connectedBssType; |
| 2623 | VOS_STATUS status; |
| 2624 | |
| 2625 | ENTER(); |
| 2626 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2627 | status = wlan_hdd_validate_context(pHddCtx); |
| 2628 | |
| 2629 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2630 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2631 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2632 | "%s: HDD context is not valid", __func__); |
| 2633 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2634 | } |
| 2635 | |
| 2636 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2637 | __func__, pAdapter->device_mode); |
| 2638 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2639 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2640 | wdev = ndev->ieee80211_ptr; |
| 2641 | |
| 2642 | #ifdef WLAN_BTAMP_FEATURE |
| 2643 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2644 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2645 | (NL80211_IFTYPE_AP == type)|| |
| 2646 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2647 | { |
| 2648 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2649 | // stop AMP traffic |
| 2650 | status = WLANBAP_StopAmp(); |
| 2651 | if(VOS_STATUS_SUCCESS != status ) |
| 2652 | { |
| 2653 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2654 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2655 | "%s: Failed to stop AMP", __func__); |
| 2656 | return -EINVAL; |
| 2657 | } |
| 2658 | } |
| 2659 | #endif //WLAN_BTAMP_FEATURE |
| 2660 | /* Reset the current device mode bit mask*/ |
| 2661 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2662 | |
| 2663 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2664 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2665 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2666 | ) |
| 2667 | { |
| 2668 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2669 | pRoamProfile = &pWextState->roamProfile; |
| 2670 | LastBSSType = pRoamProfile->BSSType; |
| 2671 | |
| 2672 | switch (type) |
| 2673 | { |
| 2674 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2675 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2676 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2677 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2678 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2679 | #ifdef WLAN_FEATURE_11AC |
| 2680 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2681 | { |
| 2682 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2683 | } |
| 2684 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2685 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2686 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2687 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2688 | //Check for sub-string p2p to confirm its a p2p interface |
| 2689 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2690 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2691 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2692 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2693 | } |
| 2694 | else |
| 2695 | { |
| 2696 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2697 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2698 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2699 | #ifdef FEATURE_WLAN_TDLS |
| 2700 | /* The open adapter for the p2p shall skip initializations in |
| 2701 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 2702 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 2703 | * tdls_init when the change_iface sets the device mode to |
| 2704 | * WLAN_HDD_P2P_CLIENT. |
| 2705 | */ |
| 2706 | |
| 2707 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 2708 | { |
| 2709 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 2710 | { |
| 2711 | return -EINVAL; |
| 2712 | } |
| 2713 | } |
| 2714 | #endif |
| 2715 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2716 | break; |
| 2717 | case NL80211_IFTYPE_ADHOC: |
| 2718 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2719 | "%s: setting interface Type to ADHOC", __func__); |
| 2720 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2721 | pRoamProfile->phyMode = |
| 2722 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2723 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2724 | wdev->iftype = type; |
| 2725 | break; |
| 2726 | |
| 2727 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2728 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2729 | { |
| 2730 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2731 | "%s: setting interface Type to %s", __func__, |
| 2732 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2733 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2734 | //Cancel any remain on channel for GO mode |
| 2735 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2736 | { |
| 2737 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2738 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2739 | if (NL80211_IFTYPE_AP == type) |
| 2740 | { |
| 2741 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2742 | * address. This will take one HW STA and the max number of clients |
| 2743 | * that can connect to softAP will be reduced by one. so while changing |
| 2744 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2745 | * interface as it is not required in SoftAP mode. |
| 2746 | */ |
| 2747 | |
| 2748 | // Get P2P Adapter |
| 2749 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2750 | |
| 2751 | if (pP2pAdapter) |
| 2752 | { |
| 2753 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2754 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2755 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2756 | } |
| 2757 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2758 | #ifdef FEATURE_WLAN_TDLS |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2759 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2760 | /* A Mutex Lock is introduced while changing the mode to |
| 2761 | * protect the concurrent access for the Adapters by TDLS |
| 2762 | * module. |
| 2763 | */ |
| 2764 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 2765 | { |
| 2766 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2767 | "%s: unable to lock list", __func__); |
| 2768 | return -EINVAL; |
| 2769 | } |
| 2770 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2771 | //De-init the adapter. |
| 2772 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2773 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2774 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2775 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2776 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2777 | #ifdef FEATURE_WLAN_TDLS |
| 2778 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2779 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2780 | |
| 2781 | //Disable BMPS and IMPS if enabled |
| 2782 | //before starting Go |
| 2783 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2784 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2785 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2786 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2787 | { |
| 2788 | //Fail to Exit BMPS |
| 2789 | VOS_ASSERT(0); |
| 2790 | } |
| 2791 | } |
| 2792 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2793 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2794 | (pConfig->apRandomBssidEnabled)) |
| 2795 | { |
| 2796 | /* To meet Android requirements create a randomized |
| 2797 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2798 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2799 | ndev->dev_addr[0] = 0x02; |
| 2800 | ndev->dev_addr[1] = 0x1A; |
| 2801 | ndev->dev_addr[2] = 0x11; |
| 2802 | ndev->dev_addr[3] |= 0xF0; |
| 2803 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2804 | VOS_MAC_ADDR_SIZE); |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 2805 | pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n", |
| 2806 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2807 | } |
| 2808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2809 | hdd_set_ap_ops( pAdapter->dev ); |
| 2810 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2811 | /* This is for only SAP mode where users can |
| 2812 | * control country through ini. |
| 2813 | * P2P GO follows station country code |
| 2814 | * acquired during the STA scanning. */ |
| 2815 | if((NL80211_IFTYPE_AP == type) && |
| 2816 | (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)) |
| 2817 | { |
| 2818 | int status = 0; |
| 2819 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO, |
| 2820 | "%s: setting country code from INI ", __func__); |
| 2821 | init_completion(&pAdapter->change_country_code); |
| 2822 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2823 | (void *)(tSmeChangeCountryCallback) |
| 2824 | wlan_hdd_change_country_code_cb, |
| 2825 | pConfig->apCntryCode, pAdapter, |
| 2826 | pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2827 | eSIR_FALSE, |
| 2828 | eSIR_TRUE); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2829 | if (eHAL_STATUS_SUCCESS == status) |
| 2830 | { |
| 2831 | /* Wait for completion */ |
| 2832 | status = wait_for_completion_interruptible_timeout( |
| 2833 | &pAdapter->change_country_code, |
| 2834 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2835 | if (status <= 0) |
| 2836 | { |
| 2837 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2838 | "%s: SME Timed out while setting country code ", |
| 2839 | __func__); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame^] | 2840 | |
| 2841 | if (pHddCtx->isLogpInProgress) |
| 2842 | { |
| 2843 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2844 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 2845 | return -EAGAIN; |
| 2846 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2847 | } |
| 2848 | } |
| 2849 | else |
| 2850 | { |
| 2851 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2852 | "%s: SME Change Country code failed",__func__); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2853 | return -EINVAL; |
| 2854 | } |
| 2855 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2856 | status = hdd_init_ap_mode(pAdapter); |
| 2857 | if(status != VOS_STATUS_SUCCESS) |
| 2858 | { |
| 2859 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2860 | "%s: Error initializing the ap mode", __func__); |
| 2861 | return -EINVAL; |
| 2862 | } |
| 2863 | hdd_set_conparam(1); |
| 2864 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2865 | /*interface type changed update in wiphy structure*/ |
| 2866 | if(wdev) |
| 2867 | { |
| 2868 | wdev->iftype = type; |
| 2869 | pHddCtx->change_iface = type; |
| 2870 | } |
| 2871 | else |
| 2872 | { |
| 2873 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2874 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2875 | return -EINVAL; |
| 2876 | } |
| 2877 | goto done; |
| 2878 | } |
| 2879 | |
| 2880 | default: |
| 2881 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2882 | __func__); |
| 2883 | return -EOPNOTSUPP; |
| 2884 | } |
| 2885 | } |
| 2886 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2887 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2888 | ) |
| 2889 | { |
| 2890 | switch(type) |
| 2891 | { |
| 2892 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2893 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2894 | case NL80211_IFTYPE_ADHOC: |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2895 | #ifdef FEATURE_WLAN_TDLS |
| 2896 | |
| 2897 | /* A Mutex Lock is introduced while changing the mode to |
| 2898 | * protect the concurrent access for the Adapters by TDLS |
| 2899 | * module. |
| 2900 | */ |
| 2901 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 2902 | { |
| 2903 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2904 | "%s: unable to lock list", __func__); |
| 2905 | return -EINVAL; |
| 2906 | } |
| 2907 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2908 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2909 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2910 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2911 | //Check for sub-string p2p to confirm its a p2p interface |
| 2912 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2913 | { |
| 2914 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2915 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2916 | } |
| 2917 | else |
| 2918 | { |
| 2919 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2920 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2921 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2922 | hdd_set_conparam(0); |
| 2923 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2924 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2925 | hdd_set_station_ops( pAdapter->dev ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2926 | #ifdef FEATURE_WLAN_TDLS |
| 2927 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2928 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 2929 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2930 | if( VOS_STATUS_SUCCESS != status ) |
| 2931 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2932 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2933 | * This is the right place to enable back bmps_imps() |
| 2934 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 2935 | if (pHddCtx->hdd_wlan_suspended) |
| 2936 | { |
| 2937 | hdd_set_pwrparams(pHddCtx); |
| 2938 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2939 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2940 | goto done; |
| 2941 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2942 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2943 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2944 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2945 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2946 | goto done; |
| 2947 | default: |
| 2948 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2949 | __func__); |
| 2950 | return -EOPNOTSUPP; |
| 2951 | |
| 2952 | } |
| 2953 | |
| 2954 | } |
| 2955 | else |
| 2956 | { |
| 2957 | return -EOPNOTSUPP; |
| 2958 | } |
| 2959 | |
| 2960 | |
| 2961 | if(pRoamProfile) |
| 2962 | { |
| 2963 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2964 | { |
| 2965 | /*interface type changed update in wiphy structure*/ |
| 2966 | wdev->iftype = type; |
| 2967 | |
| 2968 | /*the BSS mode changed, We need to issue disconnect |
| 2969 | if connected or in IBSS disconnect state*/ |
| 2970 | if ( hdd_connGetConnectedBssType( |
| 2971 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2972 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2973 | { |
| 2974 | /*need to issue a disconnect to CSR.*/ |
| 2975 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2976 | if( eHAL_STATUS_SUCCESS == |
| 2977 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2978 | pAdapter->sessionId, |
| 2979 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2980 | { |
| 2981 | wait_for_completion_interruptible_timeout( |
| 2982 | &pAdapter->disconnect_comp_var, |
| 2983 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2984 | } |
| 2985 | } |
| 2986 | } |
| 2987 | } |
| 2988 | |
| 2989 | done: |
| 2990 | /*set bitmask based on updated value*/ |
| 2991 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 2992 | |
| 2993 | /* Only STA mode support TM now |
| 2994 | * all other mode, TM feature should be disabled */ |
| 2995 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 2996 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 2997 | { |
| 2998 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 2999 | } |
| 3000 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3001 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3002 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3003 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 3004 | { |
| 3005 | //we are ok to do AMP |
| 3006 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 3007 | } |
| 3008 | #endif //WLAN_BTAMP_FEATURE |
| 3009 | EXIT(); |
| 3010 | return 0; |
| 3011 | } |
| 3012 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3013 | #ifdef FEATURE_WLAN_TDLS |
| 3014 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 3015 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 3016 | { |
| 3017 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3018 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3019 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3020 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3021 | |
| 3022 | ENTER(); |
| 3023 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3024 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3025 | { |
| 3026 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3027 | "Invalid arguments"); |
| 3028 | return -EINVAL; |
| 3029 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 3030 | |
| 3031 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 3032 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 3033 | { |
| 3034 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3035 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 3036 | MAC_ADDRESS_STR " Request declined.", |
| 3037 | __func__, MAC_ADDR_ARRAY(mac)); |
| 3038 | return -ENOTSUPP; |
| 3039 | } |
| 3040 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3041 | if (pHddCtx->isLogpInProgress) |
| 3042 | { |
| 3043 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3044 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3045 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3046 | return -EBUSY; |
| 3047 | } |
| 3048 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3049 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3050 | |
| 3051 | if ( NULL == pTdlsPeer ) { |
| 3052 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3053 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 3054 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 3055 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3056 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3057 | |
| 3058 | /* in add station, we accept existing valid staId if there is */ |
| 3059 | if ((0 == update) && |
| 3060 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 3061 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3062 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3063 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3064 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3065 | " link_status %d. staId %d. add station ignored.", |
| 3066 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 3067 | return 0; |
| 3068 | } |
| 3069 | /* in change station, we accept only when staId is valid */ |
| 3070 | if ((1 == update) && |
| 3071 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 3072 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 3073 | { |
| 3074 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3075 | "%s: " MAC_ADDRESS_STR |
| 3076 | " link status %d. staId %d. change station %s.", |
| 3077 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 3078 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 3079 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3080 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3081 | |
| 3082 | /* 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] | 3083 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3084 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3086 | "%s: " MAC_ADDRESS_STR |
| 3087 | " TDLS setup is ongoing. Request declined.", |
| 3088 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3089 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3090 | } |
| 3091 | |
| 3092 | /* first to check if we reached to maximum supported TDLS peer. |
| 3093 | TODO: for now, return -EPERM looks working fine, |
| 3094 | but need to check if any other errno fit into this category.*/ |
| 3095 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 3096 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3097 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3098 | "%s: " MAC_ADDRESS_STR |
| 3099 | " TDLS Max peer already connected. Request declined.", |
| 3100 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3101 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3102 | } |
| 3103 | else |
| 3104 | { |
| 3105 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3106 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3107 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3108 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3109 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3110 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 3111 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3112 | return -EPERM; |
| 3113 | } |
| 3114 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3115 | if (0 == update) |
| 3116 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3117 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3118 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3119 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3120 | { |
| 3121 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3122 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3123 | if(StaParams->htcap_present) |
| 3124 | { |
| 3125 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3126 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 3127 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3128 | "ht_capa->extended_capabilities: %0x", |
| 3129 | StaParams->HTCap.extendedHtCapInfo); |
| 3130 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3131 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3132 | "params->capability: %0x",StaParams->capability); |
| 3133 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 3134 | "params->ext_capab_len: %0x",StaParams->extn_capability[0]); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3135 | if(StaParams->vhtcap_present) |
| 3136 | { |
| 3137 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3138 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 3139 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 3140 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 3141 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3142 | { |
| 3143 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3144 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3145 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 3146 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3147 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 3148 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3149 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3150 | else if ((1 == update) && (NULL == StaParams)) |
| 3151 | { |
| 3152 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3153 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 3154 | return -EPERM; |
| 3155 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3156 | |
| 3157 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 3158 | |
| 3159 | if (!update) |
| 3160 | { |
| 3161 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3162 | pAdapter->sessionId, mac); |
| 3163 | } |
| 3164 | else |
| 3165 | { |
| 3166 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3167 | pAdapter->sessionId, mac, StaParams); |
| 3168 | } |
| 3169 | |
| 3170 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 3171 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 3172 | |
| 3173 | if (!status) |
| 3174 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3175 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3176 | "%s: timeout waiting for tdls add station indication", |
| 3177 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3178 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3179 | } |
| 3180 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 3181 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3182 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3183 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3184 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3185 | } |
| 3186 | |
| 3187 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3188 | |
| 3189 | error: |
| 3190 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 3191 | return -EPERM; |
| 3192 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3193 | } |
| 3194 | #endif |
| 3195 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3196 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 3197 | struct net_device *dev, |
| 3198 | u8 *mac, |
| 3199 | struct station_parameters *params) |
| 3200 | { |
| 3201 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 3202 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3203 | hdd_context_t *pHddCtx; |
| 3204 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3205 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3206 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3207 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3208 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3209 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3210 | ENTER(); |
| 3211 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3212 | if ((NULL == pAdapter)) |
| 3213 | { |
| 3214 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3215 | "invalid adapter "); |
| 3216 | return -EINVAL; |
| 3217 | } |
| 3218 | |
| 3219 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3220 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3221 | |
| 3222 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 3223 | { |
| 3224 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3225 | "invalid HDD state or HDD station context"); |
| 3226 | return -EINVAL; |
| 3227 | } |
| 3228 | |
| 3229 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3230 | { |
| 3231 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3232 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3233 | return -EAGAIN; |
| 3234 | } |
| 3235 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3236 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 3237 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3238 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 3239 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3240 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3241 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3242 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3243 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3244 | WLANTL_STA_AUTHENTICATED); |
| 3245 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3246 | if (status != VOS_STATUS_SUCCESS) |
| 3247 | { |
| 3248 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3249 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3250 | return -EINVAL; |
| 3251 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3252 | } |
| 3253 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3254 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3255 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3256 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3257 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3258 | StaParams.capability = params->capability; |
| 3259 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3260 | StaParams.max_sp = params->max_sp; |
| 3261 | |
| 3262 | if (0 != params->ext_capab_len) |
| 3263 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3264 | sizeof(StaParams.extn_capability)); |
| 3265 | |
| 3266 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3267 | { |
| 3268 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3269 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3270 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3271 | |
| 3272 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3273 | |
| 3274 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3275 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3276 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3277 | * modified to send more rates. |
| 3278 | */ |
| 3279 | |
| 3280 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3281 | */ |
| 3282 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3283 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3284 | |
| 3285 | if (0 != StaParams.supported_rates_len) { |
| 3286 | int i = 0; |
| 3287 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3288 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3289 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3290 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3291 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3292 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3293 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3294 | } |
| 3295 | |
| 3296 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3297 | { |
| 3298 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3299 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3300 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3301 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3302 | if (0 != params->ext_capab_len ) { |
| 3303 | /*Define A Macro : TODO Sunil*/ |
| 3304 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3305 | isBufSta = 1; |
| 3306 | } |
| 3307 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3308 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues, |
| 3309 | params->max_sp, isBufSta); |
| 3310 | if (VOS_STATUS_SUCCESS != status) { |
| 3311 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3312 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3313 | return -EINVAL; |
| 3314 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3315 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3316 | |
| 3317 | if (VOS_STATUS_SUCCESS != status) { |
| 3318 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3319 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3320 | return -EINVAL; |
| 3321 | } |
| 3322 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3323 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3324 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3325 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3326 | return status; |
| 3327 | } |
| 3328 | |
| 3329 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3330 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3331 | * This function is used to initialize the key information |
| 3332 | */ |
| 3333 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3334 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3335 | struct net_device *ndev, |
| 3336 | u8 key_index, bool pairwise, |
| 3337 | const u8 *mac_addr, |
| 3338 | struct key_params *params |
| 3339 | ) |
| 3340 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3341 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3342 | struct net_device *ndev, |
| 3343 | u8 key_index, const u8 *mac_addr, |
| 3344 | struct key_params *params |
| 3345 | ) |
| 3346 | #endif |
| 3347 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3348 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3349 | tCsrRoamSetKey setKey; |
| 3350 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3351 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3352 | v_U32_t roamId= 0xFF; |
| 3353 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3354 | hdd_hostapd_state_t *pHostapdState; |
| 3355 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3356 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3357 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3358 | |
| 3359 | ENTER(); |
| 3360 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3361 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3362 | status = wlan_hdd_validate_context(pHddCtx); |
| 3363 | |
| 3364 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3365 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3366 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3367 | "%s: HDD context is not valid", __func__); |
| 3368 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3369 | } |
| 3370 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3371 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3372 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3373 | |
| 3374 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3375 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3376 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3377 | key_index); |
| 3378 | |
| 3379 | return -EINVAL; |
| 3380 | } |
| 3381 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3382 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3383 | { |
| 3384 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3385 | params->key_len); |
| 3386 | |
| 3387 | return -EINVAL; |
| 3388 | } |
| 3389 | |
| 3390 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3391 | "%s: called with key index = %d & key length %d", |
| 3392 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3393 | |
| 3394 | /*extract key idx, key len and key*/ |
| 3395 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3396 | setKey.keyId = key_index; |
| 3397 | setKey.keyLength = params->key_len; |
| 3398 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3399 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3400 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3401 | { |
| 3402 | case WLAN_CIPHER_SUITE_WEP40: |
| 3403 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3404 | break; |
| 3405 | |
| 3406 | case WLAN_CIPHER_SUITE_WEP104: |
| 3407 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3408 | break; |
| 3409 | |
| 3410 | case WLAN_CIPHER_SUITE_TKIP: |
| 3411 | { |
| 3412 | u8 *pKey = &setKey.Key[0]; |
| 3413 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3414 | |
| 3415 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3416 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3417 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3418 | |
| 3419 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3420 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3421 | |--------------|----------|----------| |
| 3422 | <---16bytes---><--8bytes--><--8bytes--> |
| 3423 | |
| 3424 | */ |
| 3425 | /*Sme expects the 32 bytes key to be in the below order |
| 3426 | |
| 3427 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3428 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3429 | |--------------|----------|----------| |
| 3430 | <---16bytes---><--8bytes--><--8bytes--> |
| 3431 | */ |
| 3432 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3433 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3434 | |
| 3435 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3436 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3437 | |
| 3438 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3439 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3440 | |
| 3441 | |
| 3442 | break; |
| 3443 | } |
| 3444 | |
| 3445 | case WLAN_CIPHER_SUITE_CCMP: |
| 3446 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3447 | break; |
| 3448 | |
| 3449 | #ifdef FEATURE_WLAN_WAPI |
| 3450 | case WLAN_CIPHER_SUITE_SMS4: |
| 3451 | { |
| 3452 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3453 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3454 | params->key, params->key_len); |
| 3455 | return 0; |
| 3456 | } |
| 3457 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3458 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3459 | #ifdef FEATURE_WLAN_CCX |
| 3460 | case WLAN_CIPHER_SUITE_KRK: |
| 3461 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3462 | break; |
| 3463 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3464 | |
| 3465 | #ifdef WLAN_FEATURE_11W |
| 3466 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3467 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3468 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3469 | #endif |
| 3470 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3471 | default: |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 3472 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3473 | __func__, params->cipher); |
| 3474 | return -EOPNOTSUPP; |
| 3475 | } |
| 3476 | |
| 3477 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3478 | __func__, setKey.encType); |
| 3479 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3480 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3481 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3482 | (!pairwise) |
| 3483 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3484 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3485 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3486 | ) |
| 3487 | { |
| 3488 | /* set group key*/ |
| 3489 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3490 | "%s- %d: setting Broadcast key", |
| 3491 | __func__, __LINE__); |
| 3492 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3493 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3494 | } |
| 3495 | else |
| 3496 | { |
| 3497 | /* set pairwise key*/ |
| 3498 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3499 | "%s- %d: setting pairwise key", |
| 3500 | __func__, __LINE__); |
| 3501 | setKey.keyDirection = eSIR_TX_RX; |
| 3502 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3503 | } |
| 3504 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3505 | { |
| 3506 | setKey.keyDirection = eSIR_TX_RX; |
| 3507 | /*Set the group key*/ |
| 3508 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3509 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3510 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3511 | if ( 0 != status ) |
| 3512 | { |
| 3513 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3514 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3515 | return -EINVAL; |
| 3516 | } |
| 3517 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3518 | the PTK after peer joins the IBSS network*/ |
| 3519 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3520 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3521 | return status; |
| 3522 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3523 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3524 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3525 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3526 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3527 | if( pHostapdState->bssState == BSS_START ) |
| 3528 | { |
c_hpothu | 7c55da6 | 2014-01-23 18:34:02 +0530 | [diff] [blame] | 3529 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3530 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3531 | |
| 3532 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3533 | { |
| 3534 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3535 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3536 | __LINE__, vos_status ); |
| 3537 | |
| 3538 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3539 | |
| 3540 | return -EINVAL; |
| 3541 | } |
| 3542 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3543 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3544 | |
| 3545 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3546 | { |
| 3547 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3548 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3549 | __LINE__, status ); |
| 3550 | } |
| 3551 | } |
| 3552 | |
| 3553 | /* Saving WEP keys */ |
| 3554 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3555 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3556 | { |
| 3557 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3558 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3559 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3560 | } |
| 3561 | else |
| 3562 | { |
| 3563 | //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] | 3564 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3565 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3566 | } |
| 3567 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3568 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3569 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3570 | { |
| 3571 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3572 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3573 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3574 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3575 | if (!pairwise) |
| 3576 | #else |
| 3577 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3578 | #endif |
| 3579 | { |
| 3580 | /* set group key*/ |
| 3581 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3582 | { |
| 3583 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3584 | "%s- %d: Perform Set key Complete", |
| 3585 | __func__, __LINE__); |
| 3586 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3587 | } |
| 3588 | } |
| 3589 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3590 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3591 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3592 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3593 | |
| 3594 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3595 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3596 | params->key, params->key_len); |
| 3597 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3598 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3599 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3600 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3601 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3602 | "%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] | 3603 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3604 | setKey.peerMac[2], setKey.peerMac[3], |
| 3605 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3606 | setKey.keyDirection); |
| 3607 | |
| 3608 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3609 | |
| 3610 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3611 | { |
| 3612 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3613 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3614 | __LINE__, vos_status ); |
| 3615 | |
| 3616 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3617 | |
| 3618 | return -EINVAL; |
| 3619 | |
| 3620 | } |
| 3621 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3622 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3623 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3624 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3625 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3626 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3627 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3628 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3629 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3630 | "%s: Update PreAuth Key success", __func__); |
| 3631 | return 0; |
| 3632 | } |
| 3633 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3634 | { |
| 3635 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3636 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3637 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3638 | } |
| 3639 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3640 | |
| 3641 | /* issue set key request to SME*/ |
| 3642 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3643 | pAdapter->sessionId, &setKey, &roamId ); |
| 3644 | |
| 3645 | if ( 0 != status ) |
| 3646 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3647 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3648 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3649 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3650 | return -EINVAL; |
| 3651 | } |
| 3652 | |
| 3653 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3654 | /* in case of IBSS as there was no information available about WEP keys during |
| 3655 | * 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] | 3656 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3657 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3658 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3659 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3660 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3661 | ) |
| 3662 | && |
| 3663 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3664 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3665 | ) |
| 3666 | ) |
| 3667 | { |
| 3668 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3669 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3670 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3671 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3672 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3673 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3674 | setKey.peerMac[2], setKey.peerMac[3], |
| 3675 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3676 | setKey.keyDirection); |
| 3677 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3678 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3679 | pAdapter->sessionId, &setKey, &roamId ); |
| 3680 | |
| 3681 | if ( 0 != status ) |
| 3682 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3683 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3684 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3685 | __func__, status); |
| 3686 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3687 | return -EINVAL; |
| 3688 | } |
| 3689 | } |
| 3690 | } |
| 3691 | |
| 3692 | return 0; |
| 3693 | } |
| 3694 | |
| 3695 | /* |
| 3696 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3697 | * This function is used to get the key information |
| 3698 | */ |
| 3699 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3700 | static int wlan_hdd_cfg80211_get_key( |
| 3701 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3702 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3703 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3704 | const u8 *mac_addr, void *cookie, |
| 3705 | void (*callback)(void *cookie, struct key_params*) |
| 3706 | ) |
| 3707 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3708 | static int wlan_hdd_cfg80211_get_key( |
| 3709 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3710 | struct net_device *ndev, |
| 3711 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3712 | void (*callback)(void *cookie, struct key_params*) |
| 3713 | ) |
| 3714 | #endif |
| 3715 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3716 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3717 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3718 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3719 | struct key_params params; |
| 3720 | |
| 3721 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3722 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3723 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3724 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3725 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3726 | memset(¶ms, 0, sizeof(params)); |
| 3727 | |
| 3728 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3729 | { |
| 3730 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3731 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3732 | |
| 3733 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3734 | { |
| 3735 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3736 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3737 | break; |
| 3738 | |
| 3739 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3740 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3741 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3742 | break; |
| 3743 | |
| 3744 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3745 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3746 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3747 | break; |
| 3748 | |
| 3749 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3750 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3751 | break; |
| 3752 | |
| 3753 | case eCSR_ENCRYPT_TYPE_AES: |
| 3754 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3755 | break; |
| 3756 | |
| 3757 | default: |
| 3758 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3759 | break; |
| 3760 | } |
| 3761 | |
| 3762 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3763 | params.seq_len = 0; |
| 3764 | params.seq = NULL; |
| 3765 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3766 | callback(cookie, ¶ms); |
| 3767 | return 0; |
| 3768 | } |
| 3769 | |
| 3770 | /* |
| 3771 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3772 | * This function is used to delete the key information |
| 3773 | */ |
| 3774 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3775 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3776 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3777 | u8 key_index, |
| 3778 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3779 | const u8 *mac_addr |
| 3780 | ) |
| 3781 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3782 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3783 | struct net_device *ndev, |
| 3784 | u8 key_index, |
| 3785 | const u8 *mac_addr |
| 3786 | ) |
| 3787 | #endif |
| 3788 | { |
| 3789 | int status = 0; |
| 3790 | |
| 3791 | //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] | 3792 | //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] | 3793 | //it is observed that this is invalidating peer |
| 3794 | //key index whenever re-key is done. This is affecting data link. |
| 3795 | //It should be ok to ignore del_key. |
| 3796 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3797 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3798 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3799 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3800 | tCsrRoamSetKey setKey; |
| 3801 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3802 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3803 | ENTER(); |
| 3804 | |
| 3805 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3806 | __func__,pAdapter->device_mode); |
| 3807 | |
| 3808 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3809 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3810 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3811 | key_index); |
| 3812 | |
| 3813 | return -EINVAL; |
| 3814 | } |
| 3815 | |
| 3816 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3817 | setKey.keyId = key_index; |
| 3818 | |
| 3819 | if (mac_addr) |
| 3820 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3821 | else |
| 3822 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3823 | |
| 3824 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3825 | |
| 3826 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3827 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3828 | ) |
| 3829 | { |
| 3830 | |
| 3831 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3832 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3833 | if( pHostapdState->bssState == BSS_START) |
| 3834 | { |
| 3835 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3836 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3837 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3838 | { |
| 3839 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3840 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3841 | __LINE__, status ); |
| 3842 | } |
| 3843 | } |
| 3844 | } |
| 3845 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3846 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3847 | ) |
| 3848 | { |
| 3849 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3850 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3851 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3852 | |
| 3853 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3854 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3855 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3856 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3857 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3858 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3859 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3860 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3861 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3862 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3863 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3864 | if ( 0 != status ) |
| 3865 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3866 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3867 | "%s: sme_RoamSetKey failure, returned %d", |
| 3868 | __func__, status); |
| 3869 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3870 | return -EINVAL; |
| 3871 | } |
| 3872 | } |
| 3873 | } |
| 3874 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3875 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3876 | return status; |
| 3877 | } |
| 3878 | |
| 3879 | /* |
| 3880 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3881 | * This function is used to set the default tx key index |
| 3882 | */ |
| 3883 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3884 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3885 | struct net_device *ndev, |
| 3886 | u8 key_index, |
| 3887 | bool unicast, bool multicast) |
| 3888 | #else |
| 3889 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3890 | struct net_device *ndev, |
| 3891 | u8 key_index) |
| 3892 | #endif |
| 3893 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3894 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3895 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3896 | hdd_wext_state_t *pWextState; |
| 3897 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3898 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3899 | |
| 3900 | ENTER(); |
| 3901 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3902 | if ((NULL == pAdapter)) |
| 3903 | { |
| 3904 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3905 | "invalid adapter"); |
| 3906 | return -EINVAL; |
| 3907 | } |
| 3908 | |
| 3909 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3910 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3911 | |
| 3912 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3913 | { |
| 3914 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3915 | "invalid Wext state or HDD context"); |
| 3916 | return -EINVAL; |
| 3917 | } |
| 3918 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3919 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3920 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3921 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3922 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3923 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3924 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3925 | key_index); |
| 3926 | |
| 3927 | return -EINVAL; |
| 3928 | } |
| 3929 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3930 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3931 | status = wlan_hdd_validate_context(pHddCtx); |
| 3932 | |
| 3933 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3934 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3935 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3936 | "%s: HDD context is not valid", __func__); |
| 3937 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3938 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3939 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3940 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3941 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3942 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3943 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3944 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 3945 | pHddStaCtx->conn_info.ucEncryptionType) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3946 | (eCSR_ENCRYPT_TYPE_AES != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 3947 | pHddStaCtx->conn_info.ucEncryptionType) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3948 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3949 | { |
| 3950 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3951 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3953 | tCsrRoamSetKey setKey; |
| 3954 | v_U32_t roamId= 0xFF; |
| 3955 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3956 | |
| 3957 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3958 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3959 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3960 | Keys->defaultIndex = (u8)key_index; |
| 3961 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3962 | setKey.keyId = key_index; |
| 3963 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3964 | |
| 3965 | vos_mem_copy(&setKey.Key[0], |
| 3966 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3967 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3968 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3969 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3970 | |
| 3971 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3972 | &pHddStaCtx->conn_info.bssId[0], |
| 3973 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3974 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3975 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3976 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3977 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3978 | { |
| 3979 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3980 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3981 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3982 | type(104) and switching encryption type to 40*/ |
| 3983 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3984 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3985 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3986 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3987 | } |
| 3988 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3989 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3990 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3991 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3992 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3993 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3994 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3995 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3996 | if ( 0 != status ) |
| 3997 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3998 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3999 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4000 | status); |
| 4001 | return -EINVAL; |
| 4002 | } |
| 4003 | } |
| 4004 | } |
| 4005 | |
| 4006 | /* In SoftAp mode setting key direction for default mode */ |
| 4007 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 4008 | { |
| 4009 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 4010 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 4011 | (eCSR_ENCRYPT_TYPE_AES != |
| 4012 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 4013 | ) |
| 4014 | { |
| 4015 | /* Saving key direction for default key index to TX default */ |
| 4016 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 4017 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 4018 | } |
| 4019 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4020 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4021 | return status; |
| 4022 | } |
| 4023 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4024 | /* |
| 4025 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 4026 | * This function is used to inform the BSS details to nl80211 interface. |
| 4027 | */ |
| 4028 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 4029 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 4030 | { |
| 4031 | struct net_device *dev = pAdapter->dev; |
| 4032 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 4033 | struct wiphy *wiphy = wdev->wiphy; |
| 4034 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 4035 | int chan_no; |
| 4036 | int ie_length; |
| 4037 | const char *ie; |
| 4038 | unsigned int freq; |
| 4039 | struct ieee80211_channel *chan; |
| 4040 | int rssi = 0; |
| 4041 | struct cfg80211_bss *bss = NULL; |
| 4042 | |
| 4043 | ENTER(); |
| 4044 | |
| 4045 | if( NULL == pBssDesc ) |
| 4046 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4047 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4048 | return bss; |
| 4049 | } |
| 4050 | |
| 4051 | chan_no = pBssDesc->channelId; |
| 4052 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 4053 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 4054 | |
| 4055 | if( NULL == ie ) |
| 4056 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4057 | 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] | 4058 | return bss; |
| 4059 | } |
| 4060 | |
| 4061 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 4062 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 4063 | { |
| 4064 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4065 | } |
| 4066 | else |
| 4067 | { |
| 4068 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4069 | } |
| 4070 | #else |
| 4071 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4072 | #endif |
| 4073 | |
| 4074 | chan = __ieee80211_get_channel(wiphy, freq); |
| 4075 | |
| 4076 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 4077 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 4078 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 4079 | if (bss == NULL) |
| 4080 | { |
| 4081 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 4082 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4083 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 4084 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4085 | pBssDesc->capabilityInfo, |
| 4086 | pBssDesc->beaconInterval, ie, ie_length, |
| 4087 | rssi, GFP_KERNEL )); |
| 4088 | } |
| 4089 | else |
| 4090 | { |
| 4091 | return bss; |
| 4092 | } |
| 4093 | } |
| 4094 | |
| 4095 | |
| 4096 | |
| 4097 | /* |
| 4098 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 4099 | * This function is used to inform the BSS details to nl80211 interface. |
| 4100 | */ |
| 4101 | struct cfg80211_bss* |
| 4102 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 4103 | tSirBssDescription *bss_desc |
| 4104 | ) |
| 4105 | { |
| 4106 | /* |
| 4107 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 4108 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 4109 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 4110 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 4111 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 4112 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 4113 | cfg80211_inform_bss_frame. |
| 4114 | */ |
| 4115 | struct net_device *dev = pAdapter->dev; |
| 4116 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 4117 | struct wiphy *wiphy = wdev->wiphy; |
| 4118 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4119 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4120 | qcom_ie_age *qie_age = NULL; |
| 4121 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 4122 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4123 | 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] | 4124 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4125 | const char *ie = |
| 4126 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 4127 | unsigned int freq; |
| 4128 | struct ieee80211_channel *chan; |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 4129 | struct ieee80211_mgmt *mgmt = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4130 | struct cfg80211_bss *bss_status = NULL; |
| 4131 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 4132 | int rssi = 0; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4133 | hdd_context_t *pHddCtx; |
| 4134 | int status; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4135 | #ifdef WLAN_OPEN_SOURCE |
| 4136 | struct timespec ts; |
| 4137 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4138 | |
| 4139 | ENTER(); |
| 4140 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4141 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4142 | status = wlan_hdd_validate_context(pHddCtx); |
| 4143 | |
| 4144 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
| 4145 | if (pHddCtx->isLoadUnloadInProgress) |
| 4146 | { |
| 4147 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4148 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 4149 | return NULL; |
| 4150 | } |
| 4151 | |
| 4152 | |
| 4153 | if (0 != status) |
| 4154 | { |
| 4155 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4156 | "%s: HDD context is not valid", __func__); |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4157 | return NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4158 | } |
| 4159 | |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 4160 | mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4161 | if (!mgmt) |
| 4162 | { |
| 4163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4164 | "%s: memory allocation failed ", __func__); |
| 4165 | return NULL; |
| 4166 | } |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4167 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4168 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4169 | |
| 4170 | #ifdef WLAN_OPEN_SOURCE |
| 4171 | /* Android does not want the timestamp from the frame. |
| 4172 | Instead it wants a monotonic increasing value */ |
| 4173 | get_monotonic_boottime(&ts); |
| 4174 | mgmt->u.probe_resp.timestamp = |
| 4175 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 4176 | #else |
| 4177 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4178 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 4179 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4180 | |
| 4181 | #endif |
| 4182 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4183 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 4184 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4185 | |
| 4186 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4187 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 4188 | /* Assuming this is the last IE, copy at the end */ |
| 4189 | ie_length -=sizeof(qcom_ie_age); |
| 4190 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 4191 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 4192 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 4193 | qie_age->oui_1 = QCOM_OUI1; |
| 4194 | qie_age->oui_2 = QCOM_OUI2; |
| 4195 | qie_age->oui_3 = QCOM_OUI3; |
| 4196 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 4197 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 4198 | #endif |
| 4199 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4200 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 4201 | if (bss_desc->fProbeRsp) |
| 4202 | { |
| 4203 | mgmt->frame_control |= |
| 4204 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 4205 | } |
| 4206 | else |
| 4207 | { |
| 4208 | mgmt->frame_control |= |
| 4209 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 4210 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4211 | |
| 4212 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4213 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4214 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 4215 | { |
| 4216 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4217 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4218 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4219 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 4220 | |
| 4221 | { |
| 4222 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4223 | } |
| 4224 | else |
| 4225 | { |
| 4226 | kfree(mgmt); |
| 4227 | return NULL; |
| 4228 | } |
| 4229 | #else |
| 4230 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4231 | #endif |
| 4232 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4233 | /*when the band is changed on the fly using the GUI, three things are done |
| 4234 | * 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) |
| 4235 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 4236 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 4237 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 4238 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 4239 | * 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 |
| 4240 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 4241 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 4242 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 4243 | * So drop the bss and continue to next bss. |
| 4244 | */ |
| 4245 | if(chan == NULL) |
| 4246 | { |
| 4247 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 4248 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4249 | return NULL; |
| 4250 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4251 | /*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] | 4252 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4253 | * */ |
| 4254 | if (( eConnectionState_Associated == |
| 4255 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4256 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4257 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4258 | WNI_CFG_BSSID_LEN))) |
| 4259 | { |
| 4260 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4261 | rssi = (pAdapter->rssi * 100); |
| 4262 | } |
| 4263 | else |
| 4264 | { |
| 4265 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4266 | } |
| 4267 | |
| 4268 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4269 | frame_len, rssi, GFP_KERNEL); |
| 4270 | kfree(mgmt); |
| 4271 | return bss_status; |
| 4272 | } |
| 4273 | |
| 4274 | /* |
| 4275 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4276 | * This function is used to update the BSS data base of CFG8011 |
| 4277 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4278 | 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] | 4279 | tCsrRoamInfo *pRoamInfo |
| 4280 | ) |
| 4281 | { |
| 4282 | tCsrRoamConnectedProfile roamProfile; |
| 4283 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4284 | struct cfg80211_bss *bss = NULL; |
| 4285 | |
| 4286 | ENTER(); |
| 4287 | |
| 4288 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4289 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4290 | |
| 4291 | if (NULL != roamProfile.pBssDesc) |
| 4292 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4293 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4294 | &roamProfile); |
| 4295 | |
| 4296 | if (NULL == bss) |
| 4297 | { |
| 4298 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4299 | __func__); |
| 4300 | } |
| 4301 | |
| 4302 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4303 | } |
| 4304 | else |
| 4305 | { |
| 4306 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4307 | __func__); |
| 4308 | } |
| 4309 | return bss; |
| 4310 | } |
| 4311 | |
| 4312 | /* |
| 4313 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4314 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4315 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4316 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4317 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4318 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4319 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4320 | tCsrScanResultInfo *pScanResult; |
| 4321 | eHalStatus status = 0; |
| 4322 | tScanResultHandle pResult; |
| 4323 | struct cfg80211_bss *bss_status = NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4324 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4325 | |
| 4326 | ENTER(); |
| 4327 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4328 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4329 | |
| 4330 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4331 | { |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4333 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4334 | return -EAGAIN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4335 | } |
| 4336 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4337 | |
| 4338 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
| 4339 | if (pHddCtx->isLoadUnloadInProgress) |
| 4340 | { |
| 4341 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4342 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 4343 | return VOS_STATUS_E_PERM; |
| 4344 | } |
| 4345 | |
| 4346 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4347 | /* |
| 4348 | * start getting scan results and populate cgf80211 BSS database |
| 4349 | */ |
| 4350 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4351 | |
| 4352 | /* no scan results */ |
| 4353 | if (NULL == pResult) |
| 4354 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4355 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4356 | return status; |
| 4357 | } |
| 4358 | |
| 4359 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4360 | |
| 4361 | while (pScanResult) |
| 4362 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4363 | /* |
| 4364 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4365 | * entry already exists in bss data base of cfg80211 for that |
| 4366 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4367 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4368 | * mgmt packet as input. As of now there is no possibility to get |
| 4369 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4370 | * ieee80211_mgmt(probe response) and passing to c |
| 4371 | * fg80211_inform_bss_frame. |
| 4372 | * */ |
| 4373 | |
| 4374 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4375 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4376 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4377 | |
| 4378 | if (NULL == bss_status) |
| 4379 | { |
| 4380 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4381 | "%s: NULL returned by cfg80211_inform_bss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4382 | } |
| 4383 | else |
| 4384 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4385 | cfg80211_put_bss( |
| 4386 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 4387 | wiphy, |
| 4388 | #endif |
| 4389 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4390 | } |
| 4391 | |
| 4392 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4393 | } |
| 4394 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4395 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4396 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4397 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4398 | } |
| 4399 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4400 | void |
| 4401 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4402 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4403 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 4404 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4405 | } /****** end hddPrintMacAddr() ******/ |
| 4406 | |
| 4407 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4408 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4409 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4410 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4411 | "%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] | 4412 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4413 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4414 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4415 | } /****** end hddPrintPmkId() ******/ |
| 4416 | |
| 4417 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4418 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4419 | |
| 4420 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4421 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4422 | |
| 4423 | #define dump_bssid(bssid) \ |
| 4424 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4425 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4426 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4427 | } |
| 4428 | |
| 4429 | #define dump_pmkid(pMac, pmkid) \ |
| 4430 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4431 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4432 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4433 | } |
| 4434 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4435 | #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] | 4436 | /* |
| 4437 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4438 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4439 | */ |
| 4440 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4441 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4442 | int index, bool preauth ) |
| 4443 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4444 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4445 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4446 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4447 | |
| 4448 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4449 | 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] | 4450 | |
| 4451 | if( NULL == pRoamInfo ) |
| 4452 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4453 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4454 | return -EINVAL; |
| 4455 | } |
| 4456 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4457 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4458 | { |
| 4459 | dump_bssid(pRoamInfo->bssid); |
| 4460 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4461 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4462 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4463 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4464 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4465 | } |
| 4466 | #endif //FEATURE_WLAN_LFR |
| 4467 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 4468 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 4469 | /* |
| 4470 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth |
| 4471 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 4472 | * |
| 4473 | */ |
| 4474 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
| 4475 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
| 4476 | tCsrRoamInfo *pRoamInfo) |
| 4477 | { |
| 4478 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4479 | union iwreq_data wrqu; |
| 4480 | |
| 4481 | ENTER(); |
| 4482 | |
| 4483 | if (NULL == pAdapter) |
| 4484 | { |
| 4485 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4486 | return VOS_STATUS_E_FAILURE; |
| 4487 | } |
| 4488 | |
| 4489 | /* create the event */ |
| 4490 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4491 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4492 | |
| 4493 | wrqu.data.pointer = metrics_notification; |
| 4494 | wrqu.data.length = scnprintf(metrics_notification, |
| 4495 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT " |
| 4496 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4497 | |
| 4498 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4499 | |
| 4500 | EXIT(); |
| 4501 | |
| 4502 | return VOS_STATUS_SUCCESS; |
| 4503 | } |
| 4504 | |
| 4505 | /* |
| 4506 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status |
| 4507 | * 802.11r/LFR metrics reporting function to report preauth completion |
| 4508 | * or failure |
| 4509 | */ |
| 4510 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status( |
| 4511 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status) |
| 4512 | { |
| 4513 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4514 | union iwreq_data wrqu; |
| 4515 | |
| 4516 | ENTER(); |
| 4517 | |
| 4518 | if (NULL == pAdapter) |
| 4519 | { |
| 4520 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4521 | return VOS_STATUS_E_FAILURE; |
| 4522 | } |
| 4523 | |
| 4524 | /* create the event */ |
| 4525 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4526 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4527 | |
| 4528 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 4529 | "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR, |
| 4530 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4531 | |
| 4532 | if (1 == preauth_status) |
| 4533 | strncat(metrics_notification, " TRUE", 5); |
| 4534 | else |
| 4535 | strncat(metrics_notification, " FALSE", 6); |
| 4536 | |
| 4537 | wrqu.data.pointer = metrics_notification; |
| 4538 | wrqu.data.length = strlen(metrics_notification); |
| 4539 | |
| 4540 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4541 | |
| 4542 | EXIT(); |
| 4543 | |
| 4544 | return VOS_STATUS_SUCCESS; |
| 4545 | } |
| 4546 | |
| 4547 | /* |
| 4548 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover |
| 4549 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 4550 | * |
| 4551 | */ |
| 4552 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter, |
| 4553 | tCsrRoamInfo *pRoamInfo) |
| 4554 | { |
| 4555 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4556 | union iwreq_data wrqu; |
| 4557 | |
| 4558 | ENTER(); |
| 4559 | |
| 4560 | if (NULL == pAdapter) |
| 4561 | { |
| 4562 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4563 | return VOS_STATUS_E_FAILURE; |
| 4564 | } |
| 4565 | |
| 4566 | /* create the event */ |
| 4567 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4568 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4569 | |
| 4570 | wrqu.data.pointer = metrics_notification; |
| 4571 | wrqu.data.length = scnprintf(metrics_notification, |
| 4572 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER " |
| 4573 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4574 | |
| 4575 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4576 | |
| 4577 | EXIT(); |
| 4578 | |
| 4579 | return VOS_STATUS_SUCCESS; |
| 4580 | } |
| 4581 | #endif |
| 4582 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4583 | /* |
| 4584 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4585 | * scanning callback function, called after finishing scan |
| 4586 | * |
| 4587 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4588 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4589 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4590 | { |
| 4591 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4592 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4593 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4594 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4595 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4596 | struct cfg80211_scan_request *req = NULL; |
| 4597 | int ret = 0; |
| 4598 | |
| 4599 | ENTER(); |
| 4600 | |
| 4601 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4602 | "%s called with halHandle = %p, pContext = %p," |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4603 | "scanID = %d, returned status = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4604 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4605 | |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4606 | pScanInfo->mScanPendingCounter = 0; |
| 4607 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4608 | //Block on scan req completion variable. Can't wait forever though. |
| 4609 | ret = wait_for_completion_interruptible_timeout( |
| 4610 | &pScanInfo->scan_req_completion_event, |
| 4611 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4612 | if (!ret) |
| 4613 | { |
| 4614 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4615 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4616 | } |
| 4617 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 4618 | if (pScanInfo->mScanPending != VOS_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4619 | { |
| 4620 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4621 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4622 | } |
| 4623 | |
| 4624 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4625 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4626 | { |
| 4627 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4628 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4629 | "scanId = %d", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4630 | (int) scanId); |
| 4631 | } |
| 4632 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4633 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4634 | pAdapter); |
| 4635 | |
| 4636 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4637 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4638 | |
| 4639 | |
| 4640 | /* If any client wait scan result through WEXT |
| 4641 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4642 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4643 | { |
| 4644 | /* The other scan request waiting for current scan finish |
| 4645 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4646 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4647 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4648 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4649 | } |
| 4650 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4651 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4652 | { |
| 4653 | struct net_device *dev = pAdapter->dev; |
| 4654 | union iwreq_data wrqu; |
| 4655 | int we_event; |
| 4656 | char *msg; |
| 4657 | |
| 4658 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4659 | we_event = SIOCGIWSCAN; |
| 4660 | msg = NULL; |
| 4661 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4662 | } |
| 4663 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4664 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4665 | |
| 4666 | /* Get the Scan Req */ |
| 4667 | req = pAdapter->request; |
| 4668 | |
| 4669 | if (!req) |
| 4670 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4671 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4672 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4673 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4674 | } |
| 4675 | |
| 4676 | /* |
| 4677 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4678 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4679 | req->n_ssids = 0; |
| 4680 | req->n_channels = 0; |
| 4681 | req->ie = 0; |
| 4682 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4683 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4684 | /* Scan is no longer pending */ |
| 4685 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4686 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4687 | /* |
| 4688 | * cfg80211_scan_done informing NL80211 about completion |
| 4689 | * of scanning |
| 4690 | */ |
| 4691 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4692 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4693 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4694 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4695 | /* release the wake lock at the end of the scan*/ |
| 4696 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4697 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4698 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4699 | * immediatly after the driver gets connect request(i.e after scan) |
| 4700 | * from supplicant, this result in app's is suspending and not able |
| 4701 | * to process the connect request to AP */ |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 4702 | hdd_prevent_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4703 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4704 | #ifdef FEATURE_WLAN_TDLS |
| 4705 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4706 | #endif |
| 4707 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4708 | EXIT(); |
| 4709 | return 0; |
| 4710 | } |
| 4711 | |
| 4712 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4713 | * FUNCTION: hdd_isScanAllowed |
| 4714 | * Go through each adapter and check if scan allowed |
| 4715 | * |
| 4716 | */ |
| 4717 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4718 | { |
| 4719 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4720 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4721 | hdd_adapter_t *pAdapter = NULL; |
| 4722 | VOS_STATUS status = 0; |
| 4723 | v_U8_t staId = 0; |
| 4724 | v_U8_t *staMac = NULL; |
| 4725 | |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 4726 | if (TRUE == pHddCtx->btCoexModeSet) |
| 4727 | { |
| 4728 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4729 | FL("BTCoex Mode operation in progress, Do not allow scan")); |
| 4730 | return VOS_FALSE; |
| 4731 | } |
| 4732 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4733 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4734 | |
| 4735 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4736 | { |
| 4737 | pAdapter = pAdapterNode->pAdapter; |
| 4738 | |
| 4739 | if( pAdapter ) |
| 4740 | { |
| 4741 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4742 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4743 | __func__, pAdapter->device_mode); |
| 4744 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4745 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4746 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4747 | { |
| 4748 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4749 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4750 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4751 | { |
| 4752 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4753 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4754 | "%s: client " MAC_ADDRESS_STR |
| 4755 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 4756 | MAC_ADDR_ARRAY(staMac)); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4757 | return VOS_FALSE; |
| 4758 | } |
| 4759 | } |
| 4760 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4761 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4762 | { |
| 4763 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4764 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4765 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4766 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4767 | { |
| 4768 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4769 | |
| 4770 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4771 | "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the " |
| 4772 | "middle of WPS/EAPOL exchange.", __func__, |
| 4773 | MAC_ADDR_ARRAY(staMac)); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4774 | return VOS_FALSE; |
| 4775 | } |
| 4776 | } |
| 4777 | } |
| 4778 | } |
| 4779 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4780 | pAdapterNode = pNext; |
| 4781 | } |
| 4782 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4783 | "%s: Scan allowed", __func__); |
| 4784 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4785 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4786 | |
| 4787 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4788 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4789 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4790 | * later, scan dump command can be used to recieve scan results |
| 4791 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4792 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4793 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4794 | struct net_device *dev, |
| 4795 | #endif |
| 4796 | struct cfg80211_scan_request *request) |
| 4797 | { |
| 4798 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4799 | struct net_device *dev = request->wdev->netdev; |
| 4800 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4801 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4802 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4803 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4804 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4805 | tCsrScanRequest scanRequest; |
| 4806 | tANI_U8 *channelList = NULL, i; |
| 4807 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4808 | int status; |
| 4809 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4810 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4811 | |
| 4812 | ENTER(); |
| 4813 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4814 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4815 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4816 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4817 | status = wlan_hdd_validate_context(pHddCtx); |
| 4818 | |
| 4819 | if (0 != status) |
| 4820 | { |
| 4821 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4822 | "%s: HDD context is not valid", __func__); |
| 4823 | return status; |
| 4824 | } |
| 4825 | |
| 4826 | cfg_param = pHddCtx->cfg_ini; |
| 4827 | pScanInfo = &pHddCtx->scan_info; |
| 4828 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4829 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4830 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4831 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4832 | { |
| 4833 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4834 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4835 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4836 | return -EBUSY; |
| 4837 | } |
| 4838 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4839 | #ifdef WLAN_BTAMP_FEATURE |
| 4840 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4841 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4842 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4843 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4844 | "%s: No scanning when AMP is on", __func__); |
| 4845 | return -EOPNOTSUPP; |
| 4846 | } |
| 4847 | #endif |
| 4848 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4849 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4850 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4851 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4852 | "%s: Not scanning on device_mode = %d", |
| 4853 | __func__, pAdapter->device_mode); |
| 4854 | return -EOPNOTSUPP; |
| 4855 | } |
| 4856 | |
| 4857 | if (TRUE == pScanInfo->mScanPending) |
| 4858 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4859 | if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ ) |
| 4860 | { |
| 4861 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__); |
| 4862 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4863 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4864 | } |
| 4865 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4866 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4867 | //Channel and action frame is pending |
| 4868 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4869 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4870 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4871 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4872 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4873 | return -EBUSY; |
| 4874 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4875 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4876 | /* if tdls disagree scan right now, return immediately. |
| 4877 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4878 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4879 | */ |
| 4880 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4881 | wiphy, |
| 4882 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4883 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4884 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4885 | request); |
| 4886 | if(status <= 0) |
| 4887 | { |
| 4888 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4889 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4890 | } |
| 4891 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4892 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4893 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4894 | { |
| 4895 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4896 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4897 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4898 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4899 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4900 | { |
| 4901 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4902 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4903 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4904 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4905 | } |
| 4906 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4907 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4908 | /* Check if scan is allowed at this point of time. |
| 4909 | */ |
| 4910 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4911 | { |
| 4912 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4913 | return -EBUSY; |
| 4914 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4915 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4916 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4917 | |
| 4918 | if (NULL != request) |
| 4919 | { |
| 4920 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4921 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4922 | |
| 4923 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4924 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4925 | * is not aging out the scan results. |
| 4926 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4927 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4928 | { |
| 4929 | request->n_ssids = 0; |
| 4930 | } |
| 4931 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4932 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4933 | { |
| 4934 | tCsrSSIDInfo *SsidInfo; |
| 4935 | int j; |
| 4936 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4937 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4938 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4939 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4940 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4941 | |
| 4942 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4943 | { |
| 4944 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4945 | "memory alloc failed SSIDInfo buffer"); |
| 4946 | return -ENOMEM; |
| 4947 | } |
| 4948 | |
| 4949 | /* copy all the ssid's and their length */ |
| 4950 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4951 | { |
| 4952 | /* get the ssid length */ |
| 4953 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4954 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4955 | SsidInfo->SSID.length); |
| 4956 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4957 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4958 | j, SsidInfo->SSID.ssId); |
| 4959 | } |
| 4960 | /* set the scan type to active */ |
| 4961 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4962 | } |
| 4963 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4964 | { |
| 4965 | /* set the scan type to active */ |
| 4966 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4967 | } |
| 4968 | else |
| 4969 | { |
| 4970 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4971 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4972 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4973 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4974 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4975 | } |
| 4976 | else |
| 4977 | { |
| 4978 | /* set the scan type to active */ |
| 4979 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4980 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4981 | |
| 4982 | /* set min and max channel time to zero */ |
| 4983 | scanRequest.minChnTime = 0; |
| 4984 | scanRequest.maxChnTime = 0; |
| 4985 | } |
| 4986 | |
| 4987 | /* set BSSType to default type */ |
| 4988 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4989 | |
| 4990 | /*TODO: scan the requested channels only*/ |
| 4991 | |
| 4992 | /*Right now scanning all the channels */ |
| 4993 | if( request ) |
| 4994 | { |
| 4995 | if( request->n_channels ) |
| 4996 | { |
| 4997 | channelList = vos_mem_malloc( request->n_channels ); |
| 4998 | if( NULL == channelList ) |
| 4999 | { |
| 5000 | status = -ENOMEM; |
| 5001 | goto free_mem; |
| 5002 | } |
| 5003 | |
| 5004 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 5005 | channelList[i] = request->channels[i]->hw_value; |
| 5006 | } |
| 5007 | |
| 5008 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 5009 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 5010 | |
| 5011 | /* set requestType to full scan */ |
| 5012 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5013 | |
| 5014 | /* Flush the scan results(only p2p beacons) for STA scan and P2P |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 5015 | * search (Flush on both full scan and social scan but not on single |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5016 | * channel scan).P2P search happens on 3 social channels (1, 6, 11) |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 5017 | */ |
| 5018 | |
| 5019 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5020 | * and in that case driver shoudnt flush scan results. If |
| 5021 | * driver flushes the scan results here and unfortunately if |
| 5022 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 5023 | * fails which is not desired |
| 5024 | */ |
| 5025 | |
| 5026 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 5027 | { |
| 5028 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5029 | pAdapter->sessionId ); |
| 5030 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5031 | |
| 5032 | if( request->ie_len ) |
| 5033 | { |
| 5034 | /* save this for future association (join requires this) */ |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5035 | /*TODO: Array needs to be converted to dynamic allocation, |
| 5036 | * as multiple ie.s can be sent in cfg80211_scan_request structure |
| 5037 | * CR 597966 |
| 5038 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5039 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 5040 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 5041 | pScanInfo->scanAddIE.length = request->ie_len; |
| 5042 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5043 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5044 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5045 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5046 | { |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5047 | if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH) |
| 5048 | { |
| 5049 | pwextBuf->roamProfile.nAddIEScanLength = request->ie_len; |
| 5050 | memcpy( pwextBuf->roamProfile.addIEScan, |
| 5051 | request->ie, request->ie_len); |
| 5052 | } |
| 5053 | else |
| 5054 | { |
| 5055 | hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:" |
| 5056 | "%d", request->ie_len); |
| 5057 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5058 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5059 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5060 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 5061 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 5062 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5063 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 5064 | request->ie_len); |
| 5065 | if (pP2pIe != NULL) |
| 5066 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 5067 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 5068 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 5069 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 5070 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5071 | { |
| 5072 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 5073 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 5074 | "Go nego completed to Connection is started"); |
| 5075 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 5076 | "for 8way Handshake"); |
| 5077 | } |
| 5078 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 5079 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5080 | { |
| 5081 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 5082 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 5083 | "Disconnected state to Connection is started"); |
| 5084 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 5085 | "for 4way Handshake"); |
| 5086 | } |
| 5087 | #endif |
| 5088 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5089 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 5090 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5091 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5092 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5093 | "%s: This is a P2P Search", __func__); |
| 5094 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5095 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5096 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 5097 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 5098 | /* set requestType to P2P Discovery */ |
| 5099 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5100 | } |
| 5101 | |
| 5102 | /* |
| 5103 | Skip Dfs Channel in case of P2P Search |
| 5104 | if it is set in ini file |
| 5105 | */ |
| 5106 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 5107 | { |
| 5108 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 5109 | } |
| 5110 | else |
| 5111 | { |
| 5112 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 5113 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5114 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5115 | } |
| 5116 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5117 | } |
| 5118 | } |
| 5119 | |
| 5120 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 5121 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 5122 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 5123 | * address the following issues. |
| 5124 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 5125 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 5126 | * for long time, this result in apps running at full power for long time. |
| 5127 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 5128 | * be stuck in full power because of resume BMPS |
| 5129 | */ |
| 5130 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5131 | |
| 5132 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5133 | pAdapter->sessionId, &scanRequest, &scanId, |
| 5134 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5136 | if (eHAL_STATUS_SUCCESS != status) |
| 5137 | { |
| 5138 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5139 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 5140 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 5141 | if(eHAL_STATUS_RESOURCES == status) |
| 5142 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 5143 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: HO is in progress.So defer the scan by informing busy",__func__); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 5144 | status = -EBUSY; |
| 5145 | } else { |
| 5146 | status = -EIO; |
| 5147 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 5148 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5149 | goto free_mem; |
| 5150 | } |
| 5151 | |
| 5152 | pScanInfo->mScanPending = TRUE; |
| 5153 | pAdapter->request = request; |
| 5154 | pScanInfo->scanId = scanId; |
| 5155 | |
| 5156 | complete(&pScanInfo->scan_req_completion_event); |
| 5157 | |
| 5158 | free_mem: |
| 5159 | if( scanRequest.SSIDs.SSIDList ) |
| 5160 | { |
| 5161 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 5162 | } |
| 5163 | |
| 5164 | if( channelList ) |
| 5165 | vos_mem_free( channelList ); |
| 5166 | |
| 5167 | EXIT(); |
| 5168 | |
| 5169 | return status; |
| 5170 | } |
| 5171 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5172 | |
| 5173 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 5174 | { |
| 5175 | v_U8_t iniDot11Mode = |
| 5176 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 5177 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 5178 | |
| 5179 | switch ( iniDot11Mode ) |
| 5180 | { |
| 5181 | case eHDD_DOT11_MODE_AUTO: |
| 5182 | case eHDD_DOT11_MODE_11ac: |
| 5183 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 5184 | #ifdef WLAN_FEATURE_11AC |
| 5185 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 5186 | #else |
| 5187 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 5188 | #endif |
| 5189 | break; |
| 5190 | case eHDD_DOT11_MODE_11n: |
| 5191 | case eHDD_DOT11_MODE_11n_ONLY: |
| 5192 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 5193 | break; |
| 5194 | default: |
| 5195 | hddDot11Mode = iniDot11Mode; |
| 5196 | break; |
| 5197 | } |
| 5198 | /* This call decides required channel bonding mode */ |
| 5199 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 5200 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 5201 | operationChannel); |
| 5202 | } |
| 5203 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5204 | /* |
| 5205 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5206 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5207 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5208 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5209 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5210 | { |
| 5211 | int status = 0; |
| 5212 | hdd_wext_state_t *pWextState; |
| 5213 | v_U32_t roamId; |
| 5214 | tCsrRoamProfile *pRoamProfile; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5215 | eCsrAuthType RSNAuthType; |
| 5216 | |
| 5217 | ENTER(); |
| 5218 | |
| 5219 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5220 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5221 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 5222 | { |
| 5223 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 5224 | return -EINVAL; |
| 5225 | } |
| 5226 | |
| 5227 | pRoamProfile = &pWextState->roamProfile; |
| 5228 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5229 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5230 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5231 | hdd_station_ctx_t *pHddStaCtx; |
| 5232 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5233 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5234 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5235 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 5236 | { |
| 5237 | /*QoS not enabled in cfg file*/ |
| 5238 | pRoamProfile->uapsd_mask = 0; |
| 5239 | } |
| 5240 | else |
| 5241 | { |
| 5242 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5243 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5244 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 5245 | } |
| 5246 | |
| 5247 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 5248 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 5249 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5250 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5251 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 5252 | ssid, ssid_len); |
| 5253 | |
| 5254 | if (bssid) |
| 5255 | { |
| 5256 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 5257 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 5258 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5259 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 5260 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5261 | case of join failure we should send valid BSSID to supplicant |
| 5262 | */ |
| 5263 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 5264 | WNI_CFG_BSSID_LEN); |
| 5265 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 5266 | else |
| 5267 | { |
| 5268 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 5269 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5270 | |
| 5271 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 5272 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5273 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5274 | /*set gen ie*/ |
| 5275 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 5276 | /*set auth*/ |
| 5277 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 5278 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5279 | #ifdef FEATURE_WLAN_WAPI |
| 5280 | if (pAdapter->wapi_info.nWapiMode) |
| 5281 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5282 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5283 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 5284 | { |
| 5285 | case WAPI_AUTH_MODE_PSK: |
| 5286 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5287 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5288 | pAdapter->wapi_info.wapiAuthMode); |
| 5289 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5290 | break; |
| 5291 | } |
| 5292 | case WAPI_AUTH_MODE_CERT: |
| 5293 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5294 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5295 | pAdapter->wapi_info.wapiAuthMode); |
| 5296 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5297 | break; |
| 5298 | } |
| 5299 | } // End of switch |
| 5300 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 5301 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 5302 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5303 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5304 | pRoamProfile->AuthType.numEntries = 1; |
| 5305 | pRoamProfile->EncryptionType.numEntries = 1; |
| 5306 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5307 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 5308 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5309 | } |
| 5310 | } |
| 5311 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5312 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5313 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5314 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5315 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5316 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5317 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 5318 | sizeof (tSirGtkOffloadParams)); |
| 5319 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5320 | } |
| 5321 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5322 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 5323 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5324 | if( operatingChannel ) |
| 5325 | { |
| 5326 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 5327 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5328 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5329 | else |
| 5330 | { |
| 5331 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5332 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5333 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5334 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 5335 | { |
| 5336 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 5337 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5338 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 5339 | * 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] | 5340 | * 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] | 5341 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5342 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 5343 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5344 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5345 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5346 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 5347 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5348 | |
| 5349 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5350 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 5351 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5352 | if ((eHAL_STATUS_SUCCESS != status) && |
| 5353 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5354 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5355 | |
| 5356 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5357 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 5358 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 5359 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5360 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5361 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5362 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5363 | |
| 5364 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5365 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5366 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5367 | } |
| 5368 | else |
| 5369 | { |
| 5370 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 5371 | return -EINVAL; |
| 5372 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5373 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5374 | return status; |
| 5375 | } |
| 5376 | |
| 5377 | /* |
| 5378 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 5379 | * This function is used to set the authentication type (OPEN/SHARED). |
| 5380 | * |
| 5381 | */ |
| 5382 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 5383 | enum nl80211_auth_type auth_type) |
| 5384 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5385 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5386 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5387 | |
| 5388 | ENTER(); |
| 5389 | |
| 5390 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5391 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5392 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5393 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5394 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5395 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 5396 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5397 | break; |
| 5398 | |
| 5399 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5400 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5401 | case NL80211_AUTHTYPE_FT: |
| 5402 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5403 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5404 | "%s: set authentication type to OPEN", __func__); |
| 5405 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5406 | break; |
| 5407 | |
| 5408 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5409 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5410 | "%s: set authentication type to SHARED", __func__); |
| 5411 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5412 | break; |
| 5413 | #ifdef FEATURE_WLAN_CCX |
| 5414 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5415 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5416 | "%s: set authentication type to CCKM WPA", __func__); |
| 5417 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5418 | break; |
| 5419 | #endif |
| 5420 | |
| 5421 | |
| 5422 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5423 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5424 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5425 | auth_type); |
| 5426 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5427 | return -EINVAL; |
| 5428 | } |
| 5429 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5430 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5431 | pHddStaCtx->conn_info.authType; |
| 5432 | return 0; |
| 5433 | } |
| 5434 | |
| 5435 | /* |
| 5436 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5437 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5438 | * |
| 5439 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5440 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5441 | u32 key_mgmt |
| 5442 | ) |
| 5443 | { |
| 5444 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5445 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5446 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5447 | /*set key mgmt type*/ |
| 5448 | switch(key_mgmt) |
| 5449 | { |
| 5450 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5451 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5452 | case WLAN_AKM_SUITE_FT_PSK: |
| 5453 | #endif |
| 5454 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5455 | __func__); |
| 5456 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5457 | break; |
| 5458 | |
| 5459 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5460 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5461 | case WLAN_AKM_SUITE_FT_8021X: |
| 5462 | #endif |
| 5463 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5464 | __func__); |
| 5465 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5466 | break; |
| 5467 | #ifdef FEATURE_WLAN_CCX |
| 5468 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5469 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5470 | case WLAN_AKM_SUITE_CCKM: |
| 5471 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5472 | __func__); |
| 5473 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5474 | break; |
| 5475 | #endif |
| 5476 | |
| 5477 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5478 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5479 | __func__, key_mgmt); |
| 5480 | return -EINVAL; |
| 5481 | |
| 5482 | } |
| 5483 | return 0; |
| 5484 | } |
| 5485 | |
| 5486 | /* |
| 5487 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5488 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5489 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5490 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5491 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5492 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5493 | bool ucast |
| 5494 | ) |
| 5495 | { |
| 5496 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5497 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5498 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5499 | |
| 5500 | ENTER(); |
| 5501 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5502 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5503 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5504 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5505 | __func__, cipher); |
| 5506 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5507 | } |
| 5508 | else |
| 5509 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5510 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5511 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5512 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5513 | { |
| 5514 | case IW_AUTH_CIPHER_NONE: |
| 5515 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5516 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5517 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5518 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5519 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5520 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5522 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5523 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5524 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5525 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5526 | case WLAN_CIPHER_SUITE_TKIP: |
| 5527 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5528 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5529 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5530 | case WLAN_CIPHER_SUITE_CCMP: |
| 5531 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5532 | break; |
| 5533 | #ifdef FEATURE_WLAN_WAPI |
| 5534 | case WLAN_CIPHER_SUITE_SMS4: |
| 5535 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5536 | break; |
| 5537 | #endif |
| 5538 | |
| 5539 | #ifdef FEATURE_WLAN_CCX |
| 5540 | case WLAN_CIPHER_SUITE_KRK: |
| 5541 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5542 | break; |
| 5543 | #endif |
| 5544 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5545 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5546 | __func__, cipher); |
| 5547 | return -EOPNOTSUPP; |
| 5548 | } |
| 5549 | } |
| 5550 | |
| 5551 | if (ucast) |
| 5552 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5553 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5554 | __func__, encryptionType); |
| 5555 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5556 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5557 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5558 | encryptionType; |
| 5559 | } |
| 5560 | else |
| 5561 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5562 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5563 | __func__, encryptionType); |
| 5564 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5565 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5566 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5567 | } |
| 5568 | |
| 5569 | return 0; |
| 5570 | } |
| 5571 | |
| 5572 | |
| 5573 | /* |
| 5574 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5575 | * This function is used to parse WPA/RSN IE's. |
| 5576 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5577 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5578 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5579 | size_t ie_len |
| 5580 | ) |
| 5581 | { |
| 5582 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5583 | u8 *genie = ie; |
| 5584 | v_U16_t remLen = ie_len; |
| 5585 | #ifdef FEATURE_WLAN_WAPI |
| 5586 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5587 | u16 *tmp; |
| 5588 | v_U16_t akmsuiteCount; |
| 5589 | int *akmlist; |
| 5590 | #endif |
| 5591 | ENTER(); |
| 5592 | |
| 5593 | /* clear previous assocAddIE */ |
| 5594 | pWextState->assocAddIE.length = 0; |
| 5595 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5596 | |
| 5597 | while (remLen >= 2) |
| 5598 | { |
| 5599 | v_U16_t eLen = 0; |
| 5600 | v_U8_t elementId; |
| 5601 | elementId = *genie++; |
| 5602 | eLen = *genie++; |
| 5603 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5604 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5605 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5606 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5607 | |
| 5608 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5609 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5610 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5611 | 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] | 5612 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5613 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5614 | "%s: Invalid WPA IE", __func__); |
| 5615 | return -EINVAL; |
| 5616 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5617 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5618 | { |
| 5619 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5620 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5621 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5622 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5623 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5624 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5625 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5626 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5627 | VOS_ASSERT(0); |
| 5628 | return -ENOMEM; |
| 5629 | } |
| 5630 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5631 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5632 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5633 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5634 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5635 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5636 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5637 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5638 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5639 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5640 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5641 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5642 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5643 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5644 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5645 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5646 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
Kiet Lam | 8da9899 | 2013-11-21 15:59:07 +0530 | [diff] [blame] | 5647 | P2P_OUI_TYPE_SIZE))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5648 | { |
| 5649 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5650 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5651 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5652 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5653 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5654 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5655 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5656 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5657 | VOS_ASSERT(0); |
| 5658 | return -ENOMEM; |
| 5659 | } |
| 5660 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5661 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5662 | pWextState->assocAddIE.length += eLen + 2; |
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 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5665 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5666 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5667 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5668 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5669 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5670 | /*Consider WFD IE, only for P2P Client */ |
| 5671 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5672 | { |
| 5673 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5674 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5675 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5676 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5677 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5678 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5679 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5680 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5681 | VOS_ASSERT(0); |
| 5682 | return -ENOMEM; |
| 5683 | } |
| 5684 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5685 | // WPS IE + P2P IE + WFD IE |
| 5686 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5687 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5688 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5689 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5690 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5691 | } |
| 5692 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5693 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5694 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5695 | HS20_OUI_TYPE_SIZE)) ) |
| 5696 | { |
| 5697 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5698 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5699 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5700 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5701 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5702 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5703 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5704 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5705 | VOS_ASSERT(0); |
| 5706 | return -ENOMEM; |
| 5707 | } |
| 5708 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5709 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5710 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5711 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5712 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5713 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5714 | |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 5715 | if (WLAN_HDD_IBSS == pAdapter->device_mode) { |
| 5716 | |
| 5717 | /* populating as ADDIE in beacon frames */ |
| 5718 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5719 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2, |
| 5720 | NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS) |
| 5721 | { |
| 5722 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5723 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 5724 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5725 | { |
| 5726 | hddLog(LOGE, |
| 5727 | "Coldn't pass " |
| 5728 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
| 5729 | } |
| 5730 | }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/ |
| 5731 | else |
| 5732 | hddLog(LOGE, |
| 5733 | "Could not pass on " |
| 5734 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
| 5735 | |
| 5736 | /* IBSS mode doesn't contain params->proberesp_ies still |
| 5737 | beaconIE's need to be populated in probe response frames */ |
| 5738 | if ( (NULL != (genie - 2)) && (0 != eLen + 2) ) |
| 5739 | { |
| 5740 | u16 rem_probe_resp_ie_len = eLen + 2; |
| 5741 | u8 probe_rsp_ie_len[3] = {0}; |
| 5742 | u8 counter = 0; |
| 5743 | |
| 5744 | /* Check Probe Resp Length if it is greater then 255 then |
| 5745 | Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 |
| 5746 | & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are |
| 5747 | not able Store More then 255 bytes into One Variable */ |
| 5748 | |
| 5749 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 5750 | { |
| 5751 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 5752 | { |
| 5753 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 5754 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 5755 | } |
| 5756 | else |
| 5757 | { |
| 5758 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 5759 | rem_probe_resp_ie_len = 0; |
| 5760 | } |
| 5761 | } |
| 5762 | |
| 5763 | rem_probe_resp_ie_len = 0; |
| 5764 | |
| 5765 | if (probe_rsp_ie_len[0] > 0) |
| 5766 | { |
| 5767 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5768 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 5769 | (tANI_U8*)(genie - 2), |
| 5770 | probe_rsp_ie_len[0], NULL, |
| 5771 | eANI_BOOLEAN_FALSE) |
| 5772 | == eHAL_STATUS_FAILURE) |
| 5773 | { |
| 5774 | hddLog(LOGE, |
| 5775 | "Could not pass" |
| 5776 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
| 5777 | } |
| 5778 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 5779 | } |
| 5780 | |
| 5781 | if (probe_rsp_ie_len[1] > 0) |
| 5782 | { |
| 5783 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5784 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 5785 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 5786 | probe_rsp_ie_len[1], NULL, |
| 5787 | eANI_BOOLEAN_FALSE) |
| 5788 | == eHAL_STATUS_FAILURE) |
| 5789 | { |
| 5790 | hddLog(LOGE, |
| 5791 | "Could not pass" |
| 5792 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
| 5793 | } |
| 5794 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 5795 | } |
| 5796 | |
| 5797 | if (probe_rsp_ie_len[2] > 0) |
| 5798 | { |
| 5799 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5800 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 5801 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 5802 | probe_rsp_ie_len[2], NULL, |
| 5803 | eANI_BOOLEAN_FALSE) |
| 5804 | == eHAL_STATUS_FAILURE) |
| 5805 | { |
| 5806 | hddLog(LOGE, |
| 5807 | "Could not pass" |
| 5808 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
| 5809 | } |
| 5810 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 5811 | } |
| 5812 | |
| 5813 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5814 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 5815 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5816 | { |
| 5817 | hddLog(LOGE, |
| 5818 | "Could not pass" |
| 5819 | "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
| 5820 | } |
| 5821 | } |
| 5822 | else |
| 5823 | { |
| 5824 | // Reset WNI_CFG_PROBE_RSP Flags |
| 5825 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 5826 | |
| 5827 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5828 | "%s: No Probe Response IE received in set beacon", |
| 5829 | __func__); |
| 5830 | } |
| 5831 | } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5832 | break; |
| 5833 | case DOT11F_EID_RSN: |
| 5834 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5835 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5836 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5837 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5838 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5839 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5840 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5841 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5842 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5843 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5844 | 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] | 5845 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5846 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5847 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5848 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5849 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5850 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5851 | VOS_ASSERT(0); |
| 5852 | return -ENOMEM; |
| 5853 | } |
| 5854 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5855 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5856 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5857 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5858 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5859 | break; |
| 5860 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5861 | #ifdef FEATURE_WLAN_WAPI |
| 5862 | case WLAN_EID_WAPI: |
| 5863 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5864 | hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5865 | pAdapter->wapi_info.nWapiMode); |
| 5866 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5867 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5868 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5869 | tmp = tmp + 1; |
| 5870 | akmlist = (int *)(tmp); |
| 5871 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5872 | { |
| 5873 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5874 | } |
| 5875 | else |
| 5876 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5877 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5878 | VOS_ASSERT(0); |
| 5879 | return -EINVAL; |
| 5880 | } |
| 5881 | |
| 5882 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5883 | { |
| 5884 | 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] | 5885 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5886 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5887 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5888 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5889 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5890 | 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] | 5891 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5892 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5893 | } |
| 5894 | break; |
| 5895 | #endif |
| 5896 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5897 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5898 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5899 | /* when Unknown IE is received we should break and continue |
| 5900 | * to the next IE in the buffer instead we were returning |
| 5901 | * so changing this to break */ |
| 5902 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5903 | } |
| 5904 | genie += eLen; |
| 5905 | remLen -= eLen; |
| 5906 | } |
| 5907 | EXIT(); |
| 5908 | return 0; |
| 5909 | } |
| 5910 | |
| 5911 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5912 | * FUNCTION: hdd_isWPAIEPresent |
| 5913 | * Parse the received IE to find the WPA IE |
| 5914 | * |
| 5915 | */ |
| 5916 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5917 | { |
| 5918 | v_U8_t eLen = 0; |
| 5919 | v_U16_t remLen = ie_len; |
| 5920 | v_U8_t elementId = 0; |
| 5921 | |
| 5922 | while (remLen >= 2) |
| 5923 | { |
| 5924 | elementId = *ie++; |
| 5925 | eLen = *ie++; |
| 5926 | remLen -= 2; |
| 5927 | if (eLen > remLen) |
| 5928 | { |
| 5929 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5930 | "%s: IE length is wrong %d", __func__, eLen); |
| 5931 | return FALSE; |
| 5932 | } |
| 5933 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5934 | { |
| 5935 | /* OUI - 0x00 0X50 0XF2 |
| 5936 | WPA Information Element - 0x01 |
| 5937 | WPA version - 0x01*/ |
| 5938 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5939 | return TRUE; |
| 5940 | } |
| 5941 | ie += eLen; |
| 5942 | remLen -= eLen; |
| 5943 | } |
| 5944 | return FALSE; |
| 5945 | } |
| 5946 | |
| 5947 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5948 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5949 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5950 | * parameters during connect operation. |
| 5951 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5952 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5953 | struct cfg80211_connect_params *req |
| 5954 | ) |
| 5955 | { |
| 5956 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5957 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5958 | ENTER(); |
| 5959 | |
| 5960 | /*set wpa version*/ |
| 5961 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5962 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5963 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5964 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 5965 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5966 | { |
| 5967 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5968 | } |
| 5969 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5970 | { |
| 5971 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5972 | } |
| 5973 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5974 | |
| 5975 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5976 | pWextState->wpaVersion); |
| 5977 | |
| 5978 | /*set authentication type*/ |
| 5979 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5980 | |
| 5981 | if (0 > status) |
| 5982 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5983 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5984 | "%s: failed to set authentication type ", __func__); |
| 5985 | return status; |
| 5986 | } |
| 5987 | |
| 5988 | /*set key mgmt type*/ |
| 5989 | if (req->crypto.n_akm_suites) |
| 5990 | { |
| 5991 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5992 | if (0 > status) |
| 5993 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5994 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5995 | __func__); |
| 5996 | return status; |
| 5997 | } |
| 5998 | } |
| 5999 | |
| 6000 | /*set pairwise cipher type*/ |
| 6001 | if (req->crypto.n_ciphers_pairwise) |
| 6002 | { |
| 6003 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 6004 | req->crypto.ciphers_pairwise[0], true); |
| 6005 | if (0 > status) |
| 6006 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6007 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6008 | "%s: failed to set unicast cipher type", __func__); |
| 6009 | return status; |
| 6010 | } |
| 6011 | } |
| 6012 | else |
| 6013 | { |
| 6014 | /*Reset previous cipher suite to none*/ |
| 6015 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 6016 | if (0 > status) |
| 6017 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6018 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6019 | "%s: failed to set unicast cipher type", __func__); |
| 6020 | return status; |
| 6021 | } |
| 6022 | } |
| 6023 | |
| 6024 | /*set group cipher type*/ |
| 6025 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 6026 | false); |
| 6027 | |
| 6028 | if (0 > status) |
| 6029 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6030 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6031 | __func__); |
| 6032 | return status; |
| 6033 | } |
| 6034 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 6035 | #ifdef WLAN_FEATURE_11W |
| 6036 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 6037 | #endif |
| 6038 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6039 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 6040 | if (req->ie_len) |
| 6041 | { |
| 6042 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 6043 | if ( 0 > status) |
| 6044 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6045 | 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] | 6046 | __func__); |
| 6047 | return status; |
| 6048 | } |
| 6049 | } |
| 6050 | |
| 6051 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6052 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6053 | { |
| 6054 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 6055 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 6056 | ) |
| 6057 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6058 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6059 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 6060 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6061 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6062 | __func__); |
| 6063 | return -EOPNOTSUPP; |
| 6064 | } |
| 6065 | else |
| 6066 | { |
| 6067 | u8 key_len = req->key_len; |
| 6068 | u8 key_idx = req->key_idx; |
| 6069 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6070 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6071 | && (CSR_MAX_NUM_KEY > key_idx) |
| 6072 | ) |
| 6073 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6074 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6075 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6076 | __func__, key_idx, key_len); |
| 6077 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6078 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6079 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6080 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6081 | (u8)key_len; |
| 6082 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 6083 | } |
| 6084 | } |
| 6085 | } |
| 6086 | } |
| 6087 | |
| 6088 | return status; |
| 6089 | } |
| 6090 | |
| 6091 | /* |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6092 | * FUNCTION: wlan_hdd_try_disconnect |
| 6093 | * This function is used to disconnect from previous |
| 6094 | * connection |
| 6095 | */ |
| 6096 | static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter ) |
| 6097 | { |
| 6098 | long ret = 0; |
| 6099 | hdd_station_ctx_t *pHddStaCtx; |
| 6100 | eMib_dot11DesiredBssType connectedBssType; |
| 6101 | |
| 6102 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6103 | |
| 6104 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 6105 | |
| 6106 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 6107 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 6108 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
| 6109 | { |
| 6110 | /* Issue disconnect to CSR */ |
| 6111 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6112 | if( eHAL_STATUS_SUCCESS == |
| 6113 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6114 | pAdapter->sessionId, |
| 6115 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 6116 | { |
| 6117 | ret = wait_for_completion_interruptible_timeout( |
| 6118 | &pAdapter->disconnect_comp_var, |
| 6119 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6120 | if (0 >= ret) |
| 6121 | { |
| 6122 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 6123 | return -EALREADY; |
| 6124 | } |
| 6125 | } |
| 6126 | } |
| 6127 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 6128 | { |
| 6129 | ret = wait_for_completion_interruptible_timeout( |
| 6130 | &pAdapter->disconnect_comp_var, |
| 6131 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6132 | if (0 >= ret) |
| 6133 | { |
| 6134 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 6135 | return -EALREADY; |
| 6136 | } |
| 6137 | } |
| 6138 | |
| 6139 | return 0; |
| 6140 | } |
| 6141 | |
| 6142 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6143 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6144 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6145 | * parameters during connect operation. |
| 6146 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6147 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6148 | struct net_device *ndev, |
| 6149 | struct cfg80211_connect_params *req |
| 6150 | ) |
| 6151 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6152 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6153 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6154 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 6155 | hdd_context_t *pHddCtx = NULL; |
| 6156 | |
| 6157 | ENTER(); |
| 6158 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6159 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6160 | "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6161 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6162 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6163 | status = wlan_hdd_validate_context(pHddCtx); |
| 6164 | |
| 6165 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6166 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6167 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6168 | "%s: HDD context is not valid", __func__); |
| 6169 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6170 | } |
| 6171 | |
| 6172 | #ifdef WLAN_BTAMP_FEATURE |
| 6173 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6174 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6175 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6176 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6177 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 6178 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6179 | } |
| 6180 | #endif |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6181 | |
| 6182 | //If Device Mode is Station Concurrent Sessions Exit BMps |
| 6183 | //P2P Mode will be taken care in Open/close adapter |
| 6184 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 6185 | (vos_concurrent_sessions_running())) |
| 6186 | { |
| 6187 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6188 | } |
| 6189 | |
| 6190 | /*Try disconnecting if already in connected state*/ |
| 6191 | status = wlan_hdd_try_disconnect(pAdapter); |
| 6192 | if ( 0 > status) |
| 6193 | { |
| 6194 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 6195 | " connection")); |
| 6196 | return -EALREADY; |
| 6197 | } |
| 6198 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6199 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6200 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6201 | |
| 6202 | if ( 0 > status) |
| 6203 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6204 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6205 | __func__); |
| 6206 | return status; |
| 6207 | } |
| 6208 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 6209 | if ( req->channel ) |
| 6210 | { |
| 6211 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 6212 | req->ssid_len, req->bssid, |
| 6213 | req->channel->hw_value); |
| 6214 | } |
| 6215 | else |
| 6216 | { |
| 6217 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6218 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 6219 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6220 | |
| 6221 | if (0 > status) |
| 6222 | { |
| 6223 | //ReEnable BMPS if disabled |
| 6224 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 6225 | (NULL != pHddCtx)) |
| 6226 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6227 | if (pHddCtx->hdd_wlan_suspended) |
| 6228 | { |
| 6229 | hdd_set_pwrparams(pHddCtx); |
| 6230 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6231 | //ReEnable Bmps and Imps back |
| 6232 | hdd_enable_bmps_imps(pHddCtx); |
| 6233 | } |
| 6234 | |
| 6235 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6236 | return status; |
| 6237 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6238 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6239 | EXIT(); |
| 6240 | return status; |
| 6241 | } |
| 6242 | |
| 6243 | |
| 6244 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6245 | * FUNCTION: wlan_hdd_disconnect |
| 6246 | * This function is used to issue a disconnect request to SME |
| 6247 | */ |
| 6248 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 6249 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6250 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6251 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6252 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6253 | |
| 6254 | status = wlan_hdd_validate_context(pHddCtx); |
| 6255 | |
| 6256 | if (0 != status) |
| 6257 | { |
| 6258 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6259 | "%s: HDD context is not valid", __func__); |
| 6260 | return status; |
| 6261 | } |
| 6262 | |
| 6263 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6264 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6265 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6266 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6267 | /*issue disconnect*/ |
| 6268 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6269 | pAdapter->sessionId, reason); |
| 6270 | |
| 6271 | if ( 0 != status ) |
| 6272 | { |
| 6273 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6274 | "%s csrRoamDisconnect failure, returned %d", |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6275 | __func__, (int)status ); |
| 6276 | return -EINVAL; |
| 6277 | } |
| 6278 | wait_for_completion_interruptible_timeout( |
| 6279 | &pAdapter->disconnect_comp_var, |
| 6280 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6281 | /*stop tx queues*/ |
| 6282 | netif_tx_disable(pAdapter->dev); |
| 6283 | netif_carrier_off(pAdapter->dev); |
| 6284 | return status; |
| 6285 | } |
| 6286 | |
| 6287 | |
| 6288 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6289 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 6290 | * This function is used to issue a disconnect request to SME |
| 6291 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6292 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6293 | struct net_device *dev, |
| 6294 | u16 reason |
| 6295 | ) |
| 6296 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6297 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6298 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6299 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6300 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6301 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6302 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6303 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6304 | tANI_U8 staIdx; |
| 6305 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6306 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6307 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6308 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6309 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6310 | __func__,pAdapter->device_mode); |
| 6311 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6312 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 6313 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6314 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6315 | status = wlan_hdd_validate_context(pHddCtx); |
| 6316 | |
| 6317 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6318 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6319 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6320 | "%s: HDD context is not valid", __func__); |
| 6321 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6322 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6323 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6324 | if (NULL != pRoamProfile) |
| 6325 | { |
| 6326 | /*issue disconnect request to SME, if station is in connected state*/ |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 6327 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 6328 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6329 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6330 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6331 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6332 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6333 | switch(reason) |
| 6334 | { |
| 6335 | case WLAN_REASON_MIC_FAILURE: |
| 6336 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 6337 | break; |
| 6338 | |
| 6339 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 6340 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 6341 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 6342 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 6343 | break; |
| 6344 | |
| 6345 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 6346 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 6347 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 6348 | break; |
| 6349 | |
| 6350 | case WLAN_REASON_DEAUTH_LEAVING: |
| 6351 | default: |
| 6352 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 6353 | break; |
| 6354 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6355 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6356 | pScanInfo = &pHddCtx->scan_info; |
| 6357 | if (pScanInfo->mScanPending) |
| 6358 | { |
| 6359 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 6360 | "Aborting Scan"); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 6361 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6362 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6363 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6364 | #ifdef FEATURE_WLAN_TDLS |
| 6365 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6366 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6367 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6368 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 6369 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6370 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6371 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6372 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6373 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6374 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6375 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6376 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6377 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6378 | pAdapter->sessionId, |
| 6379 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6380 | } |
| 6381 | } |
| 6382 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6383 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 6384 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6385 | { |
| 6386 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6387 | "%s wlan_hdd_disconnect failure, returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6388 | __func__, (int)status ); |
| 6389 | return -EINVAL; |
| 6390 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6391 | } |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 6392 | else |
| 6393 | { |
| 6394 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API" |
| 6395 | "called while in %d state", __func__, |
| 6396 | pHddStaCtx->conn_info.connState); |
| 6397 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6398 | } |
| 6399 | else |
| 6400 | { |
| 6401 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 6402 | } |
| 6403 | |
| 6404 | return status; |
| 6405 | } |
| 6406 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6407 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6408 | /* |
| 6409 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6410 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6411 | * settings in IBSS mode. |
| 6412 | */ |
| 6413 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6414 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6415 | struct cfg80211_ibss_params *params |
| 6416 | ) |
| 6417 | { |
| 6418 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6419 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6420 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 6421 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6422 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6423 | ENTER(); |
| 6424 | |
| 6425 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Ravi Joshi | b58ca0d | 2013-10-29 09:50:23 -0700 | [diff] [blame] | 6426 | vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6427 | |
| 6428 | if (params->ie_len && ( NULL != params->ie) ) |
| 6429 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6430 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 6431 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6432 | { |
| 6433 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 6434 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 6435 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6436 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6437 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6438 | tDot11fIEWPA dot11WPAIE; |
| 6439 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6440 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6441 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 6442 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6443 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 6444 | params->ie_len, DOT11F_EID_WPA); |
| 6445 | if ( NULL != ie ) |
| 6446 | { |
| 6447 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 6448 | // Unpack the WPA IE |
| 6449 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 6450 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 6451 | &ie[2+4], |
| 6452 | ie[1] - 4, |
| 6453 | &dot11WPAIE); |
| 6454 | /*Extract the multicast cipher, the encType for unicast |
| 6455 | cipher for wpa-none is none*/ |
| 6456 | encryptionType = |
| 6457 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 6458 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6459 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6460 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6461 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 6462 | |
| 6463 | if (0 > status) |
| 6464 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6465 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6466 | __func__); |
| 6467 | return status; |
| 6468 | } |
| 6469 | } |
| 6470 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6471 | pWextState->roamProfile.AuthType.authType[0] = |
| 6472 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6473 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6474 | |
| 6475 | if (params->privacy) |
| 6476 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6477 | /* Security enabled IBSS, At this time there is no information available |
| 6478 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6479 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6480 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6481 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6482 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6483 | *enable privacy bit in beacons */ |
| 6484 | |
| 6485 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 6486 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6487 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6488 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6489 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 6490 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 6491 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6492 | return status; |
| 6493 | } |
| 6494 | |
| 6495 | /* |
| 6496 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6497 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6498 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6499 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6500 | struct net_device *dev, |
| 6501 | struct cfg80211_ibss_params *params |
| 6502 | ) |
| 6503 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6504 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6505 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6506 | tCsrRoamProfile *pRoamProfile; |
| 6507 | int status; |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6508 | bool alloc_bssid = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6509 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6510 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6511 | |
| 6512 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6513 | |
| 6514 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6515 | "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6516 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6517 | status = wlan_hdd_validate_context(pHddCtx); |
| 6518 | |
| 6519 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6520 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6521 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6522 | "%s: HDD context is not valid", __func__); |
| 6523 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6524 | } |
| 6525 | |
| 6526 | if (NULL == pWextState) |
| 6527 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6528 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6529 | __func__); |
| 6530 | return -EIO; |
| 6531 | } |
| 6532 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6533 | /*Try disconnecting if already in connected state*/ |
| 6534 | status = wlan_hdd_try_disconnect(pAdapter); |
| 6535 | if ( 0 > status) |
| 6536 | { |
| 6537 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 6538 | " IBSS connection")); |
| 6539 | return -EALREADY; |
| 6540 | } |
| 6541 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6542 | pRoamProfile = &pWextState->roamProfile; |
| 6543 | |
| 6544 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 6545 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6546 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6547 | "%s Interface type is not set to IBSS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6548 | return -EINVAL; |
| 6549 | } |
| 6550 | |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 6551 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 6552 | if (NULL != params->bssid) { |
| 6553 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 6554 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) { |
| 6555 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6556 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 6557 | return -EIO; |
| 6558 | } |
| 6559 | } |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6560 | else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0) |
| 6561 | { |
| 6562 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 6563 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 6564 | { |
| 6565 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6566 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 6567 | return -EIO; |
| 6568 | } |
| 6569 | params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE)); |
| 6570 | if (!params->bssid) |
| 6571 | { |
| 6572 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6573 | "%s:Failed memory allocation", __func__); |
| 6574 | return -EIO; |
| 6575 | } |
| 6576 | vos_mem_copy((v_U8_t *)params->bssid, |
| 6577 | (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0], |
| 6578 | VOS_MAC_ADDR_SIZE); |
| 6579 | alloc_bssid = VOS_TRUE; |
| 6580 | } |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 6581 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6582 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6583 | if (NULL != |
| 6584 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6585 | params->chandef.chan) |
| 6586 | #else |
| 6587 | params->channel) |
| 6588 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6589 | { |
| 6590 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6591 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6592 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6593 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6594 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6595 | |
| 6596 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6597 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6598 | ieee80211_frequency_to_channel( |
| 6599 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6600 | params->chandef.chan->center_freq); |
| 6601 | #else |
| 6602 | params->channel->center_freq); |
| 6603 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6604 | |
| 6605 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 6606 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6607 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6608 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 6609 | __func__); |
| 6610 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6611 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6612 | |
| 6613 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6614 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6615 | if (channelNum == validChan[indx]) |
| 6616 | { |
| 6617 | break; |
| 6618 | } |
| 6619 | } |
| 6620 | if (indx >= numChans) |
| 6621 | { |
| 6622 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6623 | __func__, channelNum); |
| 6624 | return -EINVAL; |
| 6625 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6626 | /* Set the Operational Channel */ |
| 6627 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 6628 | channelNum); |
| 6629 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 6630 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6631 | pRoamProfile->ChannelInfo.ChannelList = |
| 6632 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6633 | } |
| 6634 | |
| 6635 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6636 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6637 | if (status < 0) |
| 6638 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6639 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6640 | __func__); |
| 6641 | return status; |
| 6642 | } |
| 6643 | |
| 6644 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6645 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6646 | params->ssid_len, params->bssid, |
| 6647 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6648 | |
| 6649 | if (0 > status) |
| 6650 | { |
| 6651 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6652 | return status; |
| 6653 | } |
| 6654 | |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6655 | if (NULL != params->bssid && |
| 6656 | pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 && |
| 6657 | alloc_bssid == VOS_TRUE) |
| 6658 | { |
| 6659 | vos_mem_free(params->bssid); |
| 6660 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6661 | return 0; |
| 6662 | } |
| 6663 | |
| 6664 | /* |
| 6665 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6666 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6667 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6668 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6669 | struct net_device *dev |
| 6670 | ) |
| 6671 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6672 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6673 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6674 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6675 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6676 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6677 | |
| 6678 | ENTER(); |
| 6679 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6680 | status = wlan_hdd_validate_context(pHddCtx); |
| 6681 | |
| 6682 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6683 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6684 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6685 | "%s: HDD context is not valid", __func__); |
| 6686 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6687 | } |
| 6688 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6689 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6690 | if (NULL == pWextState) |
| 6691 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6692 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6693 | __func__); |
| 6694 | return -EIO; |
| 6695 | } |
| 6696 | |
| 6697 | pRoamProfile = &pWextState->roamProfile; |
| 6698 | |
| 6699 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6700 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6701 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6702 | 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] | 6703 | __func__); |
| 6704 | return -EINVAL; |
| 6705 | } |
| 6706 | |
| 6707 | /* Issue Disconnect request */ |
| 6708 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6709 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6710 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6711 | |
| 6712 | return 0; |
| 6713 | } |
| 6714 | |
| 6715 | /* |
| 6716 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6717 | * This function is used to set the phy parameters |
| 6718 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6719 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6720 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6721 | u32 changed) |
| 6722 | { |
| 6723 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6724 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6725 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6726 | |
| 6727 | ENTER(); |
| 6728 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6729 | status = wlan_hdd_validate_context(pHddCtx); |
| 6730 | |
| 6731 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6732 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6733 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6734 | "%s: HDD context is not valid", __func__); |
| 6735 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6736 | } |
| 6737 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6738 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6739 | { |
| 6740 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6741 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6742 | wiphy->rts_threshold; |
| 6743 | |
| 6744 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6745 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6746 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6747 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6748 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6749 | __func__, rts_threshold); |
| 6750 | return -EINVAL; |
| 6751 | } |
| 6752 | |
| 6753 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6754 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6755 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6756 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6757 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6758 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6759 | __func__, rts_threshold); |
| 6760 | return -EIO; |
| 6761 | } |
| 6762 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6763 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6764 | rts_threshold); |
| 6765 | } |
| 6766 | |
| 6767 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6768 | { |
| 6769 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6770 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6771 | wiphy->frag_threshold; |
| 6772 | |
| 6773 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6774 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6775 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6776 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6777 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6778 | frag_threshold); |
| 6779 | return -EINVAL; |
| 6780 | } |
| 6781 | |
| 6782 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6783 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6784 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6785 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6786 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6787 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6788 | __func__, frag_threshold); |
| 6789 | return -EIO; |
| 6790 | } |
| 6791 | |
| 6792 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6793 | frag_threshold); |
| 6794 | } |
| 6795 | |
| 6796 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6797 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6798 | { |
| 6799 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6800 | wiphy->retry_short : |
| 6801 | wiphy->retry_long; |
| 6802 | |
| 6803 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6804 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6805 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6806 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6807 | __func__, retry_value); |
| 6808 | return -EINVAL; |
| 6809 | } |
| 6810 | |
| 6811 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6812 | { |
| 6813 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6814 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6815 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6816 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6817 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6818 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6819 | __func__, retry_value); |
| 6820 | return -EIO; |
| 6821 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6822 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6823 | __func__, retry_value); |
| 6824 | } |
| 6825 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6826 | { |
| 6827 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6828 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6829 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6830 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6831 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6832 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6833 | __func__, retry_value); |
| 6834 | return -EIO; |
| 6835 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6836 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6837 | __func__, retry_value); |
| 6838 | } |
| 6839 | } |
| 6840 | |
| 6841 | return 0; |
| 6842 | } |
| 6843 | |
| 6844 | /* |
| 6845 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6846 | * This function is used to set the txpower |
| 6847 | */ |
| 6848 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6849 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6850 | struct wireless_dev *wdev, |
| 6851 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6852 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6853 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6854 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6855 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6856 | #endif |
| 6857 | int dbm) |
| 6858 | { |
| 6859 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6860 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6861 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6862 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6863 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6864 | |
| 6865 | ENTER(); |
| 6866 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6867 | status = wlan_hdd_validate_context(pHddCtx); |
| 6868 | |
| 6869 | if (0 != status) |
| 6870 | { |
| 6871 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6872 | "%s: HDD context is not valid", __func__); |
| 6873 | return status; |
| 6874 | } |
| 6875 | |
| 6876 | hHal = pHddCtx->hHal; |
| 6877 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6878 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6879 | dbm, ccmCfgSetCallback, |
| 6880 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6881 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6882 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6883 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6884 | return -EIO; |
| 6885 | } |
| 6886 | |
| 6887 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6888 | dbm); |
| 6889 | |
| 6890 | switch(type) |
| 6891 | { |
| 6892 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6893 | /* Fall through */ |
| 6894 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6895 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6896 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6897 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6898 | __func__); |
| 6899 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6900 | } |
| 6901 | break; |
| 6902 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6903 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6904 | __func__); |
| 6905 | return -EOPNOTSUPP; |
| 6906 | break; |
| 6907 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6908 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6909 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6910 | return -EIO; |
| 6911 | } |
| 6912 | |
| 6913 | return 0; |
| 6914 | } |
| 6915 | |
| 6916 | /* |
| 6917 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6918 | * This function is used to read the txpower |
| 6919 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6920 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 6921 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6922 | struct wireless_dev *wdev, |
| 6923 | #endif |
| 6924 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6925 | { |
| 6926 | |
| 6927 | hdd_adapter_t *pAdapter; |
| 6928 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6929 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6930 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6931 | ENTER(); |
| 6932 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6933 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6934 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6935 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6936 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6937 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6938 | "%s: HDD context is not valid", __func__); |
| 6939 | *dbm = 0; |
| 6940 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6941 | } |
| 6942 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6943 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6944 | if (NULL == pAdapter) |
| 6945 | { |
| 6946 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6947 | return -ENOENT; |
| 6948 | } |
| 6949 | |
| 6950 | wlan_hdd_get_classAstats(pAdapter); |
| 6951 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6952 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6953 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6954 | return 0; |
| 6955 | } |
| 6956 | |
| 6957 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6958 | u8* mac, struct station_info *sinfo) |
| 6959 | { |
| 6960 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6961 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6962 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6963 | tANI_U8 rate_flags; |
| 6964 | |
| 6965 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6966 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6967 | |
| 6968 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6969 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6970 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6971 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6972 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6973 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6974 | tANI_U16 maxRate = 0; |
| 6975 | tANI_U16 myRate; |
| 6976 | tANI_U16 currentRate = 0; |
| 6977 | tANI_U8 maxSpeedMCS = 0; |
| 6978 | tANI_U8 maxMCSIdx = 0; |
| 6979 | tANI_U8 rateFlag = 1; |
| 6980 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6981 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6982 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6983 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6984 | #ifdef WLAN_FEATURE_11AC |
| 6985 | tANI_U32 vht_mcs_map; |
| 6986 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6987 | #endif /* WLAN_FEATURE_11AC */ |
| 6988 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6989 | ENTER(); |
| 6990 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6991 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6992 | (0 == ssidlen)) |
| 6993 | { |
| 6994 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6995 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6996 | /*To keep GUI happy*/ |
| 6997 | return 0; |
| 6998 | } |
| 6999 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7000 | status = wlan_hdd_validate_context(pHddCtx); |
| 7001 | |
| 7002 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7003 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7004 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7005 | "%s: HDD context is not valid", __func__); |
| 7006 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7007 | } |
| 7008 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 7009 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7010 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 7011 | |
Kiet Lam | 3b17fc8 | 2013-09-27 05:24:08 +0530 | [diff] [blame] | 7012 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 7013 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 7014 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7015 | //convert to the UI units of 100kbps |
| 7016 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 7017 | |
| 7018 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7019 | 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] | 7020 | sinfo->signal, |
| 7021 | pCfg->reportMaxLinkSpeed, |
| 7022 | myRate, |
| 7023 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7024 | (int) pCfg->linkSpeedRssiMid, |
| 7025 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7026 | (int) rate_flags, |
| 7027 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7028 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7029 | |
| 7030 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 7031 | { |
| 7032 | // we do not want to necessarily report the current speed |
| 7033 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 7034 | { |
| 7035 | // report the max possible speed |
| 7036 | rssidx = 0; |
| 7037 | } |
| 7038 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 7039 | { |
| 7040 | // report the max possible speed with RSSI scaling |
| 7041 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 7042 | { |
| 7043 | // report the max possible speed |
| 7044 | rssidx = 0; |
| 7045 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7046 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7047 | { |
| 7048 | // report middle speed |
| 7049 | rssidx = 1; |
| 7050 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7051 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 7052 | { |
| 7053 | // report middle speed |
| 7054 | rssidx = 2; |
| 7055 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7056 | else |
| 7057 | { |
| 7058 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7059 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7060 | } |
| 7061 | } |
| 7062 | else |
| 7063 | { |
| 7064 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 7065 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7066 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 7067 | __func__, pCfg->reportMaxLinkSpeed); |
| 7068 | rssidx = 0; |
| 7069 | } |
| 7070 | |
| 7071 | maxRate = 0; |
| 7072 | |
| 7073 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7074 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 7075 | OperationalRates, &ORLeng)) |
| 7076 | { |
| 7077 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7078 | /*To keep GUI happy*/ |
| 7079 | return 0; |
| 7080 | } |
| 7081 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7082 | for (i = 0; i < ORLeng; i++) |
| 7083 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7084 | 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] | 7085 | { |
| 7086 | /* Validate Rate Set */ |
| 7087 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 7088 | { |
| 7089 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 7090 | break; |
| 7091 | } |
| 7092 | } |
| 7093 | /* Update MAX rate */ |
| 7094 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 7095 | } |
| 7096 | |
| 7097 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7098 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 7099 | ExtendedRates, &ERLeng)) |
| 7100 | { |
| 7101 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7102 | /*To keep GUI happy*/ |
| 7103 | return 0; |
| 7104 | } |
| 7105 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7106 | for (i = 0; i < ERLeng; i++) |
| 7107 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7108 | 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] | 7109 | { |
| 7110 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 7111 | { |
| 7112 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 7113 | break; |
| 7114 | } |
| 7115 | } |
| 7116 | /* Update MAX rate */ |
| 7117 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 7118 | } |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7119 | /* Get MCS Rate Set -- |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 7120 | Only if we are always reporting max speed (or) |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7121 | if we have good rssi */ |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 7122 | if ((0 == rssidx) || |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7123 | (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7124 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7125 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 7126 | MCSRates, &MCSLeng)) |
| 7127 | { |
| 7128 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7129 | /*To keep GUI happy*/ |
| 7130 | return 0; |
| 7131 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7132 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7133 | #ifdef WLAN_FEATURE_11AC |
| 7134 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7135 | 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] | 7136 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7137 | 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] | 7138 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7139 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7140 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7141 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7142 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7143 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7144 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7145 | maxMCSIdx = 7; |
| 7146 | } |
| 7147 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 7148 | { |
| 7149 | maxMCSIdx = 8; |
| 7150 | } |
| 7151 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 7152 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7153 | //VHT20 is supporting 0~8 |
| 7154 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7155 | maxMCSIdx = 8; |
| 7156 | else |
| 7157 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7158 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7159 | |
| 7160 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7161 | { |
| 7162 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 7163 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 7164 | } |
| 7165 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 7166 | { |
| 7167 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 7168 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 7169 | } |
| 7170 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7171 | { |
| 7172 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 7173 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 7174 | } |
| 7175 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7176 | maxSpeedMCS = 1; |
| 7177 | if (currentRate > maxRate) |
| 7178 | { |
| 7179 | maxRate = currentRate; |
| 7180 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7181 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7182 | } |
| 7183 | else |
| 7184 | #endif /* WLAN_FEATURE_11AC */ |
| 7185 | { |
| 7186 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7187 | { |
| 7188 | rateFlag |= 1; |
| 7189 | } |
| 7190 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7191 | { |
| 7192 | rateFlag |= 2; |
| 7193 | } |
| 7194 | |
| 7195 | for (i = 0; i < MCSLeng; i++) |
| 7196 | { |
| 7197 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 7198 | for (j = 0; j < temp; j++) |
| 7199 | { |
| 7200 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 7201 | { |
| 7202 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 7203 | break; |
| 7204 | } |
| 7205 | } |
| 7206 | if ((j < temp) && (currentRate > maxRate)) |
| 7207 | { |
| 7208 | maxRate = currentRate; |
| 7209 | maxSpeedMCS = 1; |
| 7210 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 7211 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7212 | } |
| 7213 | } |
| 7214 | } |
| 7215 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7216 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 7217 | { |
| 7218 | maxRate = myRate; |
| 7219 | maxSpeedMCS = 1; |
| 7220 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 7221 | } |
| 7222 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7223 | // 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] | 7224 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 7225 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7226 | { |
| 7227 | maxRate = myRate; |
| 7228 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 7229 | { |
| 7230 | maxSpeedMCS = 0; |
| 7231 | } |
| 7232 | else |
| 7233 | { |
| 7234 | maxSpeedMCS = 1; |
| 7235 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 7236 | } |
| 7237 | } |
| 7238 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7239 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7240 | { |
| 7241 | sinfo->txrate.legacy = maxRate; |
| 7242 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7243 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 7244 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7245 | } |
| 7246 | else |
| 7247 | { |
| 7248 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7249 | #ifdef WLAN_FEATURE_11AC |
| 7250 | sinfo->txrate.nss = 1; |
| 7251 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7252 | { |
| 7253 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7254 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7255 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7256 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7257 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7258 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7259 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7260 | } |
| 7261 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7262 | { |
| 7263 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7264 | } |
| 7265 | #endif /* WLAN_FEATURE_11AC */ |
| 7266 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 7267 | { |
| 7268 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 7269 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7270 | { |
| 7271 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7272 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7273 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7274 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7275 | { |
| 7276 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 7277 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7278 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7279 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7280 | pr_info("Reporting MCS rate %d flags %x\n", |
| 7281 | sinfo->txrate.mcs, |
| 7282 | sinfo->txrate.flags ); |
| 7283 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7284 | } |
| 7285 | } |
| 7286 | else |
| 7287 | { |
| 7288 | // report current rate instead of max rate |
| 7289 | |
| 7290 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 7291 | { |
| 7292 | //provide to the UI in units of 100kbps |
| 7293 | sinfo->txrate.legacy = myRate; |
| 7294 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7295 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 7296 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7297 | } |
| 7298 | else |
| 7299 | { |
| 7300 | //must be MCS |
| 7301 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7302 | #ifdef WLAN_FEATURE_11AC |
| 7303 | sinfo->txrate.nss = 1; |
| 7304 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7305 | { |
| 7306 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7307 | } |
| 7308 | else |
| 7309 | #endif /* WLAN_FEATURE_11AC */ |
| 7310 | { |
| 7311 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 7312 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7313 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7314 | { |
| 7315 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 7316 | } |
| 7317 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7318 | { |
| 7319 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7320 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7321 | #ifdef WLAN_FEATURE_11AC |
| 7322 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7323 | { |
| 7324 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 7325 | } |
| 7326 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7327 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7328 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 7329 | sinfo->txrate.mcs, |
| 7330 | sinfo->txrate.flags ); |
| 7331 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7332 | } |
| 7333 | } |
| 7334 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 7335 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 7336 | sinfo->tx_packets = |
| 7337 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 7338 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 7339 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 7340 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 7341 | |
| 7342 | sinfo->tx_retries = |
| 7343 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 7344 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 7345 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 7346 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 7347 | |
| 7348 | sinfo->tx_failed = |
| 7349 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 7350 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 7351 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 7352 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 7353 | |
| 7354 | sinfo->filled |= |
| 7355 | STATION_INFO_TX_PACKETS | |
| 7356 | STATION_INFO_TX_RETRIES | |
| 7357 | STATION_INFO_TX_FAILED; |
| 7358 | |
| 7359 | EXIT(); |
| 7360 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7361 | } |
| 7362 | |
| 7363 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 7364 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7365 | { |
| 7366 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7367 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7368 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7369 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7370 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7371 | ENTER(); |
| 7372 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7373 | if (NULL == pAdapter) |
| 7374 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7375 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7376 | return -ENODEV; |
| 7377 | } |
| 7378 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7379 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7380 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7381 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7382 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7383 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7384 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7385 | "%s: HDD context is not valid", __func__); |
| 7386 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7387 | } |
| 7388 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7389 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 7390 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 7391 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 7392 | (eConnectionState_Associated == |
| 7393 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 7394 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 7395 | |
| 7396 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7397 | "offload: in cfg80211_set_power_mgmt, calling arp offload"); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 7398 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7399 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7400 | { |
| 7401 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7402 | "%s:Failed to enable ARPOFFLOAD Feature %d", |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7403 | __func__, vos_status); |
| 7404 | } |
| 7405 | } |
| 7406 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7407 | /**The get power cmd from the supplicant gets updated by the nl only |
| 7408 | *on successful execution of the function call |
| 7409 | *we are oppositely mapped w.r.t mode in the driver |
| 7410 | **/ |
| 7411 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 7412 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7413 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7414 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 7415 | { |
| 7416 | return -EINVAL; |
| 7417 | } |
| 7418 | return 0; |
| 7419 | } |
| 7420 | |
| 7421 | |
| 7422 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7423 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 7424 | struct net_device *netdev, |
| 7425 | u8 key_index) |
| 7426 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7427 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7428 | return 0; |
| 7429 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7430 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7431 | |
| 7432 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 7433 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 7434 | struct net_device *dev, |
| 7435 | struct ieee80211_txq_params *params) |
| 7436 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7437 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7438 | return 0; |
| 7439 | } |
| 7440 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7441 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 7442 | struct ieee80211_txq_params *params) |
| 7443 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7444 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7445 | return 0; |
| 7446 | } |
| 7447 | #endif //LINUX_VERSION_CODE |
| 7448 | |
| 7449 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 7450 | struct net_device *dev, u8 *mac) |
| 7451 | { |
| 7452 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7453 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7454 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7455 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7456 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7457 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7458 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7459 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7460 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7461 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7462 | return -EINVAL; |
| 7463 | } |
| 7464 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7465 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7466 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7467 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7468 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7469 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7470 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7471 | "%s: HDD context is not valid", __func__); |
| 7472 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7473 | } |
| 7474 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7475 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7476 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7477 | ) |
| 7478 | { |
| 7479 | if( NULL == mac ) |
| 7480 | { |
| 7481 | v_U16_t i; |
| 7482 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 7483 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 7484 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 7485 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7486 | { |
| 7487 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 7488 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7489 | "%s: Delete STA with MAC::" |
| 7490 | MAC_ADDRESS_STR, |
| 7491 | __func__, MAC_ADDR_ARRAY(macAddr)); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 7492 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 7493 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7494 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7495 | } |
| 7496 | } |
| 7497 | } |
| 7498 | else |
| 7499 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7500 | |
| 7501 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 7502 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7503 | { |
| 7504 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7505 | "%s: Skip this DEL STA as this is not used::" |
| 7506 | MAC_ADDRESS_STR, |
| 7507 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7508 | return -ENOENT; |
| 7509 | } |
| 7510 | |
| 7511 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 7512 | { |
| 7513 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7514 | "%s: Skip this DEL STA as deauth is in progress::" |
| 7515 | MAC_ADDRESS_STR, |
| 7516 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7517 | return -ENOENT; |
| 7518 | } |
| 7519 | |
| 7520 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 7521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7522 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7523 | "%s: Delete STA with MAC::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7524 | MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7525 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7526 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7527 | |
| 7528 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 7529 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7530 | { |
| 7531 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 7532 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7533 | "%s: STA removal failed for ::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7534 | MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7535 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7536 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7537 | return -ENOENT; |
| 7538 | } |
| 7539 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7540 | } |
| 7541 | } |
| 7542 | |
| 7543 | EXIT(); |
| 7544 | |
| 7545 | return 0; |
| 7546 | } |
| 7547 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7548 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 7549 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 7550 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7551 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7552 | #ifdef FEATURE_WLAN_TDLS |
| 7553 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7554 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7555 | mask = params->sta_flags_mask; |
| 7556 | |
| 7557 | set = params->sta_flags_set; |
| 7558 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7559 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7560 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7561 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 7562 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 7563 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7564 | |
| 7565 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7566 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7567 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7568 | } |
| 7569 | } |
| 7570 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7571 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7572 | } |
| 7573 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7574 | |
| 7575 | #ifdef FEATURE_WLAN_LFR |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7576 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 7577 | |
| 7578 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache |
| 7579 | static tANI_U32 PMKIDCacheIndex; // HDD local Cache index |
| 7580 | |
| 7581 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7582 | 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] | 7583 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7584 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7585 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7586 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7587 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7588 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7589 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7590 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7591 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7592 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7593 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR, |
| 7594 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7595 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7596 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7597 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7598 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7599 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7600 | return -EINVAL; |
| 7601 | } |
| 7602 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7603 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7604 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7605 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7606 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7607 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7608 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7609 | "%s: HDD context is not valid", __func__); |
| 7610 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7611 | } |
| 7612 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7613 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7614 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7615 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7616 | for (j = 0; j < PMKIDCacheIndex; j++) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7617 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7618 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7619 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 7620 | { |
| 7621 | /* BSSID matched previous entry. Overwrite it. */ |
| 7622 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7623 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7624 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7625 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7626 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7627 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7628 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7629 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7630 | dump_bssid(pmksa->bssid); |
| 7631 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7632 | break; |
| 7633 | } |
| 7634 | } |
| 7635 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7636 | /* Check we compared all entries,if then take the first slot now */ |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7637 | if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0; |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7638 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7639 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7640 | { |
| 7641 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7642 | vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7643 | pmksa->bssid, ETHER_ADDR_LEN); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7644 | vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7645 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7646 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7647 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.", |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7648 | __func__, PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7649 | dump_bssid(pmksa->bssid); |
| 7650 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7651 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7652 | // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7653 | if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7654 | } |
| 7655 | |
| 7656 | |
| 7657 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7658 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7659 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7660 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.", |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7661 | __func__, PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7662 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7663 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7664 | PMKIDCache, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7665 | PMKIDCacheIndex); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7666 | return 0; |
| 7667 | } |
| 7668 | |
| 7669 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7670 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7671 | 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] | 7672 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7673 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7674 | tANI_U32 j=0; |
| 7675 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7676 | tHalHandle halHandle; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7677 | tANI_U8 BSSIDMatched = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7678 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7679 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7680 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7681 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR, |
| 7682 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7683 | |
| 7684 | /* Validate pAdapter */ |
| 7685 | if (NULL == pAdapter) |
| 7686 | { |
| 7687 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
| 7688 | return -EINVAL; |
| 7689 | } |
| 7690 | |
| 7691 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7692 | status = wlan_hdd_validate_context(pHddCtx); |
| 7693 | |
| 7694 | if (0 != status) |
| 7695 | { |
| 7696 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7697 | "%s: HDD context is not valid", __func__); |
| 7698 | return status; |
| 7699 | } |
| 7700 | |
| 7701 | /*Retrieve halHandle*/ |
| 7702 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7703 | |
| 7704 | /*in case index is 0,no entry to delete*/ |
| 7705 | if (0 == PMKIDCacheIndex) |
| 7706 | { |
| 7707 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" , |
| 7708 | __func__); |
| 7709 | return -EINVAL; |
| 7710 | } |
| 7711 | |
| 7712 | /*find the matching PMKSA entry from j=0 to (index-1), |
| 7713 | * and delete the matched one |
| 7714 | */ |
| 7715 | for (j = 0; j<PMKIDCacheIndex; j++) |
| 7716 | { |
| 7717 | if (vos_mem_compare(PMKIDCache[j].BSSID, |
| 7718 | pmksa->bssid, |
| 7719 | WNI_CFG_BSSID_LEN)) |
| 7720 | { |
| 7721 | /* BSSID matched entry */ |
| 7722 | BSSIDMatched = 1; |
| 7723 | |
| 7724 | if (j<PMKIDCacheIndex-1) |
| 7725 | { |
| 7726 | /*replace the matching entry with the last entry in HDD local cache*/ |
| 7727 | vos_mem_copy(PMKIDCache[j].BSSID, |
| 7728 | PMKIDCache[PMKIDCacheIndex-1].BSSID, |
| 7729 | WNI_CFG_BSSID_LEN); |
| 7730 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7731 | PMKIDCache[PMKIDCacheIndex-1].PMKID, |
| 7732 | CSR_RSN_PMKID_SIZE); |
| 7733 | } |
| 7734 | |
| 7735 | /*clear the last entry in HDD cache ---[index-1]*/ |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7736 | vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN); |
| 7737 | vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE); |
| 7738 | |
| 7739 | /*reduce the PMKID array index*/ |
| 7740 | PMKIDCacheIndex--; |
| 7741 | |
| 7742 | /*delete the last PMKID cache in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7743 | if (eHAL_STATUS_SUCCESS != |
| 7744 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7745 | { |
| 7746 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.", |
| 7747 | __func__,PMKIDCacheIndex); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7748 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7749 | } |
| 7750 | |
| 7751 | dump_bssid(pmksa->bssid); |
| 7752 | dump_pmkid(halHandle,pmksa->pmkid); |
| 7753 | |
| 7754 | break; |
| 7755 | } |
| 7756 | } |
| 7757 | |
| 7758 | /* we compare all entries,but cannot find matching entry */ |
| 7759 | if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched) |
| 7760 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7761 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7762 | "%s: No such PMKSA entry existed " MAC_ADDRESS_STR, |
| 7763 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7764 | dump_bssid(pmksa->bssid); |
| 7765 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7766 | return -EINVAL; |
| 7767 | } |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7768 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7769 | } |
| 7770 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7771 | |
| 7772 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7773 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 7774 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7775 | tANI_U32 j=0; |
| 7776 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7777 | tHalHandle halHandle; |
| 7778 | hdd_context_t *pHddCtx; |
| 7779 | tANI_U8 *pBSSId; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7780 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7781 | |
| 7782 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__); |
| 7783 | |
| 7784 | /* Validate pAdapter */ |
| 7785 | if (NULL == pAdapter) |
| 7786 | { |
| 7787 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7788 | "%s: Invalid Adapter" ,__func__); |
| 7789 | return -EINVAL; |
| 7790 | } |
| 7791 | |
| 7792 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7793 | status = wlan_hdd_validate_context(pHddCtx); |
| 7794 | |
| 7795 | if (0 != status) |
| 7796 | { |
| 7797 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7798 | "%s: HDD context is not valid", __func__); |
| 7799 | return status; |
| 7800 | } |
| 7801 | |
| 7802 | /*Retrieve halHandle*/ |
| 7803 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7804 | |
| 7805 | /*in case index is 0,no entry to delete*/ |
| 7806 | if (0 == PMKIDCacheIndex) |
| 7807 | { |
| 7808 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" , |
| 7809 | __func__); |
| 7810 | return -EINVAL; |
| 7811 | } |
| 7812 | |
| 7813 | /*delete all the PMKSA one by one */ |
| 7814 | for (j = 0; j<PMKIDCacheIndex; j++) |
| 7815 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7816 | pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7817 | |
| 7818 | /*delete the PMKID in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7819 | if (eHAL_STATUS_SUCCESS != |
| 7820 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7821 | { |
| 7822 | hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.", |
| 7823 | __func__,j); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7824 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7825 | } |
Kiet Lam | 8d21d5b | 2013-10-31 17:18:29 +0530 | [diff] [blame] | 7826 | /*clear the entry in HDD cache 0--index-1 */ |
| 7827 | vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN); |
| 7828 | vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7829 | } |
| 7830 | |
| 7831 | PMKIDCacheIndex = 0; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7832 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7833 | } |
| 7834 | #endif |
| 7835 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7836 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7837 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7838 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 7839 | { |
| 7840 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7841 | hdd_station_ctx_t *pHddStaCtx; |
| 7842 | |
| 7843 | if (NULL == pAdapter) |
| 7844 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7845 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7846 | return -ENODEV; |
| 7847 | } |
| 7848 | |
| 7849 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7850 | |
| 7851 | // Added for debug on reception of Re-assoc Req. |
| 7852 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 7853 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7854 | 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] | 7855 | ftie->ie_len); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7856 | hddLog(LOGE, FL("Should be Re-assoc Req IEs")); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7857 | } |
| 7858 | |
| 7859 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7860 | hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7861 | ftie->ie_len); |
| 7862 | #endif |
| 7863 | |
| 7864 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7865 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 7866 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7867 | ftie->ie_len); |
| 7868 | return 0; |
| 7869 | } |
| 7870 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7871 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7872 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7873 | |
| 7874 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 7875 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7876 | { |
| 7877 | int ret; |
| 7878 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 7879 | hdd_context_t *pHddCtx; |
| 7880 | |
| 7881 | if (NULL == pAdapter) |
| 7882 | { |
| 7883 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7884 | "%s: HDD adapter is Null", __func__); |
| 7885 | return ; |
| 7886 | } |
| 7887 | |
| 7888 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7889 | if (NULL == pHddCtx) |
| 7890 | { |
| 7891 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7892 | "%s: HDD context is Null!!!", __func__); |
| 7893 | return ; |
| 7894 | } |
| 7895 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7896 | spin_lock(&pHddCtx->schedScan_lock); |
| 7897 | if (TRUE == pHddCtx->isWiphySuspended) |
| 7898 | { |
| 7899 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 7900 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7901 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7902 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 7903 | return ; |
| 7904 | } |
| 7905 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7906 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7907 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7908 | |
| 7909 | if (0 > ret) |
| 7910 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7911 | |
| 7912 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7913 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7914 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7915 | } |
| 7916 | |
| 7917 | /* |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7918 | * FUNCTION: wlan_hdd_is_pno_allowed |
| 7919 | * To check is there any P2P GO/SAP or P2P Client/STA |
| 7920 | * session is active |
| 7921 | */ |
| 7922 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter) |
| 7923 | { |
| 7924 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7925 | hdd_adapter_t *pTempAdapter = NULL; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7926 | hdd_station_ctx_t *pStaCtx; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7927 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7928 | int status = 0; |
| 7929 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 7930 | |
| 7931 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)) |
| 7932 | { |
| 7933 | pTempAdapter = pAdapterNode->pAdapter; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7934 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7935 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7936 | if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode) |
| 7937 | && (eConnectionState_NotConnected != pStaCtx->conn_info.connState)) |
| 7938 | || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode) |
| 7939 | || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode) |
| 7940 | || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode) |
| 7941 | ) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7942 | { |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7943 | return eHAL_STATUS_FAILURE; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7944 | } |
| 7945 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7946 | pAdapterNode = pNext; |
| 7947 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7948 | return eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7949 | } |
| 7950 | |
| 7951 | /* |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7952 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7953 | * NL interface to enable PNO |
| 7954 | */ |
| 7955 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7956 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7957 | { |
| 7958 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7959 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7960 | hdd_context_t *pHddCtx; |
| 7961 | tHalHandle hHal; |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 7962 | v_U32_t i, indx, num_ch, tempInterval; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7963 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7964 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7965 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7966 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7967 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7968 | |
| 7969 | if (NULL == pAdapter) |
| 7970 | { |
| 7971 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7972 | "%s: HDD adapter is Null", __func__); |
| 7973 | return -ENODEV; |
| 7974 | } |
| 7975 | |
| 7976 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7977 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7978 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7979 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7980 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7981 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7982 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7983 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7984 | } |
| 7985 | |
| 7986 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7987 | if (NULL == hHal) |
| 7988 | { |
| 7989 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7990 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7991 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7992 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7993 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7994 | /* The current firmware design for PNO does not consider concurrent |
| 7995 | * active sessions.Hence , determine the concurrent active sessions |
| 7996 | * and return a failure to the framework on a request for schedule |
| 7997 | * scan. |
| 7998 | */ |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7999 | if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter)) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8000 | { |
| 8001 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8002 | FL("Cannot handle sched_scan")); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8003 | return -EBUSY; |
| 8004 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8005 | |
| 8006 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 8007 | if (NULL == pPnoRequest) |
| 8008 | { |
| 8009 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8010 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8011 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8012 | } |
| 8013 | |
Madan Mohan Koyyalamudi | c3f0435 | 2013-09-26 19:21:48 +0530 | [diff] [blame] | 8014 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8015 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 8016 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 8017 | |
| 8018 | if (( !pPnoRequest->ucNetworksCount ) || |
| 8019 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 8020 | { |
| 8021 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8022 | "Network input is not correct"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8023 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8024 | goto error; |
| 8025 | } |
| 8026 | |
| 8027 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 8028 | { |
| 8029 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8030 | "Incorrect number of channels"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8031 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8032 | goto error; |
| 8033 | } |
| 8034 | |
| 8035 | /* Framework provides one set of channels(all) |
| 8036 | * common for all saved profile */ |
| 8037 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 8038 | channels_allowed, &num_channels_allowed)) |
| 8039 | { |
| 8040 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8041 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8042 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8043 | goto error; |
| 8044 | } |
| 8045 | /* Checking each channel against allowed channel list */ |
| 8046 | num_ch = 0; |
| 8047 | for (i = 0; i < request->n_channels; i++) |
| 8048 | { |
| 8049 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 8050 | { |
| 8051 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 8052 | { |
| 8053 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 8054 | break ; |
| 8055 | } |
| 8056 | } |
| 8057 | } |
| 8058 | |
| 8059 | /* Filling per profile params */ |
| 8060 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 8061 | { |
| 8062 | pPnoRequest->aNetworks[i].ssId.length = |
| 8063 | request->match_sets[i].ssid.ssid_len; |
| 8064 | |
| 8065 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 8066 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 8067 | { |
| 8068 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8069 | "SSID Len %d is not correct for network %d", |
| 8070 | pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8071 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8072 | goto error; |
| 8073 | } |
| 8074 | |
| 8075 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 8076 | request->match_sets[i].ssid.ssid, |
| 8077 | request->match_sets[i].ssid.ssid_len); |
| 8078 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 8079 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 8080 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 8081 | |
| 8082 | /*Copying list of valid channel into request */ |
| 8083 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 8084 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 8085 | |
| 8086 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 8087 | } |
| 8088 | |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 8089 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 8090 | "request->ie_len = %zu", request->ie_len); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 8091 | if ((0 < request->ie_len) && (NULL != request->ie)) |
| 8092 | { |
| 8093 | pPnoRequest->us24GProbeTemplateLen = request->ie_len; |
| 8094 | memcpy(&pPnoRequest->p24GProbeTemplate, request->ie, |
| 8095 | pPnoRequest->us24GProbeTemplateLen); |
| 8096 | |
| 8097 | pPnoRequest->us5GProbeTemplateLen = request->ie_len; |
| 8098 | memcpy(&pPnoRequest->p5GProbeTemplate, request->ie, |
| 8099 | pPnoRequest->us5GProbeTemplateLen); |
| 8100 | } |
| 8101 | |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 8102 | /* Driver gets only one time interval which is hardcoded in |
| 8103 | * supplicant for 10000ms. Taking power consumption into account 6 timers |
| 8104 | * will be used, Timervalue is increased exponentially i.e 10,20,40, |
| 8105 | * 80,160,320 secs. And number of scan cycle for each timer |
| 8106 | * is configurable through INI param gPNOScanTimerRepeatValue. |
| 8107 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 8108 | * will be repeated after each interval specified by supplicant |
| 8109 | * till PNO is disabled. |
| 8110 | */ |
| 8111 | if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue) |
| 8112 | pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 8113 | else |
| 8114 | pPnoRequest->scanTimers.ucScanTimersCount = |
| 8115 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 8116 | |
| 8117 | tempInterval = (request->interval)/1000; |
| 8118 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8119 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 8120 | tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue); |
| 8121 | for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++) |
| 8122 | { |
| 8123 | pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat = |
| 8124 | pHddCtx->cfg_ini->configPNOScanTimerRepeatValue; |
| 8125 | pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval; |
| 8126 | tempInterval *= 2; |
| 8127 | } |
| 8128 | //Repeat last timer until pno disabled. |
| 8129 | pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
| 8130 | |
Madan Mohan Koyyalamudi | d206c7b | 2013-09-26 22:54:51 +0530 | [diff] [blame] | 8131 | pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8132 | |
| 8133 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8134 | pPnoRequest, pAdapter->sessionId, |
| 8135 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 8136 | if (eHAL_STATUS_SUCCESS != status) |
| 8137 | { |
| 8138 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8139 | "Failed to enable PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8140 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8141 | goto error; |
| 8142 | } |
| 8143 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8144 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8145 | "PNO scanRequest offloaded"); |
| 8146 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8147 | error: |
| 8148 | vos_mem_free(pPnoRequest); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8149 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8150 | } |
| 8151 | |
| 8152 | /* |
| 8153 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 8154 | * NL interface to disable PNO |
| 8155 | */ |
| 8156 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 8157 | struct net_device *dev) |
| 8158 | { |
| 8159 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8160 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8161 | hdd_context_t *pHddCtx; |
| 8162 | tHalHandle hHal; |
| 8163 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8164 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8165 | |
| 8166 | ENTER(); |
| 8167 | |
| 8168 | if (NULL == pAdapter) |
| 8169 | { |
| 8170 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8171 | "%s: HDD adapter is Null", __func__); |
| 8172 | return -ENODEV; |
| 8173 | } |
| 8174 | |
| 8175 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8176 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8177 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8178 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8179 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8180 | "%s: HDD context is Null", __func__); |
| 8181 | return -ENODEV; |
| 8182 | } |
| 8183 | |
| 8184 | /* The return 0 is intentional when isLogpInProgress and |
| 8185 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 8186 | * failure in sched_scan_stop , especially for a case where the unload |
| 8187 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 8188 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 8189 | * success. If it returns a failure , then its next invocation due to the |
| 8190 | * clean up of the second interface will have the dev pointer corresponding |
| 8191 | * to the first one leading to a crash. |
| 8192 | */ |
| 8193 | if (pHddCtx->isLogpInProgress) |
| 8194 | { |
| 8195 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8196 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8197 | return ret; |
| 8198 | } |
| 8199 | |
| 8200 | if (pHddCtx->isLoadUnloadInProgress) |
| 8201 | { |
| 8202 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8203 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 8204 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8205 | } |
| 8206 | |
| 8207 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8208 | if (NULL == hHal) |
| 8209 | { |
| 8210 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8211 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8212 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8213 | } |
| 8214 | |
| 8215 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 8216 | if (NULL == pPnoRequest) |
| 8217 | { |
| 8218 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8219 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8220 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8221 | } |
| 8222 | |
| 8223 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 8224 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 8225 | pPnoRequest->ucNetworksCount = 0; |
| 8226 | |
| 8227 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 8228 | pAdapter->sessionId, |
| 8229 | NULL, pAdapter); |
| 8230 | if (eHAL_STATUS_SUCCESS != status) |
| 8231 | { |
| 8232 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8233 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8234 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8235 | } |
| 8236 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8237 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8238 | "%s: PNO scan disabled", __func__); |
| 8239 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8240 | vos_mem_free(pPnoRequest); |
| 8241 | |
| 8242 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8243 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8244 | } |
| 8245 | |
| 8246 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 8247 | |
| 8248 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8249 | #ifdef FEATURE_WLAN_TDLS |
| 8250 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 8251 | u8 *peer, u8 action_code, u8 dialog_token, |
| 8252 | u16 status_code, const u8 *buf, size_t len) |
| 8253 | { |
| 8254 | |
| 8255 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8256 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8257 | u8 peerMac[6]; |
| 8258 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8259 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8260 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8261 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8262 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8263 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8264 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8265 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8266 | "Invalid arguments"); |
| 8267 | return -EINVAL; |
| 8268 | } |
| 8269 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8270 | if (pHddCtx->isLogpInProgress) |
| 8271 | { |
| 8272 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8273 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8274 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8275 | return -EBUSY; |
| 8276 | } |
| 8277 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8278 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8279 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8280 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 8281 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 8282 | MAC_ADDRESS_STR " action %d declined.", |
| 8283 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8284 | return -ENOTSUPP; |
| 8285 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8286 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8287 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 8288 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 8289 | { |
| 8290 | /* if tdls_mode is disabled to respond to peer's request */ |
| 8291 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 8292 | { |
| 8293 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 8294 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8295 | " TDLS mode is disabled. action %d declined.", |
| 8296 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8297 | |
| 8298 | return -ENOTSUPP; |
| 8299 | } |
| 8300 | } |
| 8301 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8302 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 8303 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8304 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8305 | { |
| 8306 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8307 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8308 | " TDLS setup is ongoing. action %d declined.", |
| 8309 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 8310 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8311 | } |
| 8312 | } |
| 8313 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8314 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 8315 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8316 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8317 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8318 | { |
| 8319 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 8320 | we return error code at 'add_station()'. Hence we have this |
| 8321 | check again in addtion to add_station(). |
| 8322 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8323 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8324 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8325 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8326 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8327 | " TDLS Max peer already connected. action %d declined.", |
| 8328 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8329 | return -EINVAL; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8330 | } |
| 8331 | else |
| 8332 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8333 | /* maximum reached. tweak to send error code to peer and return |
| 8334 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8335 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8336 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8337 | "%s: " MAC_ADDRESS_STR |
| 8338 | " TDLS Max peer already connected send response status %d", |
| 8339 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8340 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8341 | /* fall through to send setup resp with failure status |
| 8342 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8343 | } |
| 8344 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8345 | else |
| 8346 | { |
| 8347 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8348 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8349 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8350 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8351 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8352 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 8353 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8354 | return -EPERM; |
| 8355 | } |
| 8356 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8357 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8358 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8359 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8360 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 8361 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8362 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 8363 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 8364 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8365 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8366 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8367 | /*Except teardown responder will not be used so just make 0*/ |
| 8368 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8369 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8370 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8371 | |
| 8372 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8373 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8374 | |
| 8375 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 8376 | responder = pTdlsPeer->is_responder; |
| 8377 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8378 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8379 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8380 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 8381 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 8382 | dialog_token, status_code, len); |
| 8383 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8384 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8385 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8386 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8387 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 8388 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8389 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8390 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 8391 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8392 | { |
| 8393 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 8394 | { |
| 8395 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8396 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8397 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 8398 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8399 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 8400 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8401 | } |
| 8402 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8403 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 8404 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 8405 | { |
| 8406 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8407 | "%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] | 8408 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 8409 | return -EBUSY; |
| 8410 | } |
| 8411 | |
| 8412 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8413 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 8414 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8415 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8416 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8417 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8418 | if (VOS_STATUS_SUCCESS != status) |
| 8419 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8420 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8421 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8422 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8423 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8424 | return -EINVAL; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8425 | } |
| 8426 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8427 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 8428 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 8429 | |
| 8430 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8431 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8432 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8433 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %u", |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8434 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8435 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame^] | 8436 | |
| 8437 | if (pHddCtx->isLogpInProgress) |
| 8438 | { |
| 8439 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8440 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8441 | return -EAGAIN; |
| 8442 | } |
| 8443 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8444 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8445 | return -EINVAL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8446 | } |
| 8447 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8448 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8449 | { |
| 8450 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8451 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8452 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8453 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8454 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 8455 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8456 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8457 | } |
| 8458 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 8459 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8460 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8461 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8462 | |
| 8463 | return 0; |
| 8464 | } |
| 8465 | |
| 8466 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 8467 | u8 *peer, enum nl80211_tdls_operation oper) |
| 8468 | { |
| 8469 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8470 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8471 | int status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8472 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8473 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8474 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8475 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8476 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8477 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8478 | return -EINVAL; |
| 8479 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8480 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8481 | status = wlan_hdd_validate_context(pHddCtx); |
| 8482 | |
| 8483 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8484 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8485 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8486 | "%s: HDD context is not valid", __func__); |
| 8487 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8488 | } |
| 8489 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8490 | |
| 8491 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8492 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8493 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8494 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8495 | "TDLS Disabled in INI OR not enabled in FW. " |
| 8496 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8497 | return -ENOTSUPP; |
| 8498 | } |
| 8499 | |
| 8500 | switch (oper) { |
| 8501 | case NL80211_TDLS_ENABLE_LINK: |
| 8502 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8503 | VOS_STATUS status; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8504 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8505 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8506 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8507 | |
| 8508 | if ( NULL == pTdlsPeer ) { |
| 8509 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 8510 | " (oper %d) not exsting. ignored", |
| 8511 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 8512 | return -EINVAL; |
| 8513 | } |
| 8514 | |
| 8515 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8516 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 8517 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 8518 | "NL80211_TDLS_ENABLE_LINK"); |
| 8519 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 8520 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 8521 | { |
| 8522 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 8523 | MAC_ADDRESS_STR " failed", |
| 8524 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 8525 | return -EINVAL; |
| 8526 | } |
| 8527 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8528 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8529 | { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 8530 | long ret; |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8531 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 8532 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8533 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 8534 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 8535 | return -EINVAL; |
| 8536 | } |
| 8537 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8538 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8539 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8540 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 8541 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 8542 | * register with the TL on after the response for this operation |
| 8543 | * is received . |
| 8544 | */ |
| 8545 | ret = wait_for_completion_interruptible_timeout( |
| 8546 | &pAdapter->tdls_link_establish_req_comp, |
| 8547 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 8548 | if (ret <= 0) |
| 8549 | { |
| 8550 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8551 | "%s: Link Establish Request Faled Status %ld", |
| 8552 | __func__, ret); |
| 8553 | return -EINVAL; |
| 8554 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8555 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8556 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 8557 | /* Mark TDLS client Authenticated .*/ |
| 8558 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 8559 | pTdlsPeer->staId, |
| 8560 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8561 | if (VOS_STATUS_SUCCESS == status) |
| 8562 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8563 | if (pTdlsPeer->is_responder == 0) |
| 8564 | { |
| 8565 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 8566 | |
| 8567 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 8568 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 8569 | WAIT_TIME_TDLS_INITIATOR); |
| 8570 | /* suspend initiator TX until it receives direct packet from the |
| 8571 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 8572 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 8573 | &staId, NULL); |
| 8574 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8575 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 8576 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8577 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8578 | |
| 8579 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 8580 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 8581 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8582 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 8583 | int ac; |
| 8584 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 8585 | WLANTL_AC_VI, |
| 8586 | WLANTL_AC_BK, |
| 8587 | WLANTL_AC_BE }; |
| 8588 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 8589 | for(ac=0; ac < 4; ac++) |
| 8590 | { |
| 8591 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 8592 | pTdlsPeer->staId, ucAc[ac], |
| 8593 | tlTid[ac], tlTid[ac], 0, 0, |
| 8594 | WLANTL_BI_DIR ); |
| 8595 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8596 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8597 | } |
| 8598 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8599 | } |
| 8600 | break; |
| 8601 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8602 | { |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8603 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8604 | |
| 8605 | if ( NULL == pTdlsPeer ) { |
| 8606 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 8607 | " (oper %d) not exsting. ignored", |
| 8608 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 8609 | return -EINVAL; |
| 8610 | } |
| 8611 | |
| 8612 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8613 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 8614 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 8615 | "NL80211_TDLS_DISABLE_LINK"); |
| 8616 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8617 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8618 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8619 | long status; |
| 8620 | |
| 8621 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 8622 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8623 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8624 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8625 | |
| 8626 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 8627 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 8628 | if (status <= 0) |
| 8629 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8630 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8632 | "%s: Del station failed status %ld", |
| 8633 | __func__, status); |
| 8634 | return -EPERM; |
| 8635 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8636 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8637 | } |
| 8638 | else |
| 8639 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8640 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8641 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8642 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8643 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8644 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8645 | case NL80211_TDLS_TEARDOWN: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8646 | { |
| 8647 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8648 | " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR, |
| 8649 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8650 | |
| 8651 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 8652 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 8653 | |
| 8654 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8655 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 8656 | __func__); |
| 8657 | return -ENOTSUPP; |
| 8658 | } |
| 8659 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8660 | |
| 8661 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8662 | |
| 8663 | if ( NULL == pTdlsPeer ) { |
| 8664 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR |
| 8665 | " peer not exsting", |
| 8666 | __func__, MAC_ADDR_ARRAY(peer)); |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8667 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8668 | } |
| 8669 | else { |
| 8670 | wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, |
| 8671 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 8672 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8673 | |
| 8674 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) |
| 8675 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8676 | break; |
| 8677 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8678 | case NL80211_TDLS_SETUP: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8679 | { |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8680 | hddTdlsPeer_t *pTdlsPeer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8681 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8682 | " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR, |
| 8683 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8684 | |
| 8685 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 8686 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 8687 | |
| 8688 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8689 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 8690 | __func__); |
| 8691 | return -ENOTSUPP; |
| 8692 | } |
| 8693 | |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8694 | /* To cater the requirement of establishing the TDLS link |
| 8695 | * irrespective of the data traffic , get an entry of TDLS peer. |
| 8696 | */ |
| 8697 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer); |
| 8698 | if (pTdlsPeer == NULL) { |
| 8699 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8700 | "%s: peer " MAC_ADDRESS_STR " not existing", |
| 8701 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8702 | return -EINVAL; |
| 8703 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8704 | |
| 8705 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) { |
| 8706 | |
| 8707 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8708 | " %s TDLS Add Force Peer Failed", |
| 8709 | __func__); |
| 8710 | return -EINVAL; |
| 8711 | } |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8712 | break; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8713 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8714 | case NL80211_TDLS_DISCOVERY_REQ: |
| 8715 | /* We don't support in-driver setup/teardown/discovery */ |
| 8716 | return -ENOTSUPP; |
| 8717 | default: |
| 8718 | return -ENOTSUPP; |
| 8719 | } |
| 8720 | return 0; |
| 8721 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8722 | |
| 8723 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 8724 | struct net_device *dev, u8 *peer) |
| 8725 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 8726 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8727 | "tdls send discover req: "MAC_ADDRESS_STR, |
| 8728 | MAC_ADDR_ARRAY(peer)); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8729 | |
| 8730 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 8731 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 8732 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8733 | #endif |
| 8734 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8735 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8736 | /* |
| 8737 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 8738 | * Callback rountine called upon receiving response for |
| 8739 | * get offload info |
| 8740 | */ |
| 8741 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 8742 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 8743 | { |
| 8744 | |
| 8745 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8746 | tANI_U8 tempReplayCounter[8]; |
| 8747 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8748 | |
| 8749 | ENTER(); |
| 8750 | |
| 8751 | if (NULL == pAdapter) |
| 8752 | { |
| 8753 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8754 | "%s: HDD adapter is Null", __func__); |
| 8755 | return ; |
| 8756 | } |
| 8757 | |
| 8758 | if (NULL == pGtkOffloadGetInfoRsp) |
| 8759 | { |
| 8760 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8761 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 8762 | return ; |
| 8763 | } |
| 8764 | |
| 8765 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 8766 | { |
| 8767 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8768 | "%s: wlan Failed to get replay counter value", |
| 8769 | __func__); |
| 8770 | return ; |
| 8771 | } |
| 8772 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8773 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8774 | /* Update replay counter */ |
| 8775 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 8776 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 8777 | |
| 8778 | { |
| 8779 | /* changing from little to big endian since supplicant |
| 8780 | * works on big endian format |
| 8781 | */ |
| 8782 | int i; |
| 8783 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 8784 | |
| 8785 | for (i = 0; i < 8; i++) |
| 8786 | { |
| 8787 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 8788 | } |
| 8789 | } |
| 8790 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8791 | /* Update replay counter to NL */ |
| 8792 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8793 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8794 | } |
| 8795 | |
| 8796 | /* |
| 8797 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 8798 | * This function is used to offload GTK rekeying job to the firmware. |
| 8799 | */ |
| 8800 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 8801 | struct cfg80211_gtk_rekey_data *data) |
| 8802 | { |
| 8803 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8804 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8805 | hdd_station_ctx_t *pHddStaCtx; |
| 8806 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8807 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8808 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8809 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8810 | |
| 8811 | ENTER(); |
| 8812 | |
| 8813 | if (NULL == pAdapter) |
| 8814 | { |
| 8815 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8816 | "%s: HDD adapter is Null", __func__); |
| 8817 | return -ENODEV; |
| 8818 | } |
| 8819 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8820 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8821 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8822 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8823 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8825 | "%s: HDD context is not valid", __func__); |
| 8826 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8827 | } |
| 8828 | |
| 8829 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8830 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8831 | if (NULL == hHal) |
| 8832 | { |
| 8833 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8834 | "%s: HAL context is Null!!!", __func__); |
| 8835 | return -EAGAIN; |
| 8836 | } |
| 8837 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8838 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 8839 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 8840 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 8841 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8842 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8843 | { |
| 8844 | /* changing from big to little endian since driver |
| 8845 | * works on little endian format |
| 8846 | */ |
| 8847 | tANI_U8 *p = |
| 8848 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 8849 | int i; |
| 8850 | |
| 8851 | for (i = 0; i < 8; i++) |
| 8852 | { |
| 8853 | p[7-i] = data->replay_ctr[i]; |
| 8854 | } |
| 8855 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8856 | |
| 8857 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 8858 | { |
| 8859 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8860 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 8861 | sizeof (tSirGtkOffloadParams)); |
| 8862 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8863 | pAdapter->sessionId); |
| 8864 | |
| 8865 | if (eHAL_STATUS_SUCCESS != status) |
| 8866 | { |
| 8867 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8868 | "%s: sme_SetGTKOffload failed, returned %d", |
| 8869 | __func__, status); |
| 8870 | return status; |
| 8871 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8872 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8873 | "%s: sme_SetGTKOffload successfull", __func__); |
| 8874 | } |
| 8875 | else |
| 8876 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8877 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8878 | "%s: wlan not suspended GTKOffload request is stored", |
| 8879 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8880 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8881 | |
| 8882 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8883 | } |
| 8884 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 8885 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8886 | /* |
| 8887 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 8888 | * This function is used to set access control policy |
| 8889 | */ |
| 8890 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 8891 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 8892 | { |
| 8893 | int i; |
| 8894 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8895 | hdd_hostapd_state_t *pHostapdState; |
| 8896 | tsap_Config_t *pConfig; |
| 8897 | v_CONTEXT_t pVosContext = NULL; |
| 8898 | hdd_context_t *pHddCtx; |
| 8899 | int status; |
| 8900 | |
| 8901 | ENTER(); |
| 8902 | |
| 8903 | if (NULL == pAdapter) |
| 8904 | { |
| 8905 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8906 | "%s: HDD adapter is Null", __func__); |
| 8907 | return -ENODEV; |
| 8908 | } |
| 8909 | |
| 8910 | if (NULL == params) |
| 8911 | { |
| 8912 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8913 | "%s: params is Null", __func__); |
| 8914 | return -EINVAL; |
| 8915 | } |
| 8916 | |
| 8917 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8918 | status = wlan_hdd_validate_context(pHddCtx); |
| 8919 | |
| 8920 | if (0 != status) |
| 8921 | { |
| 8922 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8923 | "%s: HDD context is not valid", __func__); |
| 8924 | return status; |
| 8925 | } |
| 8926 | |
| 8927 | pVosContext = pHddCtx->pvosContext; |
| 8928 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8929 | |
| 8930 | if (NULL == pHostapdState) |
| 8931 | { |
| 8932 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8933 | "%s: pHostapdState is Null", __func__); |
| 8934 | return -EINVAL; |
| 8935 | } |
| 8936 | |
| 8937 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 8938 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 8939 | |
| 8940 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 8941 | { |
| 8942 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 8943 | |
| 8944 | /* default value */ |
| 8945 | pConfig->num_accept_mac = 0; |
| 8946 | pConfig->num_deny_mac = 0; |
| 8947 | |
| 8948 | /** |
| 8949 | * access control policy |
| 8950 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 8951 | * listed in hostapd.deny file. |
| 8952 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 8953 | * listed in hostapd.accept file. |
| 8954 | */ |
| 8955 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 8956 | { |
| 8957 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 8958 | } |
| 8959 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 8960 | { |
| 8961 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 8962 | } |
| 8963 | else |
| 8964 | { |
| 8965 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8966 | "%s:Acl Policy : %d is not supported", |
| 8967 | __func__, params->acl_policy); |
| 8968 | return -ENOTSUPP; |
| 8969 | } |
| 8970 | |
| 8971 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 8972 | { |
| 8973 | pConfig->num_accept_mac = params->n_acl_entries; |
| 8974 | for (i = 0; i < params->n_acl_entries; i++) |
| 8975 | { |
| 8976 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8977 | "** Add ACL MAC entry %i in WhiletList :" |
| 8978 | MAC_ADDRESS_STR, i, |
| 8979 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8980 | |
| 8981 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 8982 | sizeof(qcmacaddr)); |
| 8983 | } |
| 8984 | } |
| 8985 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 8986 | { |
| 8987 | pConfig->num_deny_mac = params->n_acl_entries; |
| 8988 | for (i = 0; i < params->n_acl_entries; i++) |
| 8989 | { |
| 8990 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8991 | "** Add ACL MAC entry %i in BlackList :" |
| 8992 | MAC_ADDRESS_STR, i, |
| 8993 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8994 | |
| 8995 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 8996 | sizeof(qcmacaddr)); |
| 8997 | } |
| 8998 | } |
| 8999 | |
| 9000 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 9001 | { |
| 9002 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9003 | "%s: SAP Set Mac Acl fail", __func__); |
| 9004 | return -EINVAL; |
| 9005 | } |
| 9006 | } |
| 9007 | else |
| 9008 | { |
| 9009 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9010 | "%s: Invalid device_mode = %d", |
| 9011 | __func__, pAdapter->device_mode); |
| 9012 | return -EINVAL; |
| 9013 | } |
| 9014 | |
| 9015 | return 0; |
| 9016 | } |
| 9017 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9018 | #ifdef WLAN_NL80211_TESTMODE |
| 9019 | #ifdef FEATURE_WLAN_LPHB |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9020 | void wlan_hdd_cfg80211_lphb_ind_handler |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9021 | ( |
| 9022 | void *pAdapter, |
| 9023 | void *indCont |
| 9024 | ) |
| 9025 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9026 | tSirLPHBInd *lphbInd; |
| 9027 | struct sk_buff *skb; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9028 | |
| 9029 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9030 | "LPHB indication arrived"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9031 | |
| 9032 | if (NULL == indCont) |
| 9033 | { |
| 9034 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9035 | "LPHB IND, invalid argument"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9036 | return; |
| 9037 | } |
| 9038 | |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9039 | lphbInd = (tSirLPHBInd *)indCont; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9040 | skb = cfg80211_testmode_alloc_event_skb( |
| 9041 | ((hdd_adapter_t *)pAdapter)->wdev.wiphy, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9042 | sizeof(tSirLPHBInd), |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9043 | GFP_ATOMIC); |
| 9044 | if (!skb) |
| 9045 | { |
| 9046 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9047 | "LPHB timeout, NL buffer alloc fail"); |
| 9048 | return; |
| 9049 | } |
| 9050 | |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9051 | 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] | 9052 | { |
| 9053 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9054 | "WLAN_HDD_TM_ATTR_CMD put fail"); |
| 9055 | goto nla_put_failure; |
| 9056 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9057 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9058 | { |
| 9059 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9060 | "WLAN_HDD_TM_ATTR_TYPE put fail"); |
| 9061 | goto nla_put_failure; |
| 9062 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9063 | if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9064 | sizeof(tSirLPHBInd), lphbInd)) |
| 9065 | { |
| 9066 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9067 | "WLAN_HDD_TM_ATTR_DATA put fail"); |
| 9068 | goto nla_put_failure; |
| 9069 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9070 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 9071 | return; |
| 9072 | |
| 9073 | nla_put_failure: |
| 9074 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9075 | "NLA Put fail"); |
| 9076 | kfree_skb(skb); |
| 9077 | |
| 9078 | return; |
| 9079 | } |
| 9080 | #endif /* FEATURE_WLAN_LPHB */ |
| 9081 | |
| 9082 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 9083 | { |
| 9084 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 9085 | int err = 0; |
| 9086 | #ifdef FEATURE_WLAN_LPHB |
| 9087 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9088 | eHalStatus smeStatus; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9089 | #endif /* FEATURE_WLAN_LPHB */ |
| 9090 | |
| 9091 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 9092 | if (err) |
| 9093 | { |
| 9094 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9095 | "%s Testmode INV ATTR", __func__); |
| 9096 | return err; |
| 9097 | } |
| 9098 | |
| 9099 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 9100 | { |
| 9101 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9102 | "%s Testmode INV CMD", __func__); |
| 9103 | return -EINVAL; |
| 9104 | } |
| 9105 | |
| 9106 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 9107 | { |
| 9108 | #ifdef FEATURE_WLAN_LPHB |
| 9109 | /* Low Power Heartbeat configuration request */ |
| 9110 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 9111 | { |
| 9112 | int buf_len; |
| 9113 | void *buf; |
| 9114 | tSirLPHBReq *hb_params = NULL; |
| 9115 | |
| 9116 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 9117 | { |
| 9118 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9119 | "%s Testmode INV DATA", __func__); |
| 9120 | return -EINVAL; |
| 9121 | } |
| 9122 | |
| 9123 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 9124 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 9125 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 9126 | if (NULL == hb_params) |
| 9127 | { |
| 9128 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9129 | "%s Request Buffer Alloc Fail", __func__); |
| 9130 | return -EINVAL; |
| 9131 | } |
| 9132 | |
| 9133 | vos_mem_copy(hb_params, buf, buf_len); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9134 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 9135 | hb_params, |
| 9136 | wlan_hdd_cfg80211_lphb_ind_handler); |
| 9137 | if (eHAL_STATUS_SUCCESS != smeStatus) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9138 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9139 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9140 | "LPHB Config Fail, disable"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9141 | vos_mem_free(hb_params); |
| 9142 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9143 | return 0; |
| 9144 | } |
| 9145 | #endif /* FEATURE_WLAN_LPHB */ |
| 9146 | default: |
| 9147 | return -EOPNOTSUPP; |
| 9148 | } |
| 9149 | |
| 9150 | return err; |
| 9151 | } |
| 9152 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 9153 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9154 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 9155 | struct net_device *dev, |
| 9156 | int idx, struct survey_info *survey) |
| 9157 | { |
| 9158 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9159 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9160 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9161 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9162 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9163 | v_S7_t snr,rssi; |
| 9164 | int status, i, j, filled = 0; |
| 9165 | |
| 9166 | ENTER(); |
| 9167 | |
| 9168 | |
| 9169 | if (NULL == pAdapter) |
| 9170 | { |
| 9171 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9172 | "%s: HDD adapter is Null", __func__); |
| 9173 | return -ENODEV; |
| 9174 | } |
| 9175 | |
| 9176 | if (NULL == wiphy) |
| 9177 | { |
| 9178 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9179 | "%s: wiphy is Null", __func__); |
| 9180 | return -ENODEV; |
| 9181 | } |
| 9182 | |
| 9183 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9184 | status = wlan_hdd_validate_context(pHddCtx); |
| 9185 | |
| 9186 | if (0 != status) |
| 9187 | { |
| 9188 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9189 | "%s: HDD context is not valid", __func__); |
| 9190 | return status; |
| 9191 | } |
| 9192 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9193 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9194 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9195 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9196 | 0 != pAdapter->survey_idx || |
| 9197 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9198 | { |
| 9199 | /* The survey dump ops when implemented completely is expected to |
| 9200 | * return a survey of all channels and the ops is called by the |
| 9201 | * kernel with incremental values of the argument 'idx' till it |
| 9202 | * returns -ENONET. But we can only support the survey for the |
| 9203 | * operating channel for now. survey_idx is used to track |
| 9204 | * that the ops is called only once and then return -ENONET for |
| 9205 | * the next iteration |
| 9206 | */ |
| 9207 | pAdapter->survey_idx = 0; |
| 9208 | return -ENONET; |
| 9209 | } |
| 9210 | |
| 9211 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9212 | |
| 9213 | wlan_hdd_get_snr(pAdapter, &snr); |
| 9214 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 9215 | |
| 9216 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 9217 | hdd_wlan_get_freq(channel, &freq); |
| 9218 | |
| 9219 | |
| 9220 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 9221 | { |
| 9222 | if (NULL == wiphy->bands[i]) |
| 9223 | { |
| 9224 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 9225 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 9226 | continue; |
| 9227 | } |
| 9228 | |
| 9229 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 9230 | { |
| 9231 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 9232 | |
| 9233 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 9234 | { |
| 9235 | survey->channel = &band->channels[j]; |
| 9236 | /* The Rx BDs contain SNR values in dB for the received frames |
| 9237 | * while the supplicant expects noise. So we calculate and |
| 9238 | * return the value of noise (dBm) |
| 9239 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 9240 | */ |
| 9241 | survey->noise = rssi - snr; |
| 9242 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 9243 | filled = 1; |
| 9244 | } |
| 9245 | } |
| 9246 | } |
| 9247 | |
| 9248 | if (filled) |
| 9249 | pAdapter->survey_idx = 1; |
| 9250 | else |
| 9251 | { |
| 9252 | pAdapter->survey_idx = 0; |
| 9253 | return -ENONET; |
| 9254 | } |
| 9255 | |
| 9256 | return 0; |
| 9257 | } |
| 9258 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9259 | /* |
| 9260 | * FUNCTION: wlan_hdd_cfg80211_resume_wlan |
| 9261 | * this is called when cfg80211 driver resume |
| 9262 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 9263 | */ |
| 9264 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 9265 | { |
| 9266 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9267 | hdd_adapter_t *pAdapter; |
| 9268 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 9269 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9270 | |
| 9271 | ENTER(); |
| 9272 | |
| 9273 | if ( NULL == pHddCtx ) |
| 9274 | { |
| 9275 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9276 | "%s: HddCtx validation failed", __func__); |
| 9277 | return 0; |
| 9278 | } |
| 9279 | |
| 9280 | if (pHddCtx->isLogpInProgress) |
| 9281 | { |
| 9282 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9283 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 9284 | return 0; |
| 9285 | } |
| 9286 | |
| 9287 | if (pHddCtx->isLoadUnloadInProgress) |
| 9288 | { |
| 9289 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9290 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 9291 | return 0; |
| 9292 | } |
| 9293 | |
| 9294 | spin_lock(&pHddCtx->schedScan_lock); |
| 9295 | pHddCtx->isWiphySuspended = FALSE; |
| 9296 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 9297 | { |
| 9298 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9299 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9300 | "%s: Return resume is not due to PNO indication", __func__); |
| 9301 | return 0; |
| 9302 | } |
| 9303 | // Reset flag to avoid updatating cfg80211 data old results again |
| 9304 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 9305 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9306 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9307 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9308 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9309 | |
| 9310 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9311 | { |
| 9312 | pAdapter = pAdapterNode->pAdapter; |
| 9313 | if ( (NULL != pAdapter) && |
| 9314 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 9315 | { |
| 9316 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9317 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9318 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 9319 | "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9320 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9321 | else |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9322 | { |
| 9323 | /* Acquire wakelock to handle the case where APP's tries to |
| 9324 | * suspend immediately after updating the scan results. Whis |
| 9325 | * results in app's is in suspended state and not able to |
| 9326 | * process the connect request to AP |
| 9327 | */ |
| 9328 | hdd_prevent_suspend_timeout(2000); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9329 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9330 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9331 | |
| 9332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9333 | "%s : cfg80211 scan result database updated", __func__); |
| 9334 | |
| 9335 | return 0; |
| 9336 | |
| 9337 | } |
| 9338 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9339 | pAdapterNode = pNext; |
| 9340 | } |
| 9341 | |
| 9342 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9343 | "%s: Failed to find Adapter", __func__); |
| 9344 | return 0; |
| 9345 | } |
| 9346 | |
| 9347 | /* |
| 9348 | * FUNCTION: wlan_hdd_cfg80211_suspend_wlan |
| 9349 | * this is called when cfg80211 driver suspends |
| 9350 | */ |
| 9351 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 9352 | struct cfg80211_wowlan *wow) |
| 9353 | { |
| 9354 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9355 | |
| 9356 | ENTER(); |
| 9357 | if (NULL == pHddCtx) |
| 9358 | { |
| 9359 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9360 | "%s: HddCtx validation failed", __func__); |
| 9361 | return 0; |
| 9362 | } |
| 9363 | |
| 9364 | pHddCtx->isWiphySuspended = TRUE; |
| 9365 | |
| 9366 | EXIT(); |
| 9367 | |
| 9368 | return 0; |
| 9369 | } |
| 9370 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9371 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9372 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9373 | { |
| 9374 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 9375 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 9376 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 9377 | .change_station = wlan_hdd_change_station, |
| 9378 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 9379 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 9380 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 9381 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9382 | #else |
| 9383 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 9384 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 9385 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9386 | #endif |
| 9387 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 9388 | .add_key = wlan_hdd_cfg80211_add_key, |
| 9389 | .get_key = wlan_hdd_cfg80211_get_key, |
| 9390 | .del_key = wlan_hdd_cfg80211_del_key, |
| 9391 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9392 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9393 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9394 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9395 | .scan = wlan_hdd_cfg80211_scan, |
| 9396 | .connect = wlan_hdd_cfg80211_connect, |
| 9397 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 9398 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 9399 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 9400 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 9401 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 9402 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9403 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 9404 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 9405 | .mgmt_tx = wlan_hdd_action, |
| 9406 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 9407 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 9408 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 9409 | .set_txq_params = wlan_hdd_set_txq_params, |
| 9410 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9411 | .get_station = wlan_hdd_cfg80211_get_station, |
| 9412 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 9413 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9414 | .add_station = wlan_hdd_cfg80211_add_station, |
| 9415 | #ifdef FEATURE_WLAN_LFR |
| 9416 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 9417 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 9418 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 9419 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9420 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 9421 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 9422 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 9423 | #ifdef FEATURE_WLAN_TDLS |
| 9424 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 9425 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 9426 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9427 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 9428 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 9429 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9430 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9431 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 9432 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 9433 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9434 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 9435 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9436 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9437 | #ifdef WLAN_NL80211_TESTMODE |
| 9438 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 9439 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9440 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9441 | }; |
| 9442 | |