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__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2340 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2341 | } |
| 2342 | } |
| 2343 | |
Arun Kumar Khandavalli | a3bd800 | 2014-01-17 16:21:19 +0530 | [diff] [blame] | 2344 | hdd_hostapd_stop(dev); |
| 2345 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2346 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2347 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2348 | ) |
| 2349 | { |
| 2350 | beacon_data_t *old; |
| 2351 | |
| 2352 | old = pAdapter->sessionCtx.ap.beacon; |
| 2353 | |
| 2354 | if (!old) |
| 2355 | return -ENOENT; |
| 2356 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2357 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2358 | |
| 2359 | mutex_lock(&pHddCtx->sap_lock); |
| 2360 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2361 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2362 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2363 | { |
| 2364 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2365 | |
| 2366 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2367 | |
| 2368 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2369 | { |
| 2370 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2371 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2372 | VOS_ASSERT(0); |
| 2373 | } |
| 2374 | } |
| 2375 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2376 | } |
| 2377 | mutex_unlock(&pHddCtx->sap_lock); |
| 2378 | |
| 2379 | if(status != VOS_STATUS_SUCCESS) |
| 2380 | { |
| 2381 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2382 | "%s:Error!!! Stopping the BSS",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2383 | return -EINVAL; |
| 2384 | } |
| 2385 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2386 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2387 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2388 | ==eHAL_STATUS_FAILURE) |
| 2389 | { |
| 2390 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2391 | "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] | 2392 | } |
| 2393 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2394 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2395 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2396 | eANI_BOOLEAN_FALSE) ) |
| 2397 | { |
| 2398 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2399 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2400 | } |
| 2401 | |
| 2402 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2403 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2404 | |
| 2405 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2406 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2407 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2408 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2409 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2410 | { |
| 2411 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2412 | "GO got removed"); |
| 2413 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2414 | } |
| 2415 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2416 | } |
| 2417 | EXIT(); |
| 2418 | return status; |
| 2419 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2420 | |
| 2421 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2422 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2423 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2424 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2425 | struct cfg80211_ap_settings *params) |
| 2426 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2427 | hdd_adapter_t *pAdapter; |
| 2428 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2429 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2430 | |
| 2431 | ENTER(); |
| 2432 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2433 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2434 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2435 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2436 | "%s: Device is Null", __func__); |
| 2437 | return -ENODEV; |
| 2438 | } |
| 2439 | |
| 2440 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2441 | if (NULL == pAdapter) |
| 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: HDD adapter is Null", __func__); |
| 2445 | return -ENODEV; |
| 2446 | } |
| 2447 | |
| 2448 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2449 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2450 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2451 | "%s: HDD adapter magic is invalid", __func__); |
| 2452 | return -ENODEV; |
| 2453 | } |
| 2454 | |
| 2455 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2456 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2457 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2458 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2459 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2460 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2461 | "%s: HDD context is not valid", __func__); |
| 2462 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2463 | } |
| 2464 | |
| 2465 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2466 | __func__, pAdapter->device_mode); |
| 2467 | |
| 2468 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2469 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2470 | ) |
| 2471 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2472 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2473 | |
| 2474 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2475 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2476 | if (old) |
| 2477 | return -EALREADY; |
| 2478 | |
| 2479 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2480 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2481 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2482 | { |
| 2483 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2484 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2485 | return -EINVAL; |
| 2486 | } |
| 2487 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2488 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2489 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 2490 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2491 | params->channel, params->channel_type); |
| 2492 | #else |
| 2493 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 2494 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2495 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2496 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2497 | params->ssid_len, params->hidden_ssid); |
| 2498 | } |
| 2499 | |
| 2500 | EXIT(); |
| 2501 | return status; |
| 2502 | } |
| 2503 | |
| 2504 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2505 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2506 | struct net_device *dev, |
| 2507 | struct cfg80211_beacon_data *params) |
| 2508 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2509 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2510 | hdd_context_t *pHddCtx; |
| 2511 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2512 | |
| 2513 | ENTER(); |
| 2514 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2515 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2516 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2517 | |
| 2518 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2519 | status = wlan_hdd_validate_context(pHddCtx); |
| 2520 | |
| 2521 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2522 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2523 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2524 | "%s: HDD context is not valid", __func__); |
| 2525 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2526 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2527 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2528 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2529 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2530 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2531 | { |
| 2532 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2533 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2534 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2535 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2536 | if (!old) |
| 2537 | return -ENOENT; |
| 2538 | |
| 2539 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2540 | |
| 2541 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2542 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2543 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2544 | return -EINVAL; |
| 2545 | } |
| 2546 | |
| 2547 | pAdapter->sessionCtx.ap.beacon = new; |
| 2548 | |
| 2549 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2550 | } |
| 2551 | |
| 2552 | EXIT(); |
| 2553 | return status; |
| 2554 | } |
| 2555 | |
| 2556 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2557 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2558 | |
| 2559 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2560 | struct net_device *dev, |
| 2561 | struct bss_parameters *params) |
| 2562 | { |
| 2563 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2564 | |
| 2565 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2566 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2567 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2568 | __func__,pAdapter->device_mode); |
| 2569 | |
| 2570 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2571 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2572 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2573 | { |
| 2574 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2575 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2576 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2577 | { |
| 2578 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2579 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2580 | } |
| 2581 | |
| 2582 | EXIT(); |
| 2583 | return 0; |
| 2584 | } |
| 2585 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2586 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 2587 | * to wait for contry code completion |
| 2588 | */ |
| 2589 | void* wlan_hdd_change_country_code_cb(void *pAdapter) |
| 2590 | { |
| 2591 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 2592 | complete(&call_back_pAdapter->change_country_code); |
| 2593 | return NULL; |
| 2594 | } |
| 2595 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2596 | /* |
| 2597 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2598 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2599 | */ |
| 2600 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2601 | struct net_device *ndev, |
| 2602 | enum nl80211_iftype type, |
| 2603 | u32 *flags, |
| 2604 | struct vif_params *params |
| 2605 | ) |
| 2606 | { |
| 2607 | struct wireless_dev *wdev; |
| 2608 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2609 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2610 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2611 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2612 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2613 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2614 | eMib_dot11DesiredBssType connectedBssType; |
| 2615 | VOS_STATUS status; |
| 2616 | |
| 2617 | ENTER(); |
| 2618 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2619 | status = wlan_hdd_validate_context(pHddCtx); |
| 2620 | |
| 2621 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2622 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2623 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2624 | "%s: HDD context is not valid", __func__); |
| 2625 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2626 | } |
| 2627 | |
| 2628 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2629 | __func__, pAdapter->device_mode); |
| 2630 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2631 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2632 | wdev = ndev->ieee80211_ptr; |
| 2633 | |
| 2634 | #ifdef WLAN_BTAMP_FEATURE |
| 2635 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2636 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2637 | (NL80211_IFTYPE_AP == type)|| |
| 2638 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2639 | { |
| 2640 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2641 | // stop AMP traffic |
| 2642 | status = WLANBAP_StopAmp(); |
| 2643 | if(VOS_STATUS_SUCCESS != status ) |
| 2644 | { |
| 2645 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2646 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2647 | "%s: Failed to stop AMP", __func__); |
| 2648 | return -EINVAL; |
| 2649 | } |
| 2650 | } |
| 2651 | #endif //WLAN_BTAMP_FEATURE |
| 2652 | /* Reset the current device mode bit mask*/ |
| 2653 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2654 | |
| 2655 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2656 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2657 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2658 | ) |
| 2659 | { |
| 2660 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2661 | pRoamProfile = &pWextState->roamProfile; |
| 2662 | LastBSSType = pRoamProfile->BSSType; |
| 2663 | |
| 2664 | switch (type) |
| 2665 | { |
| 2666 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2667 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2668 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2669 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2670 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2671 | #ifdef WLAN_FEATURE_11AC |
| 2672 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2673 | { |
| 2674 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2675 | } |
| 2676 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2677 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2678 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2679 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2680 | //Check for sub-string p2p to confirm its a p2p interface |
| 2681 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2682 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2683 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2684 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2685 | } |
| 2686 | else |
| 2687 | { |
| 2688 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2689 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2690 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2691 | #ifdef FEATURE_WLAN_TDLS |
| 2692 | /* The open adapter for the p2p shall skip initializations in |
| 2693 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 2694 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 2695 | * tdls_init when the change_iface sets the device mode to |
| 2696 | * WLAN_HDD_P2P_CLIENT. |
| 2697 | */ |
| 2698 | |
| 2699 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 2700 | { |
| 2701 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 2702 | { |
| 2703 | return -EINVAL; |
| 2704 | } |
| 2705 | } |
| 2706 | #endif |
| 2707 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2708 | break; |
| 2709 | case NL80211_IFTYPE_ADHOC: |
| 2710 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2711 | "%s: setting interface Type to ADHOC", __func__); |
| 2712 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2713 | pRoamProfile->phyMode = |
| 2714 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2715 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2716 | wdev->iftype = type; |
| 2717 | break; |
| 2718 | |
| 2719 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2720 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2721 | { |
| 2722 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2723 | "%s: setting interface Type to %s", __func__, |
| 2724 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2725 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2726 | //Cancel any remain on channel for GO mode |
| 2727 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2728 | { |
| 2729 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2730 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2731 | if (NL80211_IFTYPE_AP == type) |
| 2732 | { |
| 2733 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2734 | * address. This will take one HW STA and the max number of clients |
| 2735 | * that can connect to softAP will be reduced by one. so while changing |
| 2736 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2737 | * interface as it is not required in SoftAP mode. |
| 2738 | */ |
| 2739 | |
| 2740 | // Get P2P Adapter |
| 2741 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2742 | |
| 2743 | if (pP2pAdapter) |
| 2744 | { |
| 2745 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2746 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2747 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2748 | } |
| 2749 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2750 | #ifdef FEATURE_WLAN_TDLS |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2751 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2752 | /* A Mutex Lock is introduced while changing the mode to |
| 2753 | * protect the concurrent access for the Adapters by TDLS |
| 2754 | * module. |
| 2755 | */ |
| 2756 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 2757 | { |
| 2758 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2759 | "%s: unable to lock list", __func__); |
| 2760 | return -EINVAL; |
| 2761 | } |
| 2762 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2763 | //De-init the adapter. |
| 2764 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2765 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2766 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2767 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2768 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2769 | #ifdef FEATURE_WLAN_TDLS |
| 2770 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2771 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2772 | |
| 2773 | //Disable BMPS and IMPS if enabled |
| 2774 | //before starting Go |
| 2775 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2776 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2777 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2778 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2779 | { |
| 2780 | //Fail to Exit BMPS |
| 2781 | VOS_ASSERT(0); |
| 2782 | } |
| 2783 | } |
| 2784 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2785 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2786 | (pConfig->apRandomBssidEnabled)) |
| 2787 | { |
| 2788 | /* To meet Android requirements create a randomized |
| 2789 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2790 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2791 | ndev->dev_addr[0] = 0x02; |
| 2792 | ndev->dev_addr[1] = 0x1A; |
| 2793 | ndev->dev_addr[2] = 0x11; |
| 2794 | ndev->dev_addr[3] |= 0xF0; |
| 2795 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2796 | VOS_MAC_ADDR_SIZE); |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 2797 | pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n", |
| 2798 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2799 | } |
| 2800 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2801 | hdd_set_ap_ops( pAdapter->dev ); |
| 2802 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2803 | /* This is for only SAP mode where users can |
| 2804 | * control country through ini. |
| 2805 | * P2P GO follows station country code |
| 2806 | * acquired during the STA scanning. */ |
| 2807 | if((NL80211_IFTYPE_AP == type) && |
| 2808 | (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)) |
| 2809 | { |
| 2810 | int status = 0; |
| 2811 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO, |
| 2812 | "%s: setting country code from INI ", __func__); |
| 2813 | init_completion(&pAdapter->change_country_code); |
| 2814 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2815 | (void *)(tSmeChangeCountryCallback) |
| 2816 | wlan_hdd_change_country_code_cb, |
| 2817 | pConfig->apCntryCode, pAdapter, |
| 2818 | pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2819 | eSIR_FALSE, |
| 2820 | eSIR_TRUE); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2821 | if (eHAL_STATUS_SUCCESS == status) |
| 2822 | { |
| 2823 | /* Wait for completion */ |
| 2824 | status = wait_for_completion_interruptible_timeout( |
| 2825 | &pAdapter->change_country_code, |
| 2826 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2827 | if (status <= 0) |
| 2828 | { |
| 2829 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2830 | "%s: SME Timed out while setting country code ", |
| 2831 | __func__); |
| 2832 | } |
| 2833 | } |
| 2834 | else |
| 2835 | { |
| 2836 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2837 | "%s: SME Change Country code failed",__func__); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2838 | return -EINVAL; |
| 2839 | } |
| 2840 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2841 | status = hdd_init_ap_mode(pAdapter); |
| 2842 | if(status != VOS_STATUS_SUCCESS) |
| 2843 | { |
| 2844 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2845 | "%s: Error initializing the ap mode", __func__); |
| 2846 | return -EINVAL; |
| 2847 | } |
| 2848 | hdd_set_conparam(1); |
| 2849 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2850 | /*interface type changed update in wiphy structure*/ |
| 2851 | if(wdev) |
| 2852 | { |
| 2853 | wdev->iftype = type; |
| 2854 | pHddCtx->change_iface = type; |
| 2855 | } |
| 2856 | else |
| 2857 | { |
| 2858 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2859 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2860 | return -EINVAL; |
| 2861 | } |
| 2862 | goto done; |
| 2863 | } |
| 2864 | |
| 2865 | default: |
| 2866 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2867 | __func__); |
| 2868 | return -EOPNOTSUPP; |
| 2869 | } |
| 2870 | } |
| 2871 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2872 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2873 | ) |
| 2874 | { |
| 2875 | switch(type) |
| 2876 | { |
| 2877 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2878 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2879 | case NL80211_IFTYPE_ADHOC: |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2880 | #ifdef FEATURE_WLAN_TDLS |
| 2881 | |
| 2882 | /* A Mutex Lock is introduced while changing the mode to |
| 2883 | * protect the concurrent access for the Adapters by TDLS |
| 2884 | * module. |
| 2885 | */ |
| 2886 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 2887 | { |
| 2888 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2889 | "%s: unable to lock list", __func__); |
| 2890 | return -EINVAL; |
| 2891 | } |
| 2892 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2893 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2894 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2895 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2896 | //Check for sub-string p2p to confirm its a p2p interface |
| 2897 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2898 | { |
| 2899 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2900 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2901 | } |
| 2902 | else |
| 2903 | { |
| 2904 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2905 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2906 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2907 | hdd_set_conparam(0); |
| 2908 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2909 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2910 | hdd_set_station_ops( pAdapter->dev ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2911 | #ifdef FEATURE_WLAN_TDLS |
| 2912 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2913 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 2914 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2915 | if( VOS_STATUS_SUCCESS != status ) |
| 2916 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2917 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2918 | * This is the right place to enable back bmps_imps() |
| 2919 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 2920 | if (pHddCtx->hdd_wlan_suspended) |
| 2921 | { |
| 2922 | hdd_set_pwrparams(pHddCtx); |
| 2923 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2924 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2925 | goto done; |
| 2926 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2927 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2928 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2929 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2930 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2931 | goto done; |
| 2932 | default: |
| 2933 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2934 | __func__); |
| 2935 | return -EOPNOTSUPP; |
| 2936 | |
| 2937 | } |
| 2938 | |
| 2939 | } |
| 2940 | else |
| 2941 | { |
| 2942 | return -EOPNOTSUPP; |
| 2943 | } |
| 2944 | |
| 2945 | |
| 2946 | if(pRoamProfile) |
| 2947 | { |
| 2948 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2949 | { |
| 2950 | /*interface type changed update in wiphy structure*/ |
| 2951 | wdev->iftype = type; |
| 2952 | |
| 2953 | /*the BSS mode changed, We need to issue disconnect |
| 2954 | if connected or in IBSS disconnect state*/ |
| 2955 | if ( hdd_connGetConnectedBssType( |
| 2956 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2957 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2958 | { |
| 2959 | /*need to issue a disconnect to CSR.*/ |
| 2960 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2961 | if( eHAL_STATUS_SUCCESS == |
| 2962 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2963 | pAdapter->sessionId, |
| 2964 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2965 | { |
| 2966 | wait_for_completion_interruptible_timeout( |
| 2967 | &pAdapter->disconnect_comp_var, |
| 2968 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2969 | } |
| 2970 | } |
| 2971 | } |
| 2972 | } |
| 2973 | |
| 2974 | done: |
| 2975 | /*set bitmask based on updated value*/ |
| 2976 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 2977 | |
| 2978 | /* Only STA mode support TM now |
| 2979 | * all other mode, TM feature should be disabled */ |
| 2980 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 2981 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 2982 | { |
| 2983 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 2984 | } |
| 2985 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2986 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2987 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2988 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2989 | { |
| 2990 | //we are ok to do AMP |
| 2991 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2992 | } |
| 2993 | #endif //WLAN_BTAMP_FEATURE |
| 2994 | EXIT(); |
| 2995 | return 0; |
| 2996 | } |
| 2997 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2998 | #ifdef FEATURE_WLAN_TDLS |
| 2999 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 3000 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 3001 | { |
| 3002 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3003 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3004 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3005 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3006 | |
| 3007 | ENTER(); |
| 3008 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3009 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3010 | { |
| 3011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3012 | "Invalid arguments"); |
| 3013 | return -EINVAL; |
| 3014 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 3015 | |
| 3016 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 3017 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 3018 | { |
| 3019 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3020 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 3021 | MAC_ADDRESS_STR " Request declined.", |
| 3022 | __func__, MAC_ADDR_ARRAY(mac)); |
| 3023 | return -ENOTSUPP; |
| 3024 | } |
| 3025 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3026 | if (pHddCtx->isLogpInProgress) |
| 3027 | { |
| 3028 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3029 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3030 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3031 | return -EBUSY; |
| 3032 | } |
| 3033 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3034 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3035 | |
| 3036 | if ( NULL == pTdlsPeer ) { |
| 3037 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3038 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 3039 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 3040 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3041 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3042 | |
| 3043 | /* in add station, we accept existing valid staId if there is */ |
| 3044 | if ((0 == update) && |
| 3045 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 3046 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3047 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3048 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3049 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3050 | " link_status %d. staId %d. add station ignored.", |
| 3051 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 3052 | return 0; |
| 3053 | } |
| 3054 | /* in change station, we accept only when staId is valid */ |
| 3055 | if ((1 == update) && |
| 3056 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 3057 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 3058 | { |
| 3059 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3060 | "%s: " MAC_ADDRESS_STR |
| 3061 | " link status %d. staId %d. change station %s.", |
| 3062 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 3063 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 3064 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3065 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3066 | |
| 3067 | /* 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] | 3068 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3069 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3070 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3071 | "%s: " MAC_ADDRESS_STR |
| 3072 | " TDLS setup is ongoing. Request declined.", |
| 3073 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3074 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3075 | } |
| 3076 | |
| 3077 | /* first to check if we reached to maximum supported TDLS peer. |
| 3078 | TODO: for now, return -EPERM looks working fine, |
| 3079 | but need to check if any other errno fit into this category.*/ |
| 3080 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 3081 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3082 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3083 | "%s: " MAC_ADDRESS_STR |
| 3084 | " TDLS Max peer already connected. Request declined.", |
| 3085 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3086 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3087 | } |
| 3088 | else |
| 3089 | { |
| 3090 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3091 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3092 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3093 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3094 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3095 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 3096 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3097 | return -EPERM; |
| 3098 | } |
| 3099 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3100 | if (0 == update) |
| 3101 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3102 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3103 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3104 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3105 | { |
| 3106 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3107 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3108 | if(StaParams->htcap_present) |
| 3109 | { |
| 3110 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3111 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 3112 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3113 | "ht_capa->extended_capabilities: %0x", |
| 3114 | StaParams->HTCap.extendedHtCapInfo); |
| 3115 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3116 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3117 | "params->capability: %0x",StaParams->capability); |
| 3118 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 3119 | "params->ext_capab_len: %0x",StaParams->extn_capability[0]); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3120 | if(StaParams->vhtcap_present) |
| 3121 | { |
| 3122 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3123 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 3124 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 3125 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 3126 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3127 | { |
| 3128 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3129 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3130 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 3131 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3132 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 3133 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3134 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3135 | else if ((1 == update) && (NULL == StaParams)) |
| 3136 | { |
| 3137 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3138 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 3139 | return -EPERM; |
| 3140 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3141 | |
| 3142 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 3143 | |
| 3144 | if (!update) |
| 3145 | { |
| 3146 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3147 | pAdapter->sessionId, mac); |
| 3148 | } |
| 3149 | else |
| 3150 | { |
| 3151 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3152 | pAdapter->sessionId, mac, StaParams); |
| 3153 | } |
| 3154 | |
| 3155 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 3156 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 3157 | |
| 3158 | if (!status) |
| 3159 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3160 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3161 | "%s: timeout waiting for tdls add station indication", |
| 3162 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3163 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3164 | } |
| 3165 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 3166 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3167 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3168 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3169 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3170 | } |
| 3171 | |
| 3172 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3173 | |
| 3174 | error: |
| 3175 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 3176 | return -EPERM; |
| 3177 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3178 | } |
| 3179 | #endif |
| 3180 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3181 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 3182 | struct net_device *dev, |
| 3183 | u8 *mac, |
| 3184 | struct station_parameters *params) |
| 3185 | { |
| 3186 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 3187 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3188 | hdd_context_t *pHddCtx; |
| 3189 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3190 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3191 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3192 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3193 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3194 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3195 | ENTER(); |
| 3196 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3197 | if ((NULL == pAdapter)) |
| 3198 | { |
| 3199 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3200 | "invalid adapter "); |
| 3201 | return -EINVAL; |
| 3202 | } |
| 3203 | |
| 3204 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3205 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3206 | |
| 3207 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 3208 | { |
| 3209 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3210 | "invalid HDD state or HDD station context"); |
| 3211 | return -EINVAL; |
| 3212 | } |
| 3213 | |
| 3214 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3215 | { |
| 3216 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3217 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3218 | return -EAGAIN; |
| 3219 | } |
| 3220 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3221 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 3222 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3223 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 3224 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3225 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3226 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3227 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3228 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3229 | WLANTL_STA_AUTHENTICATED); |
| 3230 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3231 | if (status != VOS_STATUS_SUCCESS) |
| 3232 | { |
| 3233 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3234 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3235 | return -EINVAL; |
| 3236 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3237 | } |
| 3238 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3239 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3240 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3241 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3242 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3243 | StaParams.capability = params->capability; |
| 3244 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3245 | StaParams.max_sp = params->max_sp; |
| 3246 | |
| 3247 | if (0 != params->ext_capab_len) |
| 3248 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3249 | sizeof(StaParams.extn_capability)); |
| 3250 | |
| 3251 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3252 | { |
| 3253 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3254 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3255 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3256 | |
| 3257 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3258 | |
| 3259 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3260 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3261 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3262 | * modified to send more rates. |
| 3263 | */ |
| 3264 | |
| 3265 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3266 | */ |
| 3267 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3268 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3269 | |
| 3270 | if (0 != StaParams.supported_rates_len) { |
| 3271 | int i = 0; |
| 3272 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3273 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3274 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3275 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3276 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3277 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3278 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3279 | } |
| 3280 | |
| 3281 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3282 | { |
| 3283 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3284 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3285 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3286 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3287 | if (0 != params->ext_capab_len ) { |
| 3288 | /*Define A Macro : TODO Sunil*/ |
| 3289 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3290 | isBufSta = 1; |
| 3291 | } |
| 3292 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3293 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues, |
| 3294 | params->max_sp, isBufSta); |
| 3295 | if (VOS_STATUS_SUCCESS != status) { |
| 3296 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3297 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3298 | return -EINVAL; |
| 3299 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3300 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3301 | |
| 3302 | if (VOS_STATUS_SUCCESS != status) { |
| 3303 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3304 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3305 | return -EINVAL; |
| 3306 | } |
| 3307 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3308 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3309 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3310 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3311 | return status; |
| 3312 | } |
| 3313 | |
| 3314 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3315 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3316 | * This function is used to initialize the key information |
| 3317 | */ |
| 3318 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3319 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3320 | struct net_device *ndev, |
| 3321 | u8 key_index, bool pairwise, |
| 3322 | const u8 *mac_addr, |
| 3323 | struct key_params *params |
| 3324 | ) |
| 3325 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3326 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3327 | struct net_device *ndev, |
| 3328 | u8 key_index, const u8 *mac_addr, |
| 3329 | struct key_params *params |
| 3330 | ) |
| 3331 | #endif |
| 3332 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3333 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3334 | tCsrRoamSetKey setKey; |
| 3335 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3336 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3337 | v_U32_t roamId= 0xFF; |
| 3338 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3339 | hdd_hostapd_state_t *pHostapdState; |
| 3340 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3341 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3342 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3343 | |
| 3344 | ENTER(); |
| 3345 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3346 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3347 | status = wlan_hdd_validate_context(pHddCtx); |
| 3348 | |
| 3349 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3350 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3351 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3352 | "%s: HDD context is not valid", __func__); |
| 3353 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3354 | } |
| 3355 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3356 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3357 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3358 | |
| 3359 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3360 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3361 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3362 | key_index); |
| 3363 | |
| 3364 | return -EINVAL; |
| 3365 | } |
| 3366 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3367 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3368 | { |
| 3369 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3370 | params->key_len); |
| 3371 | |
| 3372 | return -EINVAL; |
| 3373 | } |
| 3374 | |
| 3375 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3376 | "%s: called with key index = %d & key length %d", |
| 3377 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3378 | |
| 3379 | /*extract key idx, key len and key*/ |
| 3380 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3381 | setKey.keyId = key_index; |
| 3382 | setKey.keyLength = params->key_len; |
| 3383 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3384 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3385 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3386 | { |
| 3387 | case WLAN_CIPHER_SUITE_WEP40: |
| 3388 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3389 | break; |
| 3390 | |
| 3391 | case WLAN_CIPHER_SUITE_WEP104: |
| 3392 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3393 | break; |
| 3394 | |
| 3395 | case WLAN_CIPHER_SUITE_TKIP: |
| 3396 | { |
| 3397 | u8 *pKey = &setKey.Key[0]; |
| 3398 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3399 | |
| 3400 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3401 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3402 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3403 | |
| 3404 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3405 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3406 | |--------------|----------|----------| |
| 3407 | <---16bytes---><--8bytes--><--8bytes--> |
| 3408 | |
| 3409 | */ |
| 3410 | /*Sme expects the 32 bytes key to be in the below order |
| 3411 | |
| 3412 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3413 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3414 | |--------------|----------|----------| |
| 3415 | <---16bytes---><--8bytes--><--8bytes--> |
| 3416 | */ |
| 3417 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3418 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3419 | |
| 3420 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3421 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3422 | |
| 3423 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3424 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3425 | |
| 3426 | |
| 3427 | break; |
| 3428 | } |
| 3429 | |
| 3430 | case WLAN_CIPHER_SUITE_CCMP: |
| 3431 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3432 | break; |
| 3433 | |
| 3434 | #ifdef FEATURE_WLAN_WAPI |
| 3435 | case WLAN_CIPHER_SUITE_SMS4: |
| 3436 | { |
| 3437 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3438 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3439 | params->key, params->key_len); |
| 3440 | return 0; |
| 3441 | } |
| 3442 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3443 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3444 | #ifdef FEATURE_WLAN_CCX |
| 3445 | case WLAN_CIPHER_SUITE_KRK: |
| 3446 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3447 | break; |
| 3448 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3449 | |
| 3450 | #ifdef WLAN_FEATURE_11W |
| 3451 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3452 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3453 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3454 | #endif |
| 3455 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3456 | default: |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 3457 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3458 | __func__, params->cipher); |
| 3459 | return -EOPNOTSUPP; |
| 3460 | } |
| 3461 | |
| 3462 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3463 | __func__, setKey.encType); |
| 3464 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3465 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3466 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3467 | (!pairwise) |
| 3468 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3469 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3470 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3471 | ) |
| 3472 | { |
| 3473 | /* set group key*/ |
| 3474 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3475 | "%s- %d: setting Broadcast key", |
| 3476 | __func__, __LINE__); |
| 3477 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3478 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3479 | } |
| 3480 | else |
| 3481 | { |
| 3482 | /* set pairwise key*/ |
| 3483 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3484 | "%s- %d: setting pairwise key", |
| 3485 | __func__, __LINE__); |
| 3486 | setKey.keyDirection = eSIR_TX_RX; |
| 3487 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3488 | } |
| 3489 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3490 | { |
| 3491 | setKey.keyDirection = eSIR_TX_RX; |
| 3492 | /*Set the group key*/ |
| 3493 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3494 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3495 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3496 | if ( 0 != status ) |
| 3497 | { |
| 3498 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3499 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3500 | return -EINVAL; |
| 3501 | } |
| 3502 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3503 | the PTK after peer joins the IBSS network*/ |
| 3504 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3505 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3506 | return status; |
| 3507 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3508 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3509 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3510 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3511 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3512 | if( pHostapdState->bssState == BSS_START ) |
| 3513 | { |
c_hpothu | 7c55da6 | 2014-01-23 18:34:02 +0530 | [diff] [blame] | 3514 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3515 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3516 | |
| 3517 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3518 | { |
| 3519 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3520 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3521 | __LINE__, vos_status ); |
| 3522 | |
| 3523 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3524 | |
| 3525 | return -EINVAL; |
| 3526 | } |
| 3527 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3528 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3529 | |
| 3530 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3531 | { |
| 3532 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3533 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3534 | __LINE__, status ); |
| 3535 | } |
| 3536 | } |
| 3537 | |
| 3538 | /* Saving WEP keys */ |
| 3539 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3540 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3541 | { |
| 3542 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3543 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3544 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3545 | } |
| 3546 | else |
| 3547 | { |
| 3548 | //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] | 3549 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3550 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3551 | } |
| 3552 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3553 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3554 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3555 | { |
| 3556 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3557 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3558 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3559 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3560 | if (!pairwise) |
| 3561 | #else |
| 3562 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3563 | #endif |
| 3564 | { |
| 3565 | /* set group key*/ |
| 3566 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3567 | { |
| 3568 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3569 | "%s- %d: Perform Set key Complete", |
| 3570 | __func__, __LINE__); |
| 3571 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3572 | } |
| 3573 | } |
| 3574 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3575 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3576 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3577 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3578 | |
| 3579 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3580 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3581 | params->key, params->key_len); |
| 3582 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3583 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3584 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3585 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3586 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3587 | "%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] | 3588 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3589 | setKey.peerMac[2], setKey.peerMac[3], |
| 3590 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3591 | setKey.keyDirection); |
| 3592 | |
| 3593 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3594 | |
| 3595 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3596 | { |
| 3597 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3598 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3599 | __LINE__, vos_status ); |
| 3600 | |
| 3601 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3602 | |
| 3603 | return -EINVAL; |
| 3604 | |
| 3605 | } |
| 3606 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3607 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3608 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3609 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3610 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3611 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3612 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3613 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3614 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3615 | "%s: Update PreAuth Key success", __func__); |
| 3616 | return 0; |
| 3617 | } |
| 3618 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3619 | { |
| 3620 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3621 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3622 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3623 | } |
| 3624 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3625 | |
| 3626 | /* issue set key request to SME*/ |
| 3627 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3628 | pAdapter->sessionId, &setKey, &roamId ); |
| 3629 | |
| 3630 | if ( 0 != status ) |
| 3631 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3632 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3633 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3634 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3635 | return -EINVAL; |
| 3636 | } |
| 3637 | |
| 3638 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3639 | /* in case of IBSS as there was no information available about WEP keys during |
| 3640 | * 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] | 3641 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3642 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3643 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3644 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3645 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3646 | ) |
| 3647 | && |
| 3648 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3649 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3650 | ) |
| 3651 | ) |
| 3652 | { |
| 3653 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3654 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3655 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3656 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3657 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3658 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3659 | setKey.peerMac[2], setKey.peerMac[3], |
| 3660 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3661 | setKey.keyDirection); |
| 3662 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3663 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3664 | pAdapter->sessionId, &setKey, &roamId ); |
| 3665 | |
| 3666 | if ( 0 != status ) |
| 3667 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3668 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3669 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3670 | __func__, status); |
| 3671 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3672 | return -EINVAL; |
| 3673 | } |
| 3674 | } |
| 3675 | } |
| 3676 | |
| 3677 | return 0; |
| 3678 | } |
| 3679 | |
| 3680 | /* |
| 3681 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3682 | * This function is used to get the key information |
| 3683 | */ |
| 3684 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3685 | static int wlan_hdd_cfg80211_get_key( |
| 3686 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3687 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3688 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3689 | const u8 *mac_addr, void *cookie, |
| 3690 | void (*callback)(void *cookie, struct key_params*) |
| 3691 | ) |
| 3692 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3693 | static int wlan_hdd_cfg80211_get_key( |
| 3694 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3695 | struct net_device *ndev, |
| 3696 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3697 | void (*callback)(void *cookie, struct key_params*) |
| 3698 | ) |
| 3699 | #endif |
| 3700 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3701 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3702 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3703 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3704 | struct key_params params; |
| 3705 | |
| 3706 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3707 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3708 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3709 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3711 | memset(¶ms, 0, sizeof(params)); |
| 3712 | |
| 3713 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3714 | { |
| 3715 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3716 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3717 | |
| 3718 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3719 | { |
| 3720 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3721 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3722 | break; |
| 3723 | |
| 3724 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3725 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3726 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3727 | break; |
| 3728 | |
| 3729 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3730 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3731 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3732 | break; |
| 3733 | |
| 3734 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3735 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3736 | break; |
| 3737 | |
| 3738 | case eCSR_ENCRYPT_TYPE_AES: |
| 3739 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3740 | break; |
| 3741 | |
| 3742 | default: |
| 3743 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3744 | break; |
| 3745 | } |
| 3746 | |
| 3747 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3748 | params.seq_len = 0; |
| 3749 | params.seq = NULL; |
| 3750 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3751 | callback(cookie, ¶ms); |
| 3752 | return 0; |
| 3753 | } |
| 3754 | |
| 3755 | /* |
| 3756 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3757 | * This function is used to delete the key information |
| 3758 | */ |
| 3759 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3760 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3761 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3762 | u8 key_index, |
| 3763 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3764 | const u8 *mac_addr |
| 3765 | ) |
| 3766 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3767 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3768 | struct net_device *ndev, |
| 3769 | u8 key_index, |
| 3770 | const u8 *mac_addr |
| 3771 | ) |
| 3772 | #endif |
| 3773 | { |
| 3774 | int status = 0; |
| 3775 | |
| 3776 | //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] | 3777 | //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] | 3778 | //it is observed that this is invalidating peer |
| 3779 | //key index whenever re-key is done. This is affecting data link. |
| 3780 | //It should be ok to ignore del_key. |
| 3781 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3782 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3783 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3784 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3785 | tCsrRoamSetKey setKey; |
| 3786 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3787 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3788 | ENTER(); |
| 3789 | |
| 3790 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3791 | __func__,pAdapter->device_mode); |
| 3792 | |
| 3793 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3794 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3795 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3796 | key_index); |
| 3797 | |
| 3798 | return -EINVAL; |
| 3799 | } |
| 3800 | |
| 3801 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3802 | setKey.keyId = key_index; |
| 3803 | |
| 3804 | if (mac_addr) |
| 3805 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3806 | else |
| 3807 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3808 | |
| 3809 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3810 | |
| 3811 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3812 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3813 | ) |
| 3814 | { |
| 3815 | |
| 3816 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3817 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3818 | if( pHostapdState->bssState == BSS_START) |
| 3819 | { |
| 3820 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3821 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3822 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3823 | { |
| 3824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3825 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3826 | __LINE__, status ); |
| 3827 | } |
| 3828 | } |
| 3829 | } |
| 3830 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3831 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3832 | ) |
| 3833 | { |
| 3834 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3835 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3836 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3837 | |
| 3838 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3839 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3840 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3841 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3842 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3843 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3844 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3845 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3846 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3847 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3848 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3849 | if ( 0 != status ) |
| 3850 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3851 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3852 | "%s: sme_RoamSetKey failure, returned %d", |
| 3853 | __func__, status); |
| 3854 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3855 | return -EINVAL; |
| 3856 | } |
| 3857 | } |
| 3858 | } |
| 3859 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3860 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3861 | return status; |
| 3862 | } |
| 3863 | |
| 3864 | /* |
| 3865 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3866 | * This function is used to set the default tx key index |
| 3867 | */ |
| 3868 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3869 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3870 | struct net_device *ndev, |
| 3871 | u8 key_index, |
| 3872 | bool unicast, bool multicast) |
| 3873 | #else |
| 3874 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3875 | struct net_device *ndev, |
| 3876 | u8 key_index) |
| 3877 | #endif |
| 3878 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3879 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3880 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3881 | hdd_wext_state_t *pWextState; |
| 3882 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3883 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3884 | |
| 3885 | ENTER(); |
| 3886 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3887 | if ((NULL == pAdapter)) |
| 3888 | { |
| 3889 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3890 | "invalid adapter"); |
| 3891 | return -EINVAL; |
| 3892 | } |
| 3893 | |
| 3894 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3895 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3896 | |
| 3897 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3898 | { |
| 3899 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3900 | "invalid Wext state or HDD context"); |
| 3901 | return -EINVAL; |
| 3902 | } |
| 3903 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3904 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3905 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3906 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3907 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3908 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3909 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3910 | key_index); |
| 3911 | |
| 3912 | return -EINVAL; |
| 3913 | } |
| 3914 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3915 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3916 | status = wlan_hdd_validate_context(pHddCtx); |
| 3917 | |
| 3918 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3919 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3920 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3921 | "%s: HDD context is not valid", __func__); |
| 3922 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3923 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3924 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3925 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3926 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3927 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3928 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3929 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 3930 | pHddStaCtx->conn_info.ucEncryptionType) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3931 | (eCSR_ENCRYPT_TYPE_AES != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 3932 | pHddStaCtx->conn_info.ucEncryptionType) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3933 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3934 | { |
| 3935 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3936 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3937 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3938 | tCsrRoamSetKey setKey; |
| 3939 | v_U32_t roamId= 0xFF; |
| 3940 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3941 | |
| 3942 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3943 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3944 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3945 | Keys->defaultIndex = (u8)key_index; |
| 3946 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3947 | setKey.keyId = key_index; |
| 3948 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3949 | |
| 3950 | vos_mem_copy(&setKey.Key[0], |
| 3951 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3952 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3953 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3954 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3955 | |
| 3956 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3957 | &pHddStaCtx->conn_info.bssId[0], |
| 3958 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3959 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3960 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3961 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3962 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3963 | { |
| 3964 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3965 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3966 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3967 | type(104) and switching encryption type to 40*/ |
| 3968 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3969 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3970 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3971 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3972 | } |
| 3973 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3974 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3975 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3976 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3977 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3978 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3979 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3980 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3981 | if ( 0 != status ) |
| 3982 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3983 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3984 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3985 | status); |
| 3986 | return -EINVAL; |
| 3987 | } |
| 3988 | } |
| 3989 | } |
| 3990 | |
| 3991 | /* In SoftAp mode setting key direction for default mode */ |
| 3992 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3993 | { |
| 3994 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3995 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3996 | (eCSR_ENCRYPT_TYPE_AES != |
| 3997 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3998 | ) |
| 3999 | { |
| 4000 | /* Saving key direction for default key index to TX default */ |
| 4001 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 4002 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 4003 | } |
| 4004 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4005 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4006 | return status; |
| 4007 | } |
| 4008 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4009 | /* |
| 4010 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 4011 | * This function is used to inform the BSS details to nl80211 interface. |
| 4012 | */ |
| 4013 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 4014 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 4015 | { |
| 4016 | struct net_device *dev = pAdapter->dev; |
| 4017 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 4018 | struct wiphy *wiphy = wdev->wiphy; |
| 4019 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 4020 | int chan_no; |
| 4021 | int ie_length; |
| 4022 | const char *ie; |
| 4023 | unsigned int freq; |
| 4024 | struct ieee80211_channel *chan; |
| 4025 | int rssi = 0; |
| 4026 | struct cfg80211_bss *bss = NULL; |
| 4027 | |
| 4028 | ENTER(); |
| 4029 | |
| 4030 | if( NULL == pBssDesc ) |
| 4031 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4032 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4033 | return bss; |
| 4034 | } |
| 4035 | |
| 4036 | chan_no = pBssDesc->channelId; |
| 4037 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 4038 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 4039 | |
| 4040 | if( NULL == ie ) |
| 4041 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4042 | 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] | 4043 | return bss; |
| 4044 | } |
| 4045 | |
| 4046 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 4047 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 4048 | { |
| 4049 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4050 | } |
| 4051 | else |
| 4052 | { |
| 4053 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4054 | } |
| 4055 | #else |
| 4056 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4057 | #endif |
| 4058 | |
| 4059 | chan = __ieee80211_get_channel(wiphy, freq); |
| 4060 | |
| 4061 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 4062 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 4063 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 4064 | if (bss == NULL) |
| 4065 | { |
| 4066 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 4067 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4068 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 4069 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4070 | pBssDesc->capabilityInfo, |
| 4071 | pBssDesc->beaconInterval, ie, ie_length, |
| 4072 | rssi, GFP_KERNEL )); |
| 4073 | } |
| 4074 | else |
| 4075 | { |
| 4076 | return bss; |
| 4077 | } |
| 4078 | } |
| 4079 | |
| 4080 | |
| 4081 | |
| 4082 | /* |
| 4083 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 4084 | * This function is used to inform the BSS details to nl80211 interface. |
| 4085 | */ |
| 4086 | struct cfg80211_bss* |
| 4087 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 4088 | tSirBssDescription *bss_desc |
| 4089 | ) |
| 4090 | { |
| 4091 | /* |
| 4092 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 4093 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 4094 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 4095 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 4096 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 4097 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 4098 | cfg80211_inform_bss_frame. |
| 4099 | */ |
| 4100 | struct net_device *dev = pAdapter->dev; |
| 4101 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 4102 | struct wiphy *wiphy = wdev->wiphy; |
| 4103 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4104 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4105 | qcom_ie_age *qie_age = NULL; |
| 4106 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 4107 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4108 | 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] | 4109 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4110 | const char *ie = |
| 4111 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 4112 | unsigned int freq; |
| 4113 | struct ieee80211_channel *chan; |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 4114 | struct ieee80211_mgmt *mgmt = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4115 | struct cfg80211_bss *bss_status = NULL; |
| 4116 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 4117 | int rssi = 0; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4118 | hdd_context_t *pHddCtx; |
| 4119 | int status; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4120 | #ifdef WLAN_OPEN_SOURCE |
| 4121 | struct timespec ts; |
| 4122 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4123 | |
| 4124 | ENTER(); |
| 4125 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4126 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4127 | status = wlan_hdd_validate_context(pHddCtx); |
| 4128 | |
| 4129 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
| 4130 | if (pHddCtx->isLoadUnloadInProgress) |
| 4131 | { |
| 4132 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4133 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 4134 | return NULL; |
| 4135 | } |
| 4136 | |
| 4137 | |
| 4138 | if (0 != status) |
| 4139 | { |
| 4140 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4141 | "%s: HDD context is not valid", __func__); |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4142 | return NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4143 | } |
| 4144 | |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 4145 | mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4146 | if (!mgmt) |
| 4147 | { |
| 4148 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4149 | "%s: memory allocation failed ", __func__); |
| 4150 | return NULL; |
| 4151 | } |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4152 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4153 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4154 | |
| 4155 | #ifdef WLAN_OPEN_SOURCE |
| 4156 | /* Android does not want the timestamp from the frame. |
| 4157 | Instead it wants a monotonic increasing value */ |
| 4158 | get_monotonic_boottime(&ts); |
| 4159 | mgmt->u.probe_resp.timestamp = |
| 4160 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 4161 | #else |
| 4162 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4163 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 4164 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4165 | |
| 4166 | #endif |
| 4167 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4168 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 4169 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4170 | |
| 4171 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4172 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 4173 | /* Assuming this is the last IE, copy at the end */ |
| 4174 | ie_length -=sizeof(qcom_ie_age); |
| 4175 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 4176 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 4177 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 4178 | qie_age->oui_1 = QCOM_OUI1; |
| 4179 | qie_age->oui_2 = QCOM_OUI2; |
| 4180 | qie_age->oui_3 = QCOM_OUI3; |
| 4181 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 4182 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 4183 | #endif |
| 4184 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4185 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 4186 | if (bss_desc->fProbeRsp) |
| 4187 | { |
| 4188 | mgmt->frame_control |= |
| 4189 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 4190 | } |
| 4191 | else |
| 4192 | { |
| 4193 | mgmt->frame_control |= |
| 4194 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 4195 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4196 | |
| 4197 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4198 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4199 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 4200 | { |
| 4201 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4202 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4203 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4204 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 4205 | |
| 4206 | { |
| 4207 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4208 | } |
| 4209 | else |
| 4210 | { |
| 4211 | kfree(mgmt); |
| 4212 | return NULL; |
| 4213 | } |
| 4214 | #else |
| 4215 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4216 | #endif |
| 4217 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4218 | /*when the band is changed on the fly using the GUI, three things are done |
| 4219 | * 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) |
| 4220 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 4221 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 4222 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 4223 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 4224 | * 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 |
| 4225 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 4226 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 4227 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 4228 | * So drop the bss and continue to next bss. |
| 4229 | */ |
| 4230 | if(chan == NULL) |
| 4231 | { |
| 4232 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 4233 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4234 | return NULL; |
| 4235 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4236 | /*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] | 4237 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4238 | * */ |
| 4239 | if (( eConnectionState_Associated == |
| 4240 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4241 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4242 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4243 | WNI_CFG_BSSID_LEN))) |
| 4244 | { |
| 4245 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4246 | rssi = (pAdapter->rssi * 100); |
| 4247 | } |
| 4248 | else |
| 4249 | { |
| 4250 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4251 | } |
| 4252 | |
| 4253 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4254 | frame_len, rssi, GFP_KERNEL); |
| 4255 | kfree(mgmt); |
| 4256 | return bss_status; |
| 4257 | } |
| 4258 | |
| 4259 | /* |
| 4260 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4261 | * This function is used to update the BSS data base of CFG8011 |
| 4262 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4263 | 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] | 4264 | tCsrRoamInfo *pRoamInfo |
| 4265 | ) |
| 4266 | { |
| 4267 | tCsrRoamConnectedProfile roamProfile; |
| 4268 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4269 | struct cfg80211_bss *bss = NULL; |
| 4270 | |
| 4271 | ENTER(); |
| 4272 | |
| 4273 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4274 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4275 | |
| 4276 | if (NULL != roamProfile.pBssDesc) |
| 4277 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4278 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4279 | &roamProfile); |
| 4280 | |
| 4281 | if (NULL == bss) |
| 4282 | { |
| 4283 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4284 | __func__); |
| 4285 | } |
| 4286 | |
| 4287 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4288 | } |
| 4289 | else |
| 4290 | { |
| 4291 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4292 | __func__); |
| 4293 | } |
| 4294 | return bss; |
| 4295 | } |
| 4296 | |
| 4297 | /* |
| 4298 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4299 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4300 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4301 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4302 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4303 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4304 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4305 | tCsrScanResultInfo *pScanResult; |
| 4306 | eHalStatus status = 0; |
| 4307 | tScanResultHandle pResult; |
| 4308 | struct cfg80211_bss *bss_status = NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4309 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4310 | |
| 4311 | ENTER(); |
| 4312 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4313 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4314 | |
| 4315 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4316 | { |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4318 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4319 | return -EAGAIN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4320 | } |
| 4321 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4322 | |
| 4323 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
| 4324 | if (pHddCtx->isLoadUnloadInProgress) |
| 4325 | { |
| 4326 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4327 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 4328 | return VOS_STATUS_E_PERM; |
| 4329 | } |
| 4330 | |
| 4331 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4332 | /* |
| 4333 | * start getting scan results and populate cgf80211 BSS database |
| 4334 | */ |
| 4335 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4336 | |
| 4337 | /* no scan results */ |
| 4338 | if (NULL == pResult) |
| 4339 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4340 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4341 | return status; |
| 4342 | } |
| 4343 | |
| 4344 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4345 | |
| 4346 | while (pScanResult) |
| 4347 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4348 | /* |
| 4349 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4350 | * entry already exists in bss data base of cfg80211 for that |
| 4351 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4352 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4353 | * mgmt packet as input. As of now there is no possibility to get |
| 4354 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4355 | * ieee80211_mgmt(probe response) and passing to c |
| 4356 | * fg80211_inform_bss_frame. |
| 4357 | * */ |
| 4358 | |
| 4359 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4360 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4361 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4362 | |
| 4363 | if (NULL == bss_status) |
| 4364 | { |
| 4365 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4366 | "%s: NULL returned by cfg80211_inform_bss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4367 | } |
| 4368 | else |
| 4369 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4370 | cfg80211_put_bss( |
| 4371 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 4372 | wiphy, |
| 4373 | #endif |
| 4374 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4375 | } |
| 4376 | |
| 4377 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4378 | } |
| 4379 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4380 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4381 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4382 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4383 | } |
| 4384 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4385 | void |
| 4386 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4387 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4388 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 4389 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4390 | } /****** end hddPrintMacAddr() ******/ |
| 4391 | |
| 4392 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4393 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4394 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4395 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4396 | "%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] | 4397 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4398 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4399 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4400 | } /****** end hddPrintPmkId() ******/ |
| 4401 | |
| 4402 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4403 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4404 | |
| 4405 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4406 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4407 | |
| 4408 | #define dump_bssid(bssid) \ |
| 4409 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4410 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4411 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4412 | } |
| 4413 | |
| 4414 | #define dump_pmkid(pMac, pmkid) \ |
| 4415 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4416 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4417 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4418 | } |
| 4419 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4420 | #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] | 4421 | /* |
| 4422 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4423 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4424 | */ |
| 4425 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4426 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4427 | int index, bool preauth ) |
| 4428 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4429 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4430 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4431 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4432 | |
| 4433 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4434 | 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] | 4435 | |
| 4436 | if( NULL == pRoamInfo ) |
| 4437 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4438 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4439 | return -EINVAL; |
| 4440 | } |
| 4441 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4442 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4443 | { |
| 4444 | dump_bssid(pRoamInfo->bssid); |
| 4445 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4446 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4447 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4448 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4449 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4450 | } |
| 4451 | #endif //FEATURE_WLAN_LFR |
| 4452 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 4453 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 4454 | /* |
| 4455 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth |
| 4456 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 4457 | * |
| 4458 | */ |
| 4459 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
| 4460 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
| 4461 | tCsrRoamInfo *pRoamInfo) |
| 4462 | { |
| 4463 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4464 | union iwreq_data wrqu; |
| 4465 | |
| 4466 | ENTER(); |
| 4467 | |
| 4468 | if (NULL == pAdapter) |
| 4469 | { |
| 4470 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4471 | return VOS_STATUS_E_FAILURE; |
| 4472 | } |
| 4473 | |
| 4474 | /* create the event */ |
| 4475 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4476 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4477 | |
| 4478 | wrqu.data.pointer = metrics_notification; |
| 4479 | wrqu.data.length = scnprintf(metrics_notification, |
| 4480 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT " |
| 4481 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4482 | |
| 4483 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4484 | |
| 4485 | EXIT(); |
| 4486 | |
| 4487 | return VOS_STATUS_SUCCESS; |
| 4488 | } |
| 4489 | |
| 4490 | /* |
| 4491 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status |
| 4492 | * 802.11r/LFR metrics reporting function to report preauth completion |
| 4493 | * or failure |
| 4494 | */ |
| 4495 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status( |
| 4496 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status) |
| 4497 | { |
| 4498 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4499 | union iwreq_data wrqu; |
| 4500 | |
| 4501 | ENTER(); |
| 4502 | |
| 4503 | if (NULL == pAdapter) |
| 4504 | { |
| 4505 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4506 | return VOS_STATUS_E_FAILURE; |
| 4507 | } |
| 4508 | |
| 4509 | /* create the event */ |
| 4510 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4511 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4512 | |
| 4513 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 4514 | "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR, |
| 4515 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4516 | |
| 4517 | if (1 == preauth_status) |
| 4518 | strncat(metrics_notification, " TRUE", 5); |
| 4519 | else |
| 4520 | strncat(metrics_notification, " FALSE", 6); |
| 4521 | |
| 4522 | wrqu.data.pointer = metrics_notification; |
| 4523 | wrqu.data.length = strlen(metrics_notification); |
| 4524 | |
| 4525 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4526 | |
| 4527 | EXIT(); |
| 4528 | |
| 4529 | return VOS_STATUS_SUCCESS; |
| 4530 | } |
| 4531 | |
| 4532 | /* |
| 4533 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover |
| 4534 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 4535 | * |
| 4536 | */ |
| 4537 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter, |
| 4538 | tCsrRoamInfo *pRoamInfo) |
| 4539 | { |
| 4540 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4541 | union iwreq_data wrqu; |
| 4542 | |
| 4543 | ENTER(); |
| 4544 | |
| 4545 | if (NULL == pAdapter) |
| 4546 | { |
| 4547 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4548 | return VOS_STATUS_E_FAILURE; |
| 4549 | } |
| 4550 | |
| 4551 | /* create the event */ |
| 4552 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4553 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4554 | |
| 4555 | wrqu.data.pointer = metrics_notification; |
| 4556 | wrqu.data.length = scnprintf(metrics_notification, |
| 4557 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER " |
| 4558 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4559 | |
| 4560 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4561 | |
| 4562 | EXIT(); |
| 4563 | |
| 4564 | return VOS_STATUS_SUCCESS; |
| 4565 | } |
| 4566 | #endif |
| 4567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4568 | /* |
| 4569 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4570 | * scanning callback function, called after finishing scan |
| 4571 | * |
| 4572 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4573 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4574 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4575 | { |
| 4576 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4577 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4578 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4579 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4580 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4581 | struct cfg80211_scan_request *req = NULL; |
| 4582 | int ret = 0; |
| 4583 | |
| 4584 | ENTER(); |
| 4585 | |
| 4586 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4587 | "%s called with halHandle = %p, pContext = %p," |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4588 | "scanID = %d, returned status = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4589 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4590 | |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4591 | pScanInfo->mScanPendingCounter = 0; |
| 4592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4593 | //Block on scan req completion variable. Can't wait forever though. |
| 4594 | ret = wait_for_completion_interruptible_timeout( |
| 4595 | &pScanInfo->scan_req_completion_event, |
| 4596 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4597 | if (!ret) |
| 4598 | { |
| 4599 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4600 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4601 | } |
| 4602 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 4603 | if (pScanInfo->mScanPending != VOS_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4604 | { |
| 4605 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4606 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4610 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4611 | { |
| 4612 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4613 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4614 | "scanId = %d", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4615 | (int) scanId); |
| 4616 | } |
| 4617 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4618 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4619 | pAdapter); |
| 4620 | |
| 4621 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4622 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4623 | |
| 4624 | |
| 4625 | /* If any client wait scan result through WEXT |
| 4626 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4627 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4628 | { |
| 4629 | /* The other scan request waiting for current scan finish |
| 4630 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4631 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4632 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4633 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4634 | } |
| 4635 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4636 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4637 | { |
| 4638 | struct net_device *dev = pAdapter->dev; |
| 4639 | union iwreq_data wrqu; |
| 4640 | int we_event; |
| 4641 | char *msg; |
| 4642 | |
| 4643 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4644 | we_event = SIOCGIWSCAN; |
| 4645 | msg = NULL; |
| 4646 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4647 | } |
| 4648 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4649 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4650 | |
| 4651 | /* Get the Scan Req */ |
| 4652 | req = pAdapter->request; |
| 4653 | |
| 4654 | if (!req) |
| 4655 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4656 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4657 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4658 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | /* |
| 4662 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4663 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4664 | req->n_ssids = 0; |
| 4665 | req->n_channels = 0; |
| 4666 | req->ie = 0; |
| 4667 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4668 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4669 | /* Scan is no longer pending */ |
| 4670 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4671 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4672 | /* |
| 4673 | * cfg80211_scan_done informing NL80211 about completion |
| 4674 | * of scanning |
| 4675 | */ |
| 4676 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4677 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4678 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4679 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4680 | /* release the wake lock at the end of the scan*/ |
| 4681 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4682 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4683 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4684 | * immediatly after the driver gets connect request(i.e after scan) |
| 4685 | * from supplicant, this result in app's is suspending and not able |
| 4686 | * to process the connect request to AP */ |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 4687 | hdd_prevent_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4688 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4689 | #ifdef FEATURE_WLAN_TDLS |
| 4690 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4691 | #endif |
| 4692 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4693 | EXIT(); |
| 4694 | return 0; |
| 4695 | } |
| 4696 | |
| 4697 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4698 | * FUNCTION: hdd_isScanAllowed |
| 4699 | * Go through each adapter and check if scan allowed |
| 4700 | * |
| 4701 | */ |
| 4702 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4703 | { |
| 4704 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4705 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4706 | hdd_adapter_t *pAdapter = NULL; |
| 4707 | VOS_STATUS status = 0; |
| 4708 | v_U8_t staId = 0; |
| 4709 | v_U8_t *staMac = NULL; |
| 4710 | |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 4711 | if (TRUE == pHddCtx->btCoexModeSet) |
| 4712 | { |
| 4713 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4714 | FL("BTCoex Mode operation in progress, Do not allow scan")); |
| 4715 | return VOS_FALSE; |
| 4716 | } |
| 4717 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4718 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4719 | |
| 4720 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4721 | { |
| 4722 | pAdapter = pAdapterNode->pAdapter; |
| 4723 | |
| 4724 | if( pAdapter ) |
| 4725 | { |
| 4726 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4727 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4728 | __func__, pAdapter->device_mode); |
| 4729 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4730 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4731 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4732 | { |
| 4733 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4734 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4735 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4736 | { |
| 4737 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4738 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4739 | "%s: client " MAC_ADDRESS_STR |
| 4740 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 4741 | MAC_ADDR_ARRAY(staMac)); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4742 | return VOS_FALSE; |
| 4743 | } |
| 4744 | } |
| 4745 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4746 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4747 | { |
| 4748 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4749 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4750 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4751 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4752 | { |
| 4753 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4754 | |
| 4755 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4756 | "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the " |
| 4757 | "middle of WPS/EAPOL exchange.", __func__, |
| 4758 | MAC_ADDR_ARRAY(staMac)); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4759 | return VOS_FALSE; |
| 4760 | } |
| 4761 | } |
| 4762 | } |
| 4763 | } |
| 4764 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4765 | pAdapterNode = pNext; |
| 4766 | } |
| 4767 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4768 | "%s: Scan allowed", __func__); |
| 4769 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4770 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4771 | |
| 4772 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4773 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4774 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4775 | * later, scan dump command can be used to recieve scan results |
| 4776 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4777 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4778 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4779 | struct net_device *dev, |
| 4780 | #endif |
| 4781 | struct cfg80211_scan_request *request) |
| 4782 | { |
| 4783 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4784 | struct net_device *dev = request->wdev->netdev; |
| 4785 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4786 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4787 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4788 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4789 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4790 | tCsrScanRequest scanRequest; |
| 4791 | tANI_U8 *channelList = NULL, i; |
| 4792 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4793 | int status; |
| 4794 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4795 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4796 | |
| 4797 | ENTER(); |
| 4798 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4799 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4800 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4801 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4802 | status = wlan_hdd_validate_context(pHddCtx); |
| 4803 | |
| 4804 | if (0 != status) |
| 4805 | { |
| 4806 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4807 | "%s: HDD context is not valid", __func__); |
| 4808 | return status; |
| 4809 | } |
| 4810 | |
| 4811 | cfg_param = pHddCtx->cfg_ini; |
| 4812 | pScanInfo = &pHddCtx->scan_info; |
| 4813 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4814 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4815 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4816 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4817 | { |
| 4818 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4819 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4820 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4821 | return -EBUSY; |
| 4822 | } |
| 4823 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4824 | #ifdef WLAN_BTAMP_FEATURE |
| 4825 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4826 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4827 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4828 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4829 | "%s: No scanning when AMP is on", __func__); |
| 4830 | return -EOPNOTSUPP; |
| 4831 | } |
| 4832 | #endif |
| 4833 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4834 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4835 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4836 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4837 | "%s: Not scanning on device_mode = %d", |
| 4838 | __func__, pAdapter->device_mode); |
| 4839 | return -EOPNOTSUPP; |
| 4840 | } |
| 4841 | |
| 4842 | if (TRUE == pScanInfo->mScanPending) |
| 4843 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4844 | if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ ) |
| 4845 | { |
| 4846 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__); |
| 4847 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4848 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4849 | } |
| 4850 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4851 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4852 | //Channel and action frame is pending |
| 4853 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4854 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4855 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4856 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4857 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4858 | return -EBUSY; |
| 4859 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4860 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4861 | /* if tdls disagree scan right now, return immediately. |
| 4862 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4863 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4864 | */ |
| 4865 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4866 | wiphy, |
| 4867 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4868 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4869 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4870 | request); |
| 4871 | if(status <= 0) |
| 4872 | { |
| 4873 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4874 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4875 | } |
| 4876 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4877 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4878 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4879 | { |
| 4880 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4881 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4882 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4883 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4884 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4885 | { |
| 4886 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4887 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4888 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4889 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4890 | } |
| 4891 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4892 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4893 | /* Check if scan is allowed at this point of time. |
| 4894 | */ |
| 4895 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4896 | { |
| 4897 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4898 | return -EBUSY; |
| 4899 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4900 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4901 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4902 | |
| 4903 | if (NULL != request) |
| 4904 | { |
| 4905 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4906 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4907 | |
| 4908 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4909 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4910 | * is not aging out the scan results. |
| 4911 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4912 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4913 | { |
| 4914 | request->n_ssids = 0; |
| 4915 | } |
| 4916 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4917 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4918 | { |
| 4919 | tCsrSSIDInfo *SsidInfo; |
| 4920 | int j; |
| 4921 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4922 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4923 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4924 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4925 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4926 | |
| 4927 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4928 | { |
| 4929 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4930 | "memory alloc failed SSIDInfo buffer"); |
| 4931 | return -ENOMEM; |
| 4932 | } |
| 4933 | |
| 4934 | /* copy all the ssid's and their length */ |
| 4935 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4936 | { |
| 4937 | /* get the ssid length */ |
| 4938 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4939 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4940 | SsidInfo->SSID.length); |
| 4941 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4942 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4943 | j, SsidInfo->SSID.ssId); |
| 4944 | } |
| 4945 | /* set the scan type to active */ |
| 4946 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4947 | } |
| 4948 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4949 | { |
| 4950 | /* set the scan type to active */ |
| 4951 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4952 | } |
| 4953 | else |
| 4954 | { |
| 4955 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4956 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4957 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4958 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4959 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4960 | } |
| 4961 | else |
| 4962 | { |
| 4963 | /* set the scan type to active */ |
| 4964 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4965 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4966 | |
| 4967 | /* set min and max channel time to zero */ |
| 4968 | scanRequest.minChnTime = 0; |
| 4969 | scanRequest.maxChnTime = 0; |
| 4970 | } |
| 4971 | |
| 4972 | /* set BSSType to default type */ |
| 4973 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4974 | |
| 4975 | /*TODO: scan the requested channels only*/ |
| 4976 | |
| 4977 | /*Right now scanning all the channels */ |
| 4978 | if( request ) |
| 4979 | { |
| 4980 | if( request->n_channels ) |
| 4981 | { |
| 4982 | channelList = vos_mem_malloc( request->n_channels ); |
| 4983 | if( NULL == channelList ) |
| 4984 | { |
| 4985 | status = -ENOMEM; |
| 4986 | goto free_mem; |
| 4987 | } |
| 4988 | |
| 4989 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4990 | channelList[i] = request->channels[i]->hw_value; |
| 4991 | } |
| 4992 | |
| 4993 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4994 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4995 | |
| 4996 | /* set requestType to full scan */ |
| 4997 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4998 | |
| 4999 | /* 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] | 5000 | * 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] | 5001 | * 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] | 5002 | */ |
| 5003 | |
| 5004 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5005 | * and in that case driver shoudnt flush scan results. If |
| 5006 | * driver flushes the scan results here and unfortunately if |
| 5007 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 5008 | * fails which is not desired |
| 5009 | */ |
| 5010 | |
| 5011 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 5012 | { |
| 5013 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5014 | pAdapter->sessionId ); |
| 5015 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5016 | |
| 5017 | if( request->ie_len ) |
| 5018 | { |
| 5019 | /* save this for future association (join requires this) */ |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5020 | /*TODO: Array needs to be converted to dynamic allocation, |
| 5021 | * as multiple ie.s can be sent in cfg80211_scan_request structure |
| 5022 | * CR 597966 |
| 5023 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5024 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 5025 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 5026 | pScanInfo->scanAddIE.length = request->ie_len; |
| 5027 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5028 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5029 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5030 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5031 | { |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5032 | if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH) |
| 5033 | { |
| 5034 | pwextBuf->roamProfile.nAddIEScanLength = request->ie_len; |
| 5035 | memcpy( pwextBuf->roamProfile.addIEScan, |
| 5036 | request->ie, request->ie_len); |
| 5037 | } |
| 5038 | else |
| 5039 | { |
| 5040 | hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:" |
| 5041 | "%d", request->ie_len); |
| 5042 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5043 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5044 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5045 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 5046 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 5047 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5048 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 5049 | request->ie_len); |
| 5050 | if (pP2pIe != NULL) |
| 5051 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 5052 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 5053 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 5054 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 5055 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5056 | { |
| 5057 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 5058 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 5059 | "Go nego completed to Connection is started"); |
| 5060 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 5061 | "for 8way Handshake"); |
| 5062 | } |
| 5063 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 5064 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5065 | { |
| 5066 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 5067 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 5068 | "Disconnected state to Connection is started"); |
| 5069 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 5070 | "for 4way Handshake"); |
| 5071 | } |
| 5072 | #endif |
| 5073 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5074 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 5075 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5076 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5077 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5078 | "%s: This is a P2P Search", __func__); |
| 5079 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5080 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5081 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 5082 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 5083 | /* set requestType to P2P Discovery */ |
| 5084 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5085 | } |
| 5086 | |
| 5087 | /* |
| 5088 | Skip Dfs Channel in case of P2P Search |
| 5089 | if it is set in ini file |
| 5090 | */ |
| 5091 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 5092 | { |
| 5093 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 5094 | } |
| 5095 | else |
| 5096 | { |
| 5097 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 5098 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5099 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5100 | } |
| 5101 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5102 | } |
| 5103 | } |
| 5104 | |
| 5105 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 5106 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 5107 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 5108 | * address the following issues. |
| 5109 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 5110 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 5111 | * for long time, this result in apps running at full power for long time. |
| 5112 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 5113 | * be stuck in full power because of resume BMPS |
| 5114 | */ |
| 5115 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5116 | |
| 5117 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5118 | pAdapter->sessionId, &scanRequest, &scanId, |
| 5119 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5121 | if (eHAL_STATUS_SUCCESS != status) |
| 5122 | { |
| 5123 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5124 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 5125 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 5126 | if(eHAL_STATUS_RESOURCES == status) |
| 5127 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 5128 | 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] | 5129 | status = -EBUSY; |
| 5130 | } else { |
| 5131 | status = -EIO; |
| 5132 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 5133 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5134 | goto free_mem; |
| 5135 | } |
| 5136 | |
| 5137 | pScanInfo->mScanPending = TRUE; |
| 5138 | pAdapter->request = request; |
| 5139 | pScanInfo->scanId = scanId; |
| 5140 | |
| 5141 | complete(&pScanInfo->scan_req_completion_event); |
| 5142 | |
| 5143 | free_mem: |
| 5144 | if( scanRequest.SSIDs.SSIDList ) |
| 5145 | { |
| 5146 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 5147 | } |
| 5148 | |
| 5149 | if( channelList ) |
| 5150 | vos_mem_free( channelList ); |
| 5151 | |
| 5152 | EXIT(); |
| 5153 | |
| 5154 | return status; |
| 5155 | } |
| 5156 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5157 | |
| 5158 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 5159 | { |
| 5160 | v_U8_t iniDot11Mode = |
| 5161 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 5162 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 5163 | |
| 5164 | switch ( iniDot11Mode ) |
| 5165 | { |
| 5166 | case eHDD_DOT11_MODE_AUTO: |
| 5167 | case eHDD_DOT11_MODE_11ac: |
| 5168 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 5169 | #ifdef WLAN_FEATURE_11AC |
| 5170 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 5171 | #else |
| 5172 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 5173 | #endif |
| 5174 | break; |
| 5175 | case eHDD_DOT11_MODE_11n: |
| 5176 | case eHDD_DOT11_MODE_11n_ONLY: |
| 5177 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 5178 | break; |
| 5179 | default: |
| 5180 | hddDot11Mode = iniDot11Mode; |
| 5181 | break; |
| 5182 | } |
| 5183 | /* This call decides required channel bonding mode */ |
| 5184 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 5185 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 5186 | operationChannel); |
| 5187 | } |
| 5188 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5189 | /* |
| 5190 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5191 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5192 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5193 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5194 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5195 | { |
| 5196 | int status = 0; |
| 5197 | hdd_wext_state_t *pWextState; |
| 5198 | v_U32_t roamId; |
| 5199 | tCsrRoamProfile *pRoamProfile; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5200 | eCsrAuthType RSNAuthType; |
| 5201 | |
| 5202 | ENTER(); |
| 5203 | |
| 5204 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5205 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5206 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 5207 | { |
| 5208 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 5209 | return -EINVAL; |
| 5210 | } |
| 5211 | |
| 5212 | pRoamProfile = &pWextState->roamProfile; |
| 5213 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5214 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5215 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5216 | hdd_station_ctx_t *pHddStaCtx; |
| 5217 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5218 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5219 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5220 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 5221 | { |
| 5222 | /*QoS not enabled in cfg file*/ |
| 5223 | pRoamProfile->uapsd_mask = 0; |
| 5224 | } |
| 5225 | else |
| 5226 | { |
| 5227 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5228 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5229 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 5230 | } |
| 5231 | |
| 5232 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 5233 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 5234 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5235 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5236 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 5237 | ssid, ssid_len); |
| 5238 | |
| 5239 | if (bssid) |
| 5240 | { |
| 5241 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 5242 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 5243 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5244 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 5245 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5246 | case of join failure we should send valid BSSID to supplicant |
| 5247 | */ |
| 5248 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 5249 | WNI_CFG_BSSID_LEN); |
| 5250 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 5251 | else |
| 5252 | { |
| 5253 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 5254 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5255 | |
| 5256 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 5257 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5258 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5259 | /*set gen ie*/ |
| 5260 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 5261 | /*set auth*/ |
| 5262 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 5263 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5264 | #ifdef FEATURE_WLAN_WAPI |
| 5265 | if (pAdapter->wapi_info.nWapiMode) |
| 5266 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5267 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5268 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 5269 | { |
| 5270 | case WAPI_AUTH_MODE_PSK: |
| 5271 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5272 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5273 | pAdapter->wapi_info.wapiAuthMode); |
| 5274 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5275 | break; |
| 5276 | } |
| 5277 | case WAPI_AUTH_MODE_CERT: |
| 5278 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5279 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5280 | pAdapter->wapi_info.wapiAuthMode); |
| 5281 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5282 | break; |
| 5283 | } |
| 5284 | } // End of switch |
| 5285 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 5286 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 5287 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5288 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5289 | pRoamProfile->AuthType.numEntries = 1; |
| 5290 | pRoamProfile->EncryptionType.numEntries = 1; |
| 5291 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5292 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 5293 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5294 | } |
| 5295 | } |
| 5296 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5297 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5298 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5299 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5300 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5301 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5302 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 5303 | sizeof (tSirGtkOffloadParams)); |
| 5304 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5305 | } |
| 5306 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5307 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 5308 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5309 | if( operatingChannel ) |
| 5310 | { |
| 5311 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 5312 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5313 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5314 | else |
| 5315 | { |
| 5316 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5317 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5318 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5319 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 5320 | { |
| 5321 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 5322 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5323 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 5324 | * 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] | 5325 | * 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] | 5326 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5327 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 5328 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5329 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5330 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5331 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 5332 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5333 | |
| 5334 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5335 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 5336 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5337 | if ((eHAL_STATUS_SUCCESS != status) && |
| 5338 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5339 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5340 | |
| 5341 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5342 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 5343 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 5344 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5345 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5346 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5347 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5348 | |
| 5349 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5350 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5351 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5352 | } |
| 5353 | else |
| 5354 | { |
| 5355 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 5356 | return -EINVAL; |
| 5357 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5358 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5359 | return status; |
| 5360 | } |
| 5361 | |
| 5362 | /* |
| 5363 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 5364 | * This function is used to set the authentication type (OPEN/SHARED). |
| 5365 | * |
| 5366 | */ |
| 5367 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 5368 | enum nl80211_auth_type auth_type) |
| 5369 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5370 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5371 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5372 | |
| 5373 | ENTER(); |
| 5374 | |
| 5375 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5376 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5377 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5378 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5379 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5380 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 5381 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5382 | break; |
| 5383 | |
| 5384 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5385 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5386 | case NL80211_AUTHTYPE_FT: |
| 5387 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5388 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | "%s: set authentication type to OPEN", __func__); |
| 5390 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5391 | break; |
| 5392 | |
| 5393 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5394 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5395 | "%s: set authentication type to SHARED", __func__); |
| 5396 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5397 | break; |
| 5398 | #ifdef FEATURE_WLAN_CCX |
| 5399 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5400 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5401 | "%s: set authentication type to CCKM WPA", __func__); |
| 5402 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5403 | break; |
| 5404 | #endif |
| 5405 | |
| 5406 | |
| 5407 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5408 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5409 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5410 | auth_type); |
| 5411 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5412 | return -EINVAL; |
| 5413 | } |
| 5414 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5415 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5416 | pHddStaCtx->conn_info.authType; |
| 5417 | return 0; |
| 5418 | } |
| 5419 | |
| 5420 | /* |
| 5421 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5422 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5423 | * |
| 5424 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5425 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5426 | u32 key_mgmt |
| 5427 | ) |
| 5428 | { |
| 5429 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5430 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5431 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5432 | /*set key mgmt type*/ |
| 5433 | switch(key_mgmt) |
| 5434 | { |
| 5435 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5436 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5437 | case WLAN_AKM_SUITE_FT_PSK: |
| 5438 | #endif |
| 5439 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5440 | __func__); |
| 5441 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5442 | break; |
| 5443 | |
| 5444 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5445 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5446 | case WLAN_AKM_SUITE_FT_8021X: |
| 5447 | #endif |
| 5448 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5449 | __func__); |
| 5450 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5451 | break; |
| 5452 | #ifdef FEATURE_WLAN_CCX |
| 5453 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5454 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5455 | case WLAN_AKM_SUITE_CCKM: |
| 5456 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5457 | __func__); |
| 5458 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5459 | break; |
| 5460 | #endif |
| 5461 | |
| 5462 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5463 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5464 | __func__, key_mgmt); |
| 5465 | return -EINVAL; |
| 5466 | |
| 5467 | } |
| 5468 | return 0; |
| 5469 | } |
| 5470 | |
| 5471 | /* |
| 5472 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5473 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5474 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5475 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5476 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5477 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5478 | bool ucast |
| 5479 | ) |
| 5480 | { |
| 5481 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5482 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5483 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5484 | |
| 5485 | ENTER(); |
| 5486 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5487 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5488 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5489 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5490 | __func__, cipher); |
| 5491 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5492 | } |
| 5493 | else |
| 5494 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5495 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5496 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5497 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5498 | { |
| 5499 | case IW_AUTH_CIPHER_NONE: |
| 5500 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5501 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5502 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5503 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5504 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5505 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5506 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5507 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5508 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5509 | break; |
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 | case WLAN_CIPHER_SUITE_TKIP: |
| 5512 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5513 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5514 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5515 | case WLAN_CIPHER_SUITE_CCMP: |
| 5516 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5517 | break; |
| 5518 | #ifdef FEATURE_WLAN_WAPI |
| 5519 | case WLAN_CIPHER_SUITE_SMS4: |
| 5520 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5521 | break; |
| 5522 | #endif |
| 5523 | |
| 5524 | #ifdef FEATURE_WLAN_CCX |
| 5525 | case WLAN_CIPHER_SUITE_KRK: |
| 5526 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5527 | break; |
| 5528 | #endif |
| 5529 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5530 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5531 | __func__, cipher); |
| 5532 | return -EOPNOTSUPP; |
| 5533 | } |
| 5534 | } |
| 5535 | |
| 5536 | if (ucast) |
| 5537 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5538 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5539 | __func__, encryptionType); |
| 5540 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5541 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5542 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5543 | encryptionType; |
| 5544 | } |
| 5545 | else |
| 5546 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5547 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5548 | __func__, encryptionType); |
| 5549 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5550 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5551 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5552 | } |
| 5553 | |
| 5554 | return 0; |
| 5555 | } |
| 5556 | |
| 5557 | |
| 5558 | /* |
| 5559 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5560 | * This function is used to parse WPA/RSN IE's. |
| 5561 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5562 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5563 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5564 | size_t ie_len |
| 5565 | ) |
| 5566 | { |
| 5567 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5568 | u8 *genie = ie; |
| 5569 | v_U16_t remLen = ie_len; |
| 5570 | #ifdef FEATURE_WLAN_WAPI |
| 5571 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5572 | u16 *tmp; |
| 5573 | v_U16_t akmsuiteCount; |
| 5574 | int *akmlist; |
| 5575 | #endif |
| 5576 | ENTER(); |
| 5577 | |
| 5578 | /* clear previous assocAddIE */ |
| 5579 | pWextState->assocAddIE.length = 0; |
| 5580 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5581 | |
| 5582 | while (remLen >= 2) |
| 5583 | { |
| 5584 | v_U16_t eLen = 0; |
| 5585 | v_U8_t elementId; |
| 5586 | elementId = *genie++; |
| 5587 | eLen = *genie++; |
| 5588 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5589 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5590 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5591 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5592 | |
| 5593 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5594 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5595 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5596 | 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] | 5597 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5598 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5599 | "%s: Invalid WPA IE", __func__); |
| 5600 | return -EINVAL; |
| 5601 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5602 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5603 | { |
| 5604 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5605 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5606 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5607 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5608 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5609 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5610 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5611 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5612 | VOS_ASSERT(0); |
| 5613 | return -ENOMEM; |
| 5614 | } |
| 5615 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5616 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5617 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5618 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5619 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5620 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5621 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5622 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5623 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5624 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5625 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5626 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5627 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5628 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5629 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5630 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5631 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
Kiet Lam | 8da9899 | 2013-11-21 15:59:07 +0530 | [diff] [blame] | 5632 | P2P_OUI_TYPE_SIZE))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5633 | { |
| 5634 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5635 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5636 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5637 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5638 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5639 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5640 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5641 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5642 | VOS_ASSERT(0); |
| 5643 | return -ENOMEM; |
| 5644 | } |
| 5645 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5646 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5647 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5648 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5649 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5650 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5651 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5652 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5653 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5654 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5655 | /*Consider WFD IE, only for P2P Client */ |
| 5656 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5657 | { |
| 5658 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5659 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5660 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5661 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5662 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5663 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5664 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5665 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5666 | VOS_ASSERT(0); |
| 5667 | return -ENOMEM; |
| 5668 | } |
| 5669 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5670 | // WPS IE + P2P IE + WFD IE |
| 5671 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5672 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5673 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5674 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5675 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5676 | } |
| 5677 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5678 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5679 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5680 | HS20_OUI_TYPE_SIZE)) ) |
| 5681 | { |
| 5682 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5683 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5684 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5685 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5686 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5687 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5688 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5689 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5690 | VOS_ASSERT(0); |
| 5691 | return -ENOMEM; |
| 5692 | } |
| 5693 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5694 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5695 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5696 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5697 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5698 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5699 | |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 5700 | if (WLAN_HDD_IBSS == pAdapter->device_mode) { |
| 5701 | |
| 5702 | /* populating as ADDIE in beacon frames */ |
| 5703 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5704 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2, |
| 5705 | NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS) |
| 5706 | { |
| 5707 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5708 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 5709 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5710 | { |
| 5711 | hddLog(LOGE, |
| 5712 | "Coldn't pass " |
| 5713 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
| 5714 | } |
| 5715 | }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/ |
| 5716 | else |
| 5717 | hddLog(LOGE, |
| 5718 | "Could not pass on " |
| 5719 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
| 5720 | |
| 5721 | /* IBSS mode doesn't contain params->proberesp_ies still |
| 5722 | beaconIE's need to be populated in probe response frames */ |
| 5723 | if ( (NULL != (genie - 2)) && (0 != eLen + 2) ) |
| 5724 | { |
| 5725 | u16 rem_probe_resp_ie_len = eLen + 2; |
| 5726 | u8 probe_rsp_ie_len[3] = {0}; |
| 5727 | u8 counter = 0; |
| 5728 | |
| 5729 | /* Check Probe Resp Length if it is greater then 255 then |
| 5730 | Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 |
| 5731 | & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are |
| 5732 | not able Store More then 255 bytes into One Variable */ |
| 5733 | |
| 5734 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 5735 | { |
| 5736 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 5737 | { |
| 5738 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 5739 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 5740 | } |
| 5741 | else |
| 5742 | { |
| 5743 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 5744 | rem_probe_resp_ie_len = 0; |
| 5745 | } |
| 5746 | } |
| 5747 | |
| 5748 | rem_probe_resp_ie_len = 0; |
| 5749 | |
| 5750 | if (probe_rsp_ie_len[0] > 0) |
| 5751 | { |
| 5752 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5753 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 5754 | (tANI_U8*)(genie - 2), |
| 5755 | probe_rsp_ie_len[0], NULL, |
| 5756 | eANI_BOOLEAN_FALSE) |
| 5757 | == eHAL_STATUS_FAILURE) |
| 5758 | { |
| 5759 | hddLog(LOGE, |
| 5760 | "Could not pass" |
| 5761 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
| 5762 | } |
| 5763 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 5764 | } |
| 5765 | |
| 5766 | if (probe_rsp_ie_len[1] > 0) |
| 5767 | { |
| 5768 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5769 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 5770 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 5771 | probe_rsp_ie_len[1], NULL, |
| 5772 | eANI_BOOLEAN_FALSE) |
| 5773 | == eHAL_STATUS_FAILURE) |
| 5774 | { |
| 5775 | hddLog(LOGE, |
| 5776 | "Could not pass" |
| 5777 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
| 5778 | } |
| 5779 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 5780 | } |
| 5781 | |
| 5782 | if (probe_rsp_ie_len[2] > 0) |
| 5783 | { |
| 5784 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5785 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 5786 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 5787 | probe_rsp_ie_len[2], NULL, |
| 5788 | eANI_BOOLEAN_FALSE) |
| 5789 | == eHAL_STATUS_FAILURE) |
| 5790 | { |
| 5791 | hddLog(LOGE, |
| 5792 | "Could not pass" |
| 5793 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
| 5794 | } |
| 5795 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 5796 | } |
| 5797 | |
| 5798 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5799 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 5800 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5801 | { |
| 5802 | hddLog(LOGE, |
| 5803 | "Could not pass" |
| 5804 | "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
| 5805 | } |
| 5806 | } |
| 5807 | else |
| 5808 | { |
| 5809 | // Reset WNI_CFG_PROBE_RSP Flags |
| 5810 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 5811 | |
| 5812 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5813 | "%s: No Probe Response IE received in set beacon", |
| 5814 | __func__); |
| 5815 | } |
| 5816 | } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5817 | break; |
| 5818 | case DOT11F_EID_RSN: |
| 5819 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5820 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5821 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5822 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5823 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5824 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5825 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5826 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5827 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5828 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5829 | 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] | 5830 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5831 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5832 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5833 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5834 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5835 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5836 | VOS_ASSERT(0); |
| 5837 | return -ENOMEM; |
| 5838 | } |
| 5839 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5840 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5841 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5842 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5843 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5844 | break; |
| 5845 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5846 | #ifdef FEATURE_WLAN_WAPI |
| 5847 | case WLAN_EID_WAPI: |
| 5848 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5849 | hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5850 | pAdapter->wapi_info.nWapiMode); |
| 5851 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5852 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5853 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5854 | tmp = tmp + 1; |
| 5855 | akmlist = (int *)(tmp); |
| 5856 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5857 | { |
| 5858 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5859 | } |
| 5860 | else |
| 5861 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5862 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5863 | VOS_ASSERT(0); |
| 5864 | return -EINVAL; |
| 5865 | } |
| 5866 | |
| 5867 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5868 | { |
| 5869 | 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] | 5870 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5871 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5872 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5873 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5874 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5875 | 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] | 5876 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5877 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5878 | } |
| 5879 | break; |
| 5880 | #endif |
| 5881 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5882 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5883 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5884 | /* when Unknown IE is received we should break and continue |
| 5885 | * to the next IE in the buffer instead we were returning |
| 5886 | * so changing this to break */ |
| 5887 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5888 | } |
| 5889 | genie += eLen; |
| 5890 | remLen -= eLen; |
| 5891 | } |
| 5892 | EXIT(); |
| 5893 | return 0; |
| 5894 | } |
| 5895 | |
| 5896 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5897 | * FUNCTION: hdd_isWPAIEPresent |
| 5898 | * Parse the received IE to find the WPA IE |
| 5899 | * |
| 5900 | */ |
| 5901 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5902 | { |
| 5903 | v_U8_t eLen = 0; |
| 5904 | v_U16_t remLen = ie_len; |
| 5905 | v_U8_t elementId = 0; |
| 5906 | |
| 5907 | while (remLen >= 2) |
| 5908 | { |
| 5909 | elementId = *ie++; |
| 5910 | eLen = *ie++; |
| 5911 | remLen -= 2; |
| 5912 | if (eLen > remLen) |
| 5913 | { |
| 5914 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5915 | "%s: IE length is wrong %d", __func__, eLen); |
| 5916 | return FALSE; |
| 5917 | } |
| 5918 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5919 | { |
| 5920 | /* OUI - 0x00 0X50 0XF2 |
| 5921 | WPA Information Element - 0x01 |
| 5922 | WPA version - 0x01*/ |
| 5923 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5924 | return TRUE; |
| 5925 | } |
| 5926 | ie += eLen; |
| 5927 | remLen -= eLen; |
| 5928 | } |
| 5929 | return FALSE; |
| 5930 | } |
| 5931 | |
| 5932 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5933 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5934 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5935 | * parameters during connect operation. |
| 5936 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5937 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5938 | struct cfg80211_connect_params *req |
| 5939 | ) |
| 5940 | { |
| 5941 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5942 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5943 | ENTER(); |
| 5944 | |
| 5945 | /*set wpa version*/ |
| 5946 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5947 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5948 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5949 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 5950 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5951 | { |
| 5952 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5953 | } |
| 5954 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5955 | { |
| 5956 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5957 | } |
| 5958 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5959 | |
| 5960 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5961 | pWextState->wpaVersion); |
| 5962 | |
| 5963 | /*set authentication type*/ |
| 5964 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5965 | |
| 5966 | if (0 > status) |
| 5967 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5968 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5969 | "%s: failed to set authentication type ", __func__); |
| 5970 | return status; |
| 5971 | } |
| 5972 | |
| 5973 | /*set key mgmt type*/ |
| 5974 | if (req->crypto.n_akm_suites) |
| 5975 | { |
| 5976 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5977 | if (0 > status) |
| 5978 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5979 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5980 | __func__); |
| 5981 | return status; |
| 5982 | } |
| 5983 | } |
| 5984 | |
| 5985 | /*set pairwise cipher type*/ |
| 5986 | if (req->crypto.n_ciphers_pairwise) |
| 5987 | { |
| 5988 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5989 | req->crypto.ciphers_pairwise[0], true); |
| 5990 | if (0 > status) |
| 5991 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5992 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5993 | "%s: failed to set unicast cipher type", __func__); |
| 5994 | return status; |
| 5995 | } |
| 5996 | } |
| 5997 | else |
| 5998 | { |
| 5999 | /*Reset previous cipher suite to none*/ |
| 6000 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 6001 | if (0 > status) |
| 6002 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6003 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6004 | "%s: failed to set unicast cipher type", __func__); |
| 6005 | return status; |
| 6006 | } |
| 6007 | } |
| 6008 | |
| 6009 | /*set group cipher type*/ |
| 6010 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 6011 | false); |
| 6012 | |
| 6013 | if (0 > status) |
| 6014 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6015 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6016 | __func__); |
| 6017 | return status; |
| 6018 | } |
| 6019 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 6020 | #ifdef WLAN_FEATURE_11W |
| 6021 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 6022 | #endif |
| 6023 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6024 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 6025 | if (req->ie_len) |
| 6026 | { |
| 6027 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 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 parse the WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6031 | __func__); |
| 6032 | return status; |
| 6033 | } |
| 6034 | } |
| 6035 | |
| 6036 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6037 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6038 | { |
| 6039 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 6040 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 6041 | ) |
| 6042 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6043 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6044 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 6045 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6046 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6047 | __func__); |
| 6048 | return -EOPNOTSUPP; |
| 6049 | } |
| 6050 | else |
| 6051 | { |
| 6052 | u8 key_len = req->key_len; |
| 6053 | u8 key_idx = req->key_idx; |
| 6054 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6055 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6056 | && (CSR_MAX_NUM_KEY > key_idx) |
| 6057 | ) |
| 6058 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6059 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6060 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6061 | __func__, key_idx, key_len); |
| 6062 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6063 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6064 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6065 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6066 | (u8)key_len; |
| 6067 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 6068 | } |
| 6069 | } |
| 6070 | } |
| 6071 | } |
| 6072 | |
| 6073 | return status; |
| 6074 | } |
| 6075 | |
| 6076 | /* |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6077 | * FUNCTION: wlan_hdd_try_disconnect |
| 6078 | * This function is used to disconnect from previous |
| 6079 | * connection |
| 6080 | */ |
| 6081 | static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter ) |
| 6082 | { |
| 6083 | long ret = 0; |
| 6084 | hdd_station_ctx_t *pHddStaCtx; |
| 6085 | eMib_dot11DesiredBssType connectedBssType; |
| 6086 | |
| 6087 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6088 | |
| 6089 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 6090 | |
| 6091 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 6092 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 6093 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
| 6094 | { |
| 6095 | /* Issue disconnect to CSR */ |
| 6096 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6097 | if( eHAL_STATUS_SUCCESS == |
| 6098 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6099 | pAdapter->sessionId, |
| 6100 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 6101 | { |
| 6102 | ret = wait_for_completion_interruptible_timeout( |
| 6103 | &pAdapter->disconnect_comp_var, |
| 6104 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6105 | if (0 >= ret) |
| 6106 | { |
| 6107 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 6108 | return -EALREADY; |
| 6109 | } |
| 6110 | } |
| 6111 | } |
| 6112 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 6113 | { |
| 6114 | ret = wait_for_completion_interruptible_timeout( |
| 6115 | &pAdapter->disconnect_comp_var, |
| 6116 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6117 | if (0 >= ret) |
| 6118 | { |
| 6119 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 6120 | return -EALREADY; |
| 6121 | } |
| 6122 | } |
| 6123 | |
| 6124 | return 0; |
| 6125 | } |
| 6126 | |
| 6127 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6128 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6129 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6130 | * parameters during connect operation. |
| 6131 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6132 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6133 | struct net_device *ndev, |
| 6134 | struct cfg80211_connect_params *req |
| 6135 | ) |
| 6136 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6137 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6138 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6139 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 6140 | hdd_context_t *pHddCtx = NULL; |
| 6141 | |
| 6142 | ENTER(); |
| 6143 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6144 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6145 | "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6146 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6147 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6148 | status = wlan_hdd_validate_context(pHddCtx); |
| 6149 | |
| 6150 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6151 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6152 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6153 | "%s: HDD context is not valid", __func__); |
| 6154 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6155 | } |
| 6156 | |
| 6157 | #ifdef WLAN_BTAMP_FEATURE |
| 6158 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6159 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6160 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6161 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6162 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 6163 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6164 | } |
| 6165 | #endif |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6166 | |
| 6167 | //If Device Mode is Station Concurrent Sessions Exit BMps |
| 6168 | //P2P Mode will be taken care in Open/close adapter |
| 6169 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 6170 | (vos_concurrent_sessions_running())) |
| 6171 | { |
| 6172 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6173 | } |
| 6174 | |
| 6175 | /*Try disconnecting if already in connected state*/ |
| 6176 | status = wlan_hdd_try_disconnect(pAdapter); |
| 6177 | if ( 0 > status) |
| 6178 | { |
| 6179 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 6180 | " connection")); |
| 6181 | return -EALREADY; |
| 6182 | } |
| 6183 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6184 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6185 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6186 | |
| 6187 | if ( 0 > status) |
| 6188 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6189 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6190 | __func__); |
| 6191 | return status; |
| 6192 | } |
| 6193 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 6194 | if ( req->channel ) |
| 6195 | { |
| 6196 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 6197 | req->ssid_len, req->bssid, |
| 6198 | req->channel->hw_value); |
| 6199 | } |
| 6200 | else |
| 6201 | { |
| 6202 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6203 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 6204 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6205 | |
| 6206 | if (0 > status) |
| 6207 | { |
| 6208 | //ReEnable BMPS if disabled |
| 6209 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 6210 | (NULL != pHddCtx)) |
| 6211 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6212 | if (pHddCtx->hdd_wlan_suspended) |
| 6213 | { |
| 6214 | hdd_set_pwrparams(pHddCtx); |
| 6215 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6216 | //ReEnable Bmps and Imps back |
| 6217 | hdd_enable_bmps_imps(pHddCtx); |
| 6218 | } |
| 6219 | |
| 6220 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6221 | return status; |
| 6222 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6223 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6224 | EXIT(); |
| 6225 | return status; |
| 6226 | } |
| 6227 | |
| 6228 | |
| 6229 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6230 | * FUNCTION: wlan_hdd_disconnect |
| 6231 | * This function is used to issue a disconnect request to SME |
| 6232 | */ |
| 6233 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 6234 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6235 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6236 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6237 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6238 | |
| 6239 | status = wlan_hdd_validate_context(pHddCtx); |
| 6240 | |
| 6241 | if (0 != status) |
| 6242 | { |
| 6243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6244 | "%s: HDD context is not valid", __func__); |
| 6245 | return status; |
| 6246 | } |
| 6247 | |
| 6248 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6249 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6250 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6251 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6252 | /*issue disconnect*/ |
| 6253 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6254 | pAdapter->sessionId, reason); |
| 6255 | |
| 6256 | if ( 0 != status ) |
| 6257 | { |
| 6258 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6259 | "%s csrRoamDisconnect failure, returned %d", |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6260 | __func__, (int)status ); |
| 6261 | return -EINVAL; |
| 6262 | } |
| 6263 | wait_for_completion_interruptible_timeout( |
| 6264 | &pAdapter->disconnect_comp_var, |
| 6265 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6266 | /*stop tx queues*/ |
| 6267 | netif_tx_disable(pAdapter->dev); |
| 6268 | netif_carrier_off(pAdapter->dev); |
| 6269 | return status; |
| 6270 | } |
| 6271 | |
| 6272 | |
| 6273 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6274 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 6275 | * This function is used to issue a disconnect request to SME |
| 6276 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6277 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6278 | struct net_device *dev, |
| 6279 | u16 reason |
| 6280 | ) |
| 6281 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6282 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6283 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6284 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6285 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6286 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6287 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6288 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6289 | tANI_U8 staIdx; |
| 6290 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6291 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6292 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6293 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6294 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6295 | __func__,pAdapter->device_mode); |
| 6296 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6297 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 6298 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6299 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6300 | status = wlan_hdd_validate_context(pHddCtx); |
| 6301 | |
| 6302 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6303 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6304 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6305 | "%s: HDD context is not valid", __func__); |
| 6306 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6307 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6308 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6309 | if (NULL != pRoamProfile) |
| 6310 | { |
| 6311 | /*issue disconnect request to SME, if station is in connected state*/ |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 6312 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 6313 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6314 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6315 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6316 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6317 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6318 | switch(reason) |
| 6319 | { |
| 6320 | case WLAN_REASON_MIC_FAILURE: |
| 6321 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 6322 | break; |
| 6323 | |
| 6324 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 6325 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 6326 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 6327 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 6328 | break; |
| 6329 | |
| 6330 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 6331 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 6332 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 6333 | break; |
| 6334 | |
| 6335 | case WLAN_REASON_DEAUTH_LEAVING: |
| 6336 | default: |
| 6337 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 6338 | break; |
| 6339 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6340 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6341 | pScanInfo = &pHddCtx->scan_info; |
| 6342 | if (pScanInfo->mScanPending) |
| 6343 | { |
| 6344 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 6345 | "Aborting Scan"); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 6346 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6347 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6348 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6349 | #ifdef FEATURE_WLAN_TDLS |
| 6350 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6351 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6352 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6353 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 6354 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6355 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6356 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6357 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6358 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6359 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6360 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6361 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6362 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6363 | pAdapter->sessionId, |
| 6364 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6365 | } |
| 6366 | } |
| 6367 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6368 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 6369 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6370 | { |
| 6371 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6372 | "%s wlan_hdd_disconnect failure, returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6373 | __func__, (int)status ); |
| 6374 | return -EINVAL; |
| 6375 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6376 | } |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 6377 | else |
| 6378 | { |
| 6379 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API" |
| 6380 | "called while in %d state", __func__, |
| 6381 | pHddStaCtx->conn_info.connState); |
| 6382 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6383 | } |
| 6384 | else |
| 6385 | { |
| 6386 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 6387 | } |
| 6388 | |
| 6389 | return status; |
| 6390 | } |
| 6391 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6392 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6393 | /* |
| 6394 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6395 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6396 | * settings in IBSS mode. |
| 6397 | */ |
| 6398 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6399 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6400 | struct cfg80211_ibss_params *params |
| 6401 | ) |
| 6402 | { |
| 6403 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6404 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6405 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 6406 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6407 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6408 | ENTER(); |
| 6409 | |
| 6410 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Ravi Joshi | b58ca0d | 2013-10-29 09:50:23 -0700 | [diff] [blame] | 6411 | vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6412 | |
| 6413 | if (params->ie_len && ( NULL != params->ie) ) |
| 6414 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6415 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 6416 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6417 | { |
| 6418 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 6419 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 6420 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6421 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6422 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6423 | tDot11fIEWPA dot11WPAIE; |
| 6424 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6425 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6426 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 6427 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6428 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 6429 | params->ie_len, DOT11F_EID_WPA); |
| 6430 | if ( NULL != ie ) |
| 6431 | { |
| 6432 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 6433 | // Unpack the WPA IE |
| 6434 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 6435 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 6436 | &ie[2+4], |
| 6437 | ie[1] - 4, |
| 6438 | &dot11WPAIE); |
| 6439 | /*Extract the multicast cipher, the encType for unicast |
| 6440 | cipher for wpa-none is none*/ |
| 6441 | encryptionType = |
| 6442 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 6443 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6444 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6445 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6446 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 6447 | |
| 6448 | if (0 > status) |
| 6449 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6450 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6451 | __func__); |
| 6452 | return status; |
| 6453 | } |
| 6454 | } |
| 6455 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6456 | pWextState->roamProfile.AuthType.authType[0] = |
| 6457 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6458 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6459 | |
| 6460 | if (params->privacy) |
| 6461 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6462 | /* Security enabled IBSS, At this time there is no information available |
| 6463 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6464 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6465 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6466 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6467 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6468 | *enable privacy bit in beacons */ |
| 6469 | |
| 6470 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 6471 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6472 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6473 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6474 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 6475 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 6476 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6477 | return status; |
| 6478 | } |
| 6479 | |
| 6480 | /* |
| 6481 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6482 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6483 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6484 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6485 | struct net_device *dev, |
| 6486 | struct cfg80211_ibss_params *params |
| 6487 | ) |
| 6488 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6489 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6490 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6491 | tCsrRoamProfile *pRoamProfile; |
| 6492 | int status; |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6493 | bool alloc_bssid = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6494 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6495 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6496 | |
| 6497 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6498 | |
| 6499 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6500 | "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6501 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6502 | status = wlan_hdd_validate_context(pHddCtx); |
| 6503 | |
| 6504 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6505 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6506 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6507 | "%s: HDD context is not valid", __func__); |
| 6508 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6509 | } |
| 6510 | |
| 6511 | if (NULL == pWextState) |
| 6512 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6513 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6514 | __func__); |
| 6515 | return -EIO; |
| 6516 | } |
| 6517 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6518 | /*Try disconnecting if already in connected state*/ |
| 6519 | status = wlan_hdd_try_disconnect(pAdapter); |
| 6520 | if ( 0 > status) |
| 6521 | { |
| 6522 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 6523 | " IBSS connection")); |
| 6524 | return -EALREADY; |
| 6525 | } |
| 6526 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6527 | pRoamProfile = &pWextState->roamProfile; |
| 6528 | |
| 6529 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 6530 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6531 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6532 | "%s Interface type is not set to IBSS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6533 | return -EINVAL; |
| 6534 | } |
| 6535 | |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 6536 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 6537 | if (NULL != params->bssid) { |
| 6538 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 6539 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) { |
| 6540 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6541 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 6542 | return -EIO; |
| 6543 | } |
| 6544 | } |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6545 | else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0) |
| 6546 | { |
| 6547 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 6548 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 6549 | { |
| 6550 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6551 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 6552 | return -EIO; |
| 6553 | } |
| 6554 | params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE)); |
| 6555 | if (!params->bssid) |
| 6556 | { |
| 6557 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6558 | "%s:Failed memory allocation", __func__); |
| 6559 | return -EIO; |
| 6560 | } |
| 6561 | vos_mem_copy((v_U8_t *)params->bssid, |
| 6562 | (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0], |
| 6563 | VOS_MAC_ADDR_SIZE); |
| 6564 | alloc_bssid = VOS_TRUE; |
| 6565 | } |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 6566 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6567 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6568 | if (NULL != |
| 6569 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6570 | params->chandef.chan) |
| 6571 | #else |
| 6572 | params->channel) |
| 6573 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6574 | { |
| 6575 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6576 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6577 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6578 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6579 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6580 | |
| 6581 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6582 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6583 | ieee80211_frequency_to_channel( |
| 6584 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6585 | params->chandef.chan->center_freq); |
| 6586 | #else |
| 6587 | params->channel->center_freq); |
| 6588 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6589 | |
| 6590 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 6591 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6592 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6593 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 6594 | __func__); |
| 6595 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6596 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6597 | |
| 6598 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6599 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6600 | if (channelNum == validChan[indx]) |
| 6601 | { |
| 6602 | break; |
| 6603 | } |
| 6604 | } |
| 6605 | if (indx >= numChans) |
| 6606 | { |
| 6607 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6608 | __func__, channelNum); |
| 6609 | return -EINVAL; |
| 6610 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6611 | /* Set the Operational Channel */ |
| 6612 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 6613 | channelNum); |
| 6614 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 6615 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6616 | pRoamProfile->ChannelInfo.ChannelList = |
| 6617 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6618 | } |
| 6619 | |
| 6620 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6621 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6622 | if (status < 0) |
| 6623 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6624 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6625 | __func__); |
| 6626 | return status; |
| 6627 | } |
| 6628 | |
| 6629 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6630 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6631 | params->ssid_len, params->bssid, |
| 6632 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6633 | |
| 6634 | if (0 > status) |
| 6635 | { |
| 6636 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6637 | return status; |
| 6638 | } |
| 6639 | |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6640 | if (NULL != params->bssid && |
| 6641 | pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 && |
| 6642 | alloc_bssid == VOS_TRUE) |
| 6643 | { |
| 6644 | vos_mem_free(params->bssid); |
| 6645 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6646 | return 0; |
| 6647 | } |
| 6648 | |
| 6649 | /* |
| 6650 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6651 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6652 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6653 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6654 | struct net_device *dev |
| 6655 | ) |
| 6656 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6657 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6658 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6659 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6660 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6661 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6662 | |
| 6663 | ENTER(); |
| 6664 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6665 | status = wlan_hdd_validate_context(pHddCtx); |
| 6666 | |
| 6667 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6668 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6669 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6670 | "%s: HDD context is not valid", __func__); |
| 6671 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6672 | } |
| 6673 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6674 | 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] | 6675 | if (NULL == pWextState) |
| 6676 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6677 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6678 | __func__); |
| 6679 | return -EIO; |
| 6680 | } |
| 6681 | |
| 6682 | pRoamProfile = &pWextState->roamProfile; |
| 6683 | |
| 6684 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6685 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6686 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6687 | 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] | 6688 | __func__); |
| 6689 | return -EINVAL; |
| 6690 | } |
| 6691 | |
| 6692 | /* Issue Disconnect request */ |
| 6693 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6694 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6695 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6696 | |
| 6697 | return 0; |
| 6698 | } |
| 6699 | |
| 6700 | /* |
| 6701 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6702 | * This function is used to set the phy parameters |
| 6703 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6704 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6705 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6706 | u32 changed) |
| 6707 | { |
| 6708 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6709 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6710 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6711 | |
| 6712 | ENTER(); |
| 6713 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6714 | status = wlan_hdd_validate_context(pHddCtx); |
| 6715 | |
| 6716 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6717 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6718 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6719 | "%s: HDD context is not valid", __func__); |
| 6720 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6721 | } |
| 6722 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6723 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6724 | { |
| 6725 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6726 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6727 | wiphy->rts_threshold; |
| 6728 | |
| 6729 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6730 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6731 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6732 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6733 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6734 | __func__, rts_threshold); |
| 6735 | return -EINVAL; |
| 6736 | } |
| 6737 | |
| 6738 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6739 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6740 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6741 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6742 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6743 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6744 | __func__, rts_threshold); |
| 6745 | return -EIO; |
| 6746 | } |
| 6747 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6748 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6749 | rts_threshold); |
| 6750 | } |
| 6751 | |
| 6752 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6753 | { |
| 6754 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6755 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6756 | wiphy->frag_threshold; |
| 6757 | |
| 6758 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6759 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6760 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6761 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6762 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6763 | frag_threshold); |
| 6764 | return -EINVAL; |
| 6765 | } |
| 6766 | |
| 6767 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6768 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6769 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6770 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6771 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6772 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6773 | __func__, frag_threshold); |
| 6774 | return -EIO; |
| 6775 | } |
| 6776 | |
| 6777 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6778 | frag_threshold); |
| 6779 | } |
| 6780 | |
| 6781 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6782 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6783 | { |
| 6784 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6785 | wiphy->retry_short : |
| 6786 | wiphy->retry_long; |
| 6787 | |
| 6788 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6789 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6790 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6791 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6792 | __func__, retry_value); |
| 6793 | return -EINVAL; |
| 6794 | } |
| 6795 | |
| 6796 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6797 | { |
| 6798 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6799 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6800 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6801 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6802 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6803 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6804 | __func__, retry_value); |
| 6805 | return -EIO; |
| 6806 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6807 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6808 | __func__, retry_value); |
| 6809 | } |
| 6810 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6811 | { |
| 6812 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6813 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6814 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6815 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6816 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6817 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6818 | __func__, retry_value); |
| 6819 | return -EIO; |
| 6820 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6821 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6822 | __func__, retry_value); |
| 6823 | } |
| 6824 | } |
| 6825 | |
| 6826 | return 0; |
| 6827 | } |
| 6828 | |
| 6829 | /* |
| 6830 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6831 | * This function is used to set the txpower |
| 6832 | */ |
| 6833 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6834 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6835 | struct wireless_dev *wdev, |
| 6836 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6837 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6838 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6839 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6840 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6841 | #endif |
| 6842 | int dbm) |
| 6843 | { |
| 6844 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6845 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6846 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6847 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6848 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6849 | |
| 6850 | ENTER(); |
| 6851 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6852 | status = wlan_hdd_validate_context(pHddCtx); |
| 6853 | |
| 6854 | if (0 != status) |
| 6855 | { |
| 6856 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6857 | "%s: HDD context is not valid", __func__); |
| 6858 | return status; |
| 6859 | } |
| 6860 | |
| 6861 | hHal = pHddCtx->hHal; |
| 6862 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6863 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6864 | dbm, ccmCfgSetCallback, |
| 6865 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6866 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6867 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6868 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6869 | return -EIO; |
| 6870 | } |
| 6871 | |
| 6872 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6873 | dbm); |
| 6874 | |
| 6875 | switch(type) |
| 6876 | { |
| 6877 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6878 | /* Fall through */ |
| 6879 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6880 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6881 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6882 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6883 | __func__); |
| 6884 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6885 | } |
| 6886 | break; |
| 6887 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6888 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6889 | __func__); |
| 6890 | return -EOPNOTSUPP; |
| 6891 | break; |
| 6892 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6893 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6894 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6895 | return -EIO; |
| 6896 | } |
| 6897 | |
| 6898 | return 0; |
| 6899 | } |
| 6900 | |
| 6901 | /* |
| 6902 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6903 | * This function is used to read the txpower |
| 6904 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6905 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 6906 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6907 | struct wireless_dev *wdev, |
| 6908 | #endif |
| 6909 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6910 | { |
| 6911 | |
| 6912 | hdd_adapter_t *pAdapter; |
| 6913 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6914 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6915 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6916 | ENTER(); |
| 6917 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6918 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6919 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6920 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6921 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6922 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6923 | "%s: HDD context is not valid", __func__); |
| 6924 | *dbm = 0; |
| 6925 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6926 | } |
| 6927 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6928 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6929 | if (NULL == pAdapter) |
| 6930 | { |
| 6931 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6932 | return -ENOENT; |
| 6933 | } |
| 6934 | |
| 6935 | wlan_hdd_get_classAstats(pAdapter); |
| 6936 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6937 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6938 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6939 | return 0; |
| 6940 | } |
| 6941 | |
| 6942 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6943 | u8* mac, struct station_info *sinfo) |
| 6944 | { |
| 6945 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6946 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6947 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6948 | tANI_U8 rate_flags; |
| 6949 | |
| 6950 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6951 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6952 | |
| 6953 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6954 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6955 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6956 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6957 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6958 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6959 | tANI_U16 maxRate = 0; |
| 6960 | tANI_U16 myRate; |
| 6961 | tANI_U16 currentRate = 0; |
| 6962 | tANI_U8 maxSpeedMCS = 0; |
| 6963 | tANI_U8 maxMCSIdx = 0; |
| 6964 | tANI_U8 rateFlag = 1; |
| 6965 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6966 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6967 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6968 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6969 | #ifdef WLAN_FEATURE_11AC |
| 6970 | tANI_U32 vht_mcs_map; |
| 6971 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6972 | #endif /* WLAN_FEATURE_11AC */ |
| 6973 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6974 | ENTER(); |
| 6975 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6976 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6977 | (0 == ssidlen)) |
| 6978 | { |
| 6979 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6980 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6981 | /*To keep GUI happy*/ |
| 6982 | return 0; |
| 6983 | } |
| 6984 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6985 | status = wlan_hdd_validate_context(pHddCtx); |
| 6986 | |
| 6987 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6988 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6989 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6990 | "%s: HDD context is not valid", __func__); |
| 6991 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6992 | } |
| 6993 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6994 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6995 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6996 | |
Kiet Lam | 3b17fc8 | 2013-09-27 05:24:08 +0530 | [diff] [blame] | 6997 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6998 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6999 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7000 | //convert to the UI units of 100kbps |
| 7001 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 7002 | |
| 7003 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7004 | 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] | 7005 | sinfo->signal, |
| 7006 | pCfg->reportMaxLinkSpeed, |
| 7007 | myRate, |
| 7008 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7009 | (int) pCfg->linkSpeedRssiMid, |
| 7010 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7011 | (int) rate_flags, |
| 7012 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7013 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7014 | |
| 7015 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 7016 | { |
| 7017 | // we do not want to necessarily report the current speed |
| 7018 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 7019 | { |
| 7020 | // report the max possible speed |
| 7021 | rssidx = 0; |
| 7022 | } |
| 7023 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 7024 | { |
| 7025 | // report the max possible speed with RSSI scaling |
| 7026 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 7027 | { |
| 7028 | // report the max possible speed |
| 7029 | rssidx = 0; |
| 7030 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7031 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7032 | { |
| 7033 | // report middle speed |
| 7034 | rssidx = 1; |
| 7035 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7036 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 7037 | { |
| 7038 | // report middle speed |
| 7039 | rssidx = 2; |
| 7040 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7041 | else |
| 7042 | { |
| 7043 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7044 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7045 | } |
| 7046 | } |
| 7047 | else |
| 7048 | { |
| 7049 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 7050 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7051 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 7052 | __func__, pCfg->reportMaxLinkSpeed); |
| 7053 | rssidx = 0; |
| 7054 | } |
| 7055 | |
| 7056 | maxRate = 0; |
| 7057 | |
| 7058 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7059 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 7060 | OperationalRates, &ORLeng)) |
| 7061 | { |
| 7062 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7063 | /*To keep GUI happy*/ |
| 7064 | return 0; |
| 7065 | } |
| 7066 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7067 | for (i = 0; i < ORLeng; i++) |
| 7068 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7069 | 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] | 7070 | { |
| 7071 | /* Validate Rate Set */ |
| 7072 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 7073 | { |
| 7074 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 7075 | break; |
| 7076 | } |
| 7077 | } |
| 7078 | /* Update MAX rate */ |
| 7079 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 7080 | } |
| 7081 | |
| 7082 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7083 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 7084 | ExtendedRates, &ERLeng)) |
| 7085 | { |
| 7086 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7087 | /*To keep GUI happy*/ |
| 7088 | return 0; |
| 7089 | } |
| 7090 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7091 | for (i = 0; i < ERLeng; i++) |
| 7092 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7093 | 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] | 7094 | { |
| 7095 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 7096 | { |
| 7097 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 7098 | break; |
| 7099 | } |
| 7100 | } |
| 7101 | /* Update MAX rate */ |
| 7102 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 7103 | } |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7104 | /* Get MCS Rate Set -- |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 7105 | Only if we are always reporting max speed (or) |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7106 | if we have good rssi */ |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 7107 | if ((0 == rssidx) || |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7108 | (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7109 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7110 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 7111 | MCSRates, &MCSLeng)) |
| 7112 | { |
| 7113 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7114 | /*To keep GUI happy*/ |
| 7115 | return 0; |
| 7116 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7117 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7118 | #ifdef WLAN_FEATURE_11AC |
| 7119 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7120 | 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] | 7121 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7122 | 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] | 7123 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7124 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7125 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7126 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7127 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7128 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7129 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7130 | maxMCSIdx = 7; |
| 7131 | } |
| 7132 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 7133 | { |
| 7134 | maxMCSIdx = 8; |
| 7135 | } |
| 7136 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 7137 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7138 | //VHT20 is supporting 0~8 |
| 7139 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7140 | maxMCSIdx = 8; |
| 7141 | else |
| 7142 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7143 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7144 | |
| 7145 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7146 | { |
| 7147 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 7148 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 7149 | } |
| 7150 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 7151 | { |
| 7152 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 7153 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 7154 | } |
| 7155 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7156 | { |
| 7157 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 7158 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 7159 | } |
| 7160 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7161 | maxSpeedMCS = 1; |
| 7162 | if (currentRate > maxRate) |
| 7163 | { |
| 7164 | maxRate = currentRate; |
| 7165 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7166 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7167 | } |
| 7168 | else |
| 7169 | #endif /* WLAN_FEATURE_11AC */ |
| 7170 | { |
| 7171 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7172 | { |
| 7173 | rateFlag |= 1; |
| 7174 | } |
| 7175 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7176 | { |
| 7177 | rateFlag |= 2; |
| 7178 | } |
| 7179 | |
| 7180 | for (i = 0; i < MCSLeng; i++) |
| 7181 | { |
| 7182 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 7183 | for (j = 0; j < temp; j++) |
| 7184 | { |
| 7185 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 7186 | { |
| 7187 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 7188 | break; |
| 7189 | } |
| 7190 | } |
| 7191 | if ((j < temp) && (currentRate > maxRate)) |
| 7192 | { |
| 7193 | maxRate = currentRate; |
| 7194 | maxSpeedMCS = 1; |
| 7195 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 7196 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7197 | } |
| 7198 | } |
| 7199 | } |
| 7200 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7201 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 7202 | { |
| 7203 | maxRate = myRate; |
| 7204 | maxSpeedMCS = 1; |
| 7205 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 7206 | } |
| 7207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7208 | // 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] | 7209 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 7210 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7211 | { |
| 7212 | maxRate = myRate; |
| 7213 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 7214 | { |
| 7215 | maxSpeedMCS = 0; |
| 7216 | } |
| 7217 | else |
| 7218 | { |
| 7219 | maxSpeedMCS = 1; |
| 7220 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 7221 | } |
| 7222 | } |
| 7223 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7224 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7225 | { |
| 7226 | sinfo->txrate.legacy = maxRate; |
| 7227 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7228 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 7229 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7230 | } |
| 7231 | else |
| 7232 | { |
| 7233 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7234 | #ifdef WLAN_FEATURE_11AC |
| 7235 | sinfo->txrate.nss = 1; |
| 7236 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7237 | { |
| 7238 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7239 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7240 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7241 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7242 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7243 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7244 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7245 | } |
| 7246 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7247 | { |
| 7248 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7249 | } |
| 7250 | #endif /* WLAN_FEATURE_11AC */ |
| 7251 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 7252 | { |
| 7253 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 7254 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7255 | { |
| 7256 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7257 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7258 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7259 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7260 | { |
| 7261 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 7262 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7263 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7264 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7265 | pr_info("Reporting MCS rate %d flags %x\n", |
| 7266 | sinfo->txrate.mcs, |
| 7267 | sinfo->txrate.flags ); |
| 7268 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7269 | } |
| 7270 | } |
| 7271 | else |
| 7272 | { |
| 7273 | // report current rate instead of max rate |
| 7274 | |
| 7275 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 7276 | { |
| 7277 | //provide to the UI in units of 100kbps |
| 7278 | sinfo->txrate.legacy = myRate; |
| 7279 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7280 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 7281 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7282 | } |
| 7283 | else |
| 7284 | { |
| 7285 | //must be MCS |
| 7286 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7287 | #ifdef WLAN_FEATURE_11AC |
| 7288 | sinfo->txrate.nss = 1; |
| 7289 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7290 | { |
| 7291 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7292 | } |
| 7293 | else |
| 7294 | #endif /* WLAN_FEATURE_11AC */ |
| 7295 | { |
| 7296 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 7297 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7298 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7299 | { |
| 7300 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 7301 | } |
| 7302 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7303 | { |
| 7304 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7305 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7306 | #ifdef WLAN_FEATURE_11AC |
| 7307 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7308 | { |
| 7309 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 7310 | } |
| 7311 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7312 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7313 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 7314 | sinfo->txrate.mcs, |
| 7315 | sinfo->txrate.flags ); |
| 7316 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7317 | } |
| 7318 | } |
| 7319 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 7320 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 7321 | sinfo->tx_packets = |
| 7322 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 7323 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 7324 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 7325 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 7326 | |
| 7327 | sinfo->tx_retries = |
| 7328 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 7329 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 7330 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 7331 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 7332 | |
| 7333 | sinfo->tx_failed = |
| 7334 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 7335 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 7336 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 7337 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 7338 | |
| 7339 | sinfo->filled |= |
| 7340 | STATION_INFO_TX_PACKETS | |
| 7341 | STATION_INFO_TX_RETRIES | |
| 7342 | STATION_INFO_TX_FAILED; |
| 7343 | |
| 7344 | EXIT(); |
| 7345 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7346 | } |
| 7347 | |
| 7348 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 7349 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7350 | { |
| 7351 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7352 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7353 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7354 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7355 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7356 | ENTER(); |
| 7357 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7358 | if (NULL == pAdapter) |
| 7359 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7360 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7361 | return -ENODEV; |
| 7362 | } |
| 7363 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7364 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7365 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7366 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7367 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7368 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7369 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7370 | "%s: HDD context is not valid", __func__); |
| 7371 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7372 | } |
| 7373 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7374 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 7375 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 7376 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 7377 | (eConnectionState_Associated == |
| 7378 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 7379 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 7380 | |
| 7381 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7382 | "offload: in cfg80211_set_power_mgmt, calling arp offload"); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 7383 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7384 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7385 | { |
| 7386 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7387 | "%s:Failed to enable ARPOFFLOAD Feature %d", |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7388 | __func__, vos_status); |
| 7389 | } |
| 7390 | } |
| 7391 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7392 | /**The get power cmd from the supplicant gets updated by the nl only |
| 7393 | *on successful execution of the function call |
| 7394 | *we are oppositely mapped w.r.t mode in the driver |
| 7395 | **/ |
| 7396 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 7397 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7398 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7399 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 7400 | { |
| 7401 | return -EINVAL; |
| 7402 | } |
| 7403 | return 0; |
| 7404 | } |
| 7405 | |
| 7406 | |
| 7407 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7408 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 7409 | struct net_device *netdev, |
| 7410 | u8 key_index) |
| 7411 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7412 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7413 | return 0; |
| 7414 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7415 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7416 | |
| 7417 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 7418 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 7419 | struct net_device *dev, |
| 7420 | struct ieee80211_txq_params *params) |
| 7421 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7422 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7423 | return 0; |
| 7424 | } |
| 7425 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7426 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 7427 | struct ieee80211_txq_params *params) |
| 7428 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7429 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7430 | return 0; |
| 7431 | } |
| 7432 | #endif //LINUX_VERSION_CODE |
| 7433 | |
| 7434 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 7435 | struct net_device *dev, u8 *mac) |
| 7436 | { |
| 7437 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7438 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7439 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7440 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7441 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7442 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7443 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7444 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7445 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7446 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7447 | return -EINVAL; |
| 7448 | } |
| 7449 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7450 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7451 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7452 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7453 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7454 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7455 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7456 | "%s: HDD context is not valid", __func__); |
| 7457 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7458 | } |
| 7459 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7460 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7461 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7462 | ) |
| 7463 | { |
| 7464 | if( NULL == mac ) |
| 7465 | { |
| 7466 | v_U16_t i; |
| 7467 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 7468 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 7469 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 7470 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7471 | { |
| 7472 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 7473 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7474 | "%s: Delete STA with MAC::" |
| 7475 | MAC_ADDRESS_STR, |
| 7476 | __func__, MAC_ADDR_ARRAY(macAddr)); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 7477 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 7478 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7479 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7480 | } |
| 7481 | } |
| 7482 | } |
| 7483 | else |
| 7484 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7485 | |
| 7486 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 7487 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7488 | { |
| 7489 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7490 | "%s: Skip this DEL STA as this is not used::" |
| 7491 | MAC_ADDRESS_STR, |
| 7492 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7493 | return -ENOENT; |
| 7494 | } |
| 7495 | |
| 7496 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 7497 | { |
| 7498 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7499 | "%s: Skip this DEL STA as deauth is in progress::" |
| 7500 | MAC_ADDRESS_STR, |
| 7501 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7502 | return -ENOENT; |
| 7503 | } |
| 7504 | |
| 7505 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 7506 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7507 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7508 | "%s: Delete STA with MAC::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7509 | MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7510 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7511 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7512 | |
| 7513 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 7514 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7515 | { |
| 7516 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 7517 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7518 | "%s: STA removal failed for ::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7519 | MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7520 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7521 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7522 | return -ENOENT; |
| 7523 | } |
| 7524 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7525 | } |
| 7526 | } |
| 7527 | |
| 7528 | EXIT(); |
| 7529 | |
| 7530 | return 0; |
| 7531 | } |
| 7532 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7533 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 7534 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 7535 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7536 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7537 | #ifdef FEATURE_WLAN_TDLS |
| 7538 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7539 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7540 | mask = params->sta_flags_mask; |
| 7541 | |
| 7542 | set = params->sta_flags_set; |
| 7543 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7544 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7545 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7546 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 7547 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 7548 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7549 | |
| 7550 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7551 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7552 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7553 | } |
| 7554 | } |
| 7555 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7556 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7557 | } |
| 7558 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7559 | |
| 7560 | #ifdef FEATURE_WLAN_LFR |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7561 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 7562 | |
| 7563 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache |
| 7564 | static tANI_U32 PMKIDCacheIndex; // HDD local Cache index |
| 7565 | |
| 7566 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7567 | 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] | 7568 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7569 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7570 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7571 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7572 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7573 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7574 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7575 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7576 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7577 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7578 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR, |
| 7579 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7580 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7581 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7582 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7583 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7584 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7585 | return -EINVAL; |
| 7586 | } |
| 7587 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7588 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7589 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7590 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7591 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7592 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7593 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7594 | "%s: HDD context is not valid", __func__); |
| 7595 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7596 | } |
| 7597 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7598 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7599 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7600 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7601 | for (j = 0; j < PMKIDCacheIndex; j++) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7602 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7603 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7604 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 7605 | { |
| 7606 | /* BSSID matched previous entry. Overwrite it. */ |
| 7607 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7608 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7609 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7610 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7611 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7612 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7613 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7614 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7615 | dump_bssid(pmksa->bssid); |
| 7616 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7617 | break; |
| 7618 | } |
| 7619 | } |
| 7620 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7621 | /* Check we compared all entries,if then take the first slot now */ |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7622 | if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0; |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7623 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7624 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7625 | { |
| 7626 | // 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] | 7627 | vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7628 | pmksa->bssid, ETHER_ADDR_LEN); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7629 | vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7630 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7631 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7632 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.", |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7633 | __func__, PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7634 | dump_bssid(pmksa->bssid); |
| 7635 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7636 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7637 | // 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] | 7638 | if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7639 | } |
| 7640 | |
| 7641 | |
| 7642 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7643 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7644 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7645 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.", |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7646 | __func__, PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7647 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7648 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7649 | PMKIDCache, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7650 | PMKIDCacheIndex); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7651 | return 0; |
| 7652 | } |
| 7653 | |
| 7654 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7655 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7656 | 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] | 7657 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7658 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7659 | tANI_U32 j=0; |
| 7660 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7661 | tHalHandle halHandle; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7662 | tANI_U8 BSSIDMatched = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7663 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7664 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7665 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7666 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR, |
| 7667 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7668 | |
| 7669 | /* Validate pAdapter */ |
| 7670 | if (NULL == pAdapter) |
| 7671 | { |
| 7672 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
| 7673 | return -EINVAL; |
| 7674 | } |
| 7675 | |
| 7676 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7677 | status = wlan_hdd_validate_context(pHddCtx); |
| 7678 | |
| 7679 | if (0 != status) |
| 7680 | { |
| 7681 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7682 | "%s: HDD context is not valid", __func__); |
| 7683 | return status; |
| 7684 | } |
| 7685 | |
| 7686 | /*Retrieve halHandle*/ |
| 7687 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7688 | |
| 7689 | /*in case index is 0,no entry to delete*/ |
| 7690 | if (0 == PMKIDCacheIndex) |
| 7691 | { |
| 7692 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" , |
| 7693 | __func__); |
| 7694 | return -EINVAL; |
| 7695 | } |
| 7696 | |
| 7697 | /*find the matching PMKSA entry from j=0 to (index-1), |
| 7698 | * and delete the matched one |
| 7699 | */ |
| 7700 | for (j = 0; j<PMKIDCacheIndex; j++) |
| 7701 | { |
| 7702 | if (vos_mem_compare(PMKIDCache[j].BSSID, |
| 7703 | pmksa->bssid, |
| 7704 | WNI_CFG_BSSID_LEN)) |
| 7705 | { |
| 7706 | /* BSSID matched entry */ |
| 7707 | BSSIDMatched = 1; |
| 7708 | |
| 7709 | if (j<PMKIDCacheIndex-1) |
| 7710 | { |
| 7711 | /*replace the matching entry with the last entry in HDD local cache*/ |
| 7712 | vos_mem_copy(PMKIDCache[j].BSSID, |
| 7713 | PMKIDCache[PMKIDCacheIndex-1].BSSID, |
| 7714 | WNI_CFG_BSSID_LEN); |
| 7715 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7716 | PMKIDCache[PMKIDCacheIndex-1].PMKID, |
| 7717 | CSR_RSN_PMKID_SIZE); |
| 7718 | } |
| 7719 | |
| 7720 | /*clear the last entry in HDD cache ---[index-1]*/ |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7721 | vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN); |
| 7722 | vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE); |
| 7723 | |
| 7724 | /*reduce the PMKID array index*/ |
| 7725 | PMKIDCacheIndex--; |
| 7726 | |
| 7727 | /*delete the last PMKID cache in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7728 | if (eHAL_STATUS_SUCCESS != |
| 7729 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7730 | { |
| 7731 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.", |
| 7732 | __func__,PMKIDCacheIndex); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7733 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7734 | } |
| 7735 | |
| 7736 | dump_bssid(pmksa->bssid); |
| 7737 | dump_pmkid(halHandle,pmksa->pmkid); |
| 7738 | |
| 7739 | break; |
| 7740 | } |
| 7741 | } |
| 7742 | |
| 7743 | /* we compare all entries,but cannot find matching entry */ |
| 7744 | if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched) |
| 7745 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7746 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7747 | "%s: No such PMKSA entry existed " MAC_ADDRESS_STR, |
| 7748 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7749 | dump_bssid(pmksa->bssid); |
| 7750 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7751 | return -EINVAL; |
| 7752 | } |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7753 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7754 | } |
| 7755 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7756 | |
| 7757 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7758 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 7759 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7760 | tANI_U32 j=0; |
| 7761 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7762 | tHalHandle halHandle; |
| 7763 | hdd_context_t *pHddCtx; |
| 7764 | tANI_U8 *pBSSId; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7765 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7766 | |
| 7767 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__); |
| 7768 | |
| 7769 | /* Validate pAdapter */ |
| 7770 | if (NULL == pAdapter) |
| 7771 | { |
| 7772 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7773 | "%s: Invalid Adapter" ,__func__); |
| 7774 | return -EINVAL; |
| 7775 | } |
| 7776 | |
| 7777 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7778 | status = wlan_hdd_validate_context(pHddCtx); |
| 7779 | |
| 7780 | if (0 != status) |
| 7781 | { |
| 7782 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7783 | "%s: HDD context is not valid", __func__); |
| 7784 | return status; |
| 7785 | } |
| 7786 | |
| 7787 | /*Retrieve halHandle*/ |
| 7788 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7789 | |
| 7790 | /*in case index is 0,no entry to delete*/ |
| 7791 | if (0 == PMKIDCacheIndex) |
| 7792 | { |
| 7793 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" , |
| 7794 | __func__); |
| 7795 | return -EINVAL; |
| 7796 | } |
| 7797 | |
| 7798 | /*delete all the PMKSA one by one */ |
| 7799 | for (j = 0; j<PMKIDCacheIndex; j++) |
| 7800 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7801 | pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7802 | |
| 7803 | /*delete the PMKID in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7804 | if (eHAL_STATUS_SUCCESS != |
| 7805 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7806 | { |
| 7807 | hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.", |
| 7808 | __func__,j); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7809 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7810 | } |
Kiet Lam | 8d21d5b | 2013-10-31 17:18:29 +0530 | [diff] [blame] | 7811 | /*clear the entry in HDD cache 0--index-1 */ |
| 7812 | vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN); |
| 7813 | vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7814 | } |
| 7815 | |
| 7816 | PMKIDCacheIndex = 0; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7817 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7818 | } |
| 7819 | #endif |
| 7820 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7821 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7822 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7823 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 7824 | { |
| 7825 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7826 | hdd_station_ctx_t *pHddStaCtx; |
| 7827 | |
| 7828 | if (NULL == pAdapter) |
| 7829 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7830 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7831 | return -ENODEV; |
| 7832 | } |
| 7833 | |
| 7834 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7835 | |
| 7836 | // Added for debug on reception of Re-assoc Req. |
| 7837 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 7838 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7839 | 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] | 7840 | ftie->ie_len); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7841 | hddLog(LOGE, FL("Should be Re-assoc Req IEs")); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7842 | } |
| 7843 | |
| 7844 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7845 | hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7846 | ftie->ie_len); |
| 7847 | #endif |
| 7848 | |
| 7849 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7850 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 7851 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7852 | ftie->ie_len); |
| 7853 | return 0; |
| 7854 | } |
| 7855 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7856 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7857 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7858 | |
| 7859 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 7860 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7861 | { |
| 7862 | int ret; |
| 7863 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 7864 | hdd_context_t *pHddCtx; |
| 7865 | |
| 7866 | if (NULL == pAdapter) |
| 7867 | { |
| 7868 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7869 | "%s: HDD adapter is Null", __func__); |
| 7870 | return ; |
| 7871 | } |
| 7872 | |
| 7873 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7874 | if (NULL == pHddCtx) |
| 7875 | { |
| 7876 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7877 | "%s: HDD context is Null!!!", __func__); |
| 7878 | return ; |
| 7879 | } |
| 7880 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7881 | spin_lock(&pHddCtx->schedScan_lock); |
| 7882 | if (TRUE == pHddCtx->isWiphySuspended) |
| 7883 | { |
| 7884 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 7885 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7886 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7887 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 7888 | return ; |
| 7889 | } |
| 7890 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7891 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7892 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7893 | |
| 7894 | if (0 > ret) |
| 7895 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7896 | |
| 7897 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7898 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7899 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7900 | } |
| 7901 | |
| 7902 | /* |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7903 | * FUNCTION: wlan_hdd_is_pno_allowed |
| 7904 | * To check is there any P2P GO/SAP or P2P Client/STA |
| 7905 | * session is active |
| 7906 | */ |
| 7907 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter) |
| 7908 | { |
| 7909 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7910 | hdd_adapter_t *pTempAdapter = NULL; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7911 | hdd_station_ctx_t *pStaCtx; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7912 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7913 | int status = 0; |
| 7914 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 7915 | |
| 7916 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)) |
| 7917 | { |
| 7918 | pTempAdapter = pAdapterNode->pAdapter; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7919 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7920 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7921 | if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode) |
| 7922 | && (eConnectionState_NotConnected != pStaCtx->conn_info.connState)) |
| 7923 | || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode) |
| 7924 | || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode) |
| 7925 | || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode) |
| 7926 | ) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7927 | { |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7928 | return eHAL_STATUS_FAILURE; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7929 | } |
| 7930 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7931 | pAdapterNode = pNext; |
| 7932 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7933 | return eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7934 | } |
| 7935 | |
| 7936 | /* |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7937 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7938 | * NL interface to enable PNO |
| 7939 | */ |
| 7940 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7941 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7942 | { |
| 7943 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7944 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7945 | hdd_context_t *pHddCtx; |
| 7946 | tHalHandle hHal; |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 7947 | v_U32_t i, indx, num_ch, tempInterval; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7948 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7949 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7950 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7951 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7952 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7953 | |
| 7954 | if (NULL == pAdapter) |
| 7955 | { |
| 7956 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7957 | "%s: HDD adapter is Null", __func__); |
| 7958 | return -ENODEV; |
| 7959 | } |
| 7960 | |
| 7961 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7962 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7963 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7964 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7965 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7967 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7968 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7969 | } |
| 7970 | |
| 7971 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7972 | if (NULL == hHal) |
| 7973 | { |
| 7974 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7975 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7976 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7977 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7978 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7979 | /* The current firmware design for PNO does not consider concurrent |
| 7980 | * active sessions.Hence , determine the concurrent active sessions |
| 7981 | * and return a failure to the framework on a request for schedule |
| 7982 | * scan. |
| 7983 | */ |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7984 | if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter)) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7985 | { |
| 7986 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 7987 | FL("Cannot handle sched_scan")); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 7988 | return -EBUSY; |
| 7989 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7990 | |
| 7991 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7992 | if (NULL == pPnoRequest) |
| 7993 | { |
| 7994 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7995 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7996 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7997 | } |
| 7998 | |
Madan Mohan Koyyalamudi | c3f0435 | 2013-09-26 19:21:48 +0530 | [diff] [blame] | 7999 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8000 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 8001 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 8002 | |
| 8003 | if (( !pPnoRequest->ucNetworksCount ) || |
| 8004 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 8005 | { |
| 8006 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8007 | "Network input is not correct"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8008 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8009 | goto error; |
| 8010 | } |
| 8011 | |
| 8012 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 8013 | { |
| 8014 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8015 | "Incorrect number of channels"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8016 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8017 | goto error; |
| 8018 | } |
| 8019 | |
| 8020 | /* Framework provides one set of channels(all) |
| 8021 | * common for all saved profile */ |
| 8022 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 8023 | channels_allowed, &num_channels_allowed)) |
| 8024 | { |
| 8025 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8026 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8027 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8028 | goto error; |
| 8029 | } |
| 8030 | /* Checking each channel against allowed channel list */ |
| 8031 | num_ch = 0; |
| 8032 | for (i = 0; i < request->n_channels; i++) |
| 8033 | { |
| 8034 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 8035 | { |
| 8036 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 8037 | { |
| 8038 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 8039 | break ; |
| 8040 | } |
| 8041 | } |
| 8042 | } |
| 8043 | |
| 8044 | /* Filling per profile params */ |
| 8045 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 8046 | { |
| 8047 | pPnoRequest->aNetworks[i].ssId.length = |
| 8048 | request->match_sets[i].ssid.ssid_len; |
| 8049 | |
| 8050 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 8051 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 8052 | { |
| 8053 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8054 | "SSID Len %d is not correct for network %d", |
| 8055 | pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8056 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8057 | goto error; |
| 8058 | } |
| 8059 | |
| 8060 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 8061 | request->match_sets[i].ssid.ssid, |
| 8062 | request->match_sets[i].ssid.ssid_len); |
| 8063 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 8064 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 8065 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 8066 | |
| 8067 | /*Copying list of valid channel into request */ |
| 8068 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 8069 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 8070 | |
| 8071 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 8072 | } |
| 8073 | |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 8074 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 8075 | "request->ie_len = %zu", request->ie_len); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 8076 | if ((0 < request->ie_len) && (NULL != request->ie)) |
| 8077 | { |
| 8078 | pPnoRequest->us24GProbeTemplateLen = request->ie_len; |
| 8079 | memcpy(&pPnoRequest->p24GProbeTemplate, request->ie, |
| 8080 | pPnoRequest->us24GProbeTemplateLen); |
| 8081 | |
| 8082 | pPnoRequest->us5GProbeTemplateLen = request->ie_len; |
| 8083 | memcpy(&pPnoRequest->p5GProbeTemplate, request->ie, |
| 8084 | pPnoRequest->us5GProbeTemplateLen); |
| 8085 | } |
| 8086 | |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 8087 | /* Driver gets only one time interval which is hardcoded in |
| 8088 | * supplicant for 10000ms. Taking power consumption into account 6 timers |
| 8089 | * will be used, Timervalue is increased exponentially i.e 10,20,40, |
| 8090 | * 80,160,320 secs. And number of scan cycle for each timer |
| 8091 | * is configurable through INI param gPNOScanTimerRepeatValue. |
| 8092 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 8093 | * will be repeated after each interval specified by supplicant |
| 8094 | * till PNO is disabled. |
| 8095 | */ |
| 8096 | if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue) |
| 8097 | pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 8098 | else |
| 8099 | pPnoRequest->scanTimers.ucScanTimersCount = |
| 8100 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 8101 | |
| 8102 | tempInterval = (request->interval)/1000; |
| 8103 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8104 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 8105 | tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue); |
| 8106 | for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++) |
| 8107 | { |
| 8108 | pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat = |
| 8109 | pHddCtx->cfg_ini->configPNOScanTimerRepeatValue; |
| 8110 | pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval; |
| 8111 | tempInterval *= 2; |
| 8112 | } |
| 8113 | //Repeat last timer until pno disabled. |
| 8114 | pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
| 8115 | |
Madan Mohan Koyyalamudi | d206c7b | 2013-09-26 22:54:51 +0530 | [diff] [blame] | 8116 | pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8117 | |
| 8118 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8119 | pPnoRequest, pAdapter->sessionId, |
| 8120 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 8121 | if (eHAL_STATUS_SUCCESS != status) |
| 8122 | { |
| 8123 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8124 | "Failed to enable PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8125 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8126 | goto error; |
| 8127 | } |
| 8128 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8129 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8130 | "PNO scanRequest offloaded"); |
| 8131 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8132 | error: |
| 8133 | vos_mem_free(pPnoRequest); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8134 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8135 | } |
| 8136 | |
| 8137 | /* |
| 8138 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 8139 | * NL interface to disable PNO |
| 8140 | */ |
| 8141 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 8142 | struct net_device *dev) |
| 8143 | { |
| 8144 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8145 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8146 | hdd_context_t *pHddCtx; |
| 8147 | tHalHandle hHal; |
| 8148 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8149 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8150 | |
| 8151 | ENTER(); |
| 8152 | |
| 8153 | if (NULL == pAdapter) |
| 8154 | { |
| 8155 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8156 | "%s: HDD adapter is Null", __func__); |
| 8157 | return -ENODEV; |
| 8158 | } |
| 8159 | |
| 8160 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8161 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8162 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8163 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8164 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8165 | "%s: HDD context is Null", __func__); |
| 8166 | return -ENODEV; |
| 8167 | } |
| 8168 | |
| 8169 | /* The return 0 is intentional when isLogpInProgress and |
| 8170 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 8171 | * failure in sched_scan_stop , especially for a case where the unload |
| 8172 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 8173 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 8174 | * success. If it returns a failure , then its next invocation due to the |
| 8175 | * clean up of the second interface will have the dev pointer corresponding |
| 8176 | * to the first one leading to a crash. |
| 8177 | */ |
| 8178 | if (pHddCtx->isLogpInProgress) |
| 8179 | { |
| 8180 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8181 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8182 | return ret; |
| 8183 | } |
| 8184 | |
| 8185 | if (pHddCtx->isLoadUnloadInProgress) |
| 8186 | { |
| 8187 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8188 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 8189 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8190 | } |
| 8191 | |
| 8192 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8193 | if (NULL == hHal) |
| 8194 | { |
| 8195 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8196 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8197 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8198 | } |
| 8199 | |
| 8200 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 8201 | if (NULL == pPnoRequest) |
| 8202 | { |
| 8203 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8204 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8205 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8206 | } |
| 8207 | |
| 8208 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 8209 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 8210 | pPnoRequest->ucNetworksCount = 0; |
| 8211 | |
| 8212 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 8213 | pAdapter->sessionId, |
| 8214 | NULL, pAdapter); |
| 8215 | if (eHAL_STATUS_SUCCESS != status) |
| 8216 | { |
| 8217 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8218 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8219 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8220 | } |
| 8221 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8222 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8223 | "%s: PNO scan disabled", __func__); |
| 8224 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8225 | vos_mem_free(pPnoRequest); |
| 8226 | |
| 8227 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8228 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8229 | } |
| 8230 | |
| 8231 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 8232 | |
| 8233 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8234 | #ifdef FEATURE_WLAN_TDLS |
| 8235 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 8236 | u8 *peer, u8 action_code, u8 dialog_token, |
| 8237 | u16 status_code, const u8 *buf, size_t len) |
| 8238 | { |
| 8239 | |
| 8240 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8241 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8242 | u8 peerMac[6]; |
| 8243 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8244 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8245 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8246 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8247 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8248 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8249 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8250 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8251 | "Invalid arguments"); |
| 8252 | return -EINVAL; |
| 8253 | } |
| 8254 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8255 | if (pHddCtx->isLogpInProgress) |
| 8256 | { |
| 8257 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8258 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8259 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8260 | return -EBUSY; |
| 8261 | } |
| 8262 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8263 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8264 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8265 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 8266 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 8267 | MAC_ADDRESS_STR " action %d declined.", |
| 8268 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8269 | return -ENOTSUPP; |
| 8270 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8271 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8272 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 8273 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 8274 | { |
| 8275 | /* if tdls_mode is disabled to respond to peer's request */ |
| 8276 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 8277 | { |
| 8278 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 8279 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8280 | " TDLS mode is disabled. action %d declined.", |
| 8281 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8282 | |
| 8283 | return -ENOTSUPP; |
| 8284 | } |
| 8285 | } |
| 8286 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8287 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 8288 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8289 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8290 | { |
| 8291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8292 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8293 | " TDLS setup is ongoing. action %d declined.", |
| 8294 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 8295 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8296 | } |
| 8297 | } |
| 8298 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8299 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 8300 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8301 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8302 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8303 | { |
| 8304 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 8305 | we return error code at 'add_station()'. Hence we have this |
| 8306 | check again in addtion to add_station(). |
| 8307 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8308 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8309 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8311 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8312 | " TDLS Max peer already connected. action %d declined.", |
| 8313 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8314 | return -EINVAL; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8315 | } |
| 8316 | else |
| 8317 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8318 | /* maximum reached. tweak to send error code to peer and return |
| 8319 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8320 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8321 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8322 | "%s: " MAC_ADDRESS_STR |
| 8323 | " TDLS Max peer already connected send response status %d", |
| 8324 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8325 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8326 | /* fall through to send setup resp with failure status |
| 8327 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8328 | } |
| 8329 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8330 | else |
| 8331 | { |
| 8332 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8333 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8334 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8335 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8336 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8337 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 8338 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8339 | return -EPERM; |
| 8340 | } |
| 8341 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8342 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8343 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8344 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8345 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 8346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8347 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 8348 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 8349 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8350 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8351 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8352 | /*Except teardown responder will not be used so just make 0*/ |
| 8353 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8354 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8355 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8356 | |
| 8357 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8358 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8359 | |
| 8360 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 8361 | responder = pTdlsPeer->is_responder; |
| 8362 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8363 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8364 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8365 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 8366 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 8367 | dialog_token, status_code, len); |
| 8368 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8369 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8370 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8371 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8372 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 8373 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8374 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8375 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 8376 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8377 | { |
| 8378 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 8379 | { |
| 8380 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8381 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8382 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 8383 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8384 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 8385 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8386 | } |
| 8387 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8388 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 8389 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 8390 | { |
| 8391 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8392 | "%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] | 8393 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 8394 | return -EBUSY; |
| 8395 | } |
| 8396 | |
| 8397 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8398 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 8399 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8400 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8401 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8402 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8403 | if (VOS_STATUS_SUCCESS != status) |
| 8404 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8405 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8406 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8407 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8408 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8409 | return -EINVAL; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8410 | } |
| 8411 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8412 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 8413 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 8414 | |
| 8415 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8416 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8417 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8418 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %u", |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8419 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8420 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8421 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8422 | return -EINVAL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8423 | } |
| 8424 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8425 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8426 | { |
| 8427 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8428 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8429 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8430 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8431 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 8432 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8433 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8434 | } |
| 8435 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 8436 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8437 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8438 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8439 | |
| 8440 | return 0; |
| 8441 | } |
| 8442 | |
| 8443 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 8444 | u8 *peer, enum nl80211_tdls_operation oper) |
| 8445 | { |
| 8446 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8447 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8448 | int status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8449 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8450 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8451 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8452 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8453 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8454 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8455 | return -EINVAL; |
| 8456 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8457 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8458 | status = wlan_hdd_validate_context(pHddCtx); |
| 8459 | |
| 8460 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8461 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8462 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8463 | "%s: HDD context is not valid", __func__); |
| 8464 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8465 | } |
| 8466 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8467 | |
| 8468 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8469 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8470 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8471 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8472 | "TDLS Disabled in INI OR not enabled in FW. " |
| 8473 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8474 | return -ENOTSUPP; |
| 8475 | } |
| 8476 | |
| 8477 | switch (oper) { |
| 8478 | case NL80211_TDLS_ENABLE_LINK: |
| 8479 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8480 | VOS_STATUS status; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8481 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8482 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8483 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8484 | |
| 8485 | if ( NULL == pTdlsPeer ) { |
| 8486 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 8487 | " (oper %d) not exsting. ignored", |
| 8488 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 8489 | return -EINVAL; |
| 8490 | } |
| 8491 | |
| 8492 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8493 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 8494 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 8495 | "NL80211_TDLS_ENABLE_LINK"); |
| 8496 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 8497 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 8498 | { |
| 8499 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 8500 | MAC_ADDRESS_STR " failed", |
| 8501 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 8502 | return -EINVAL; |
| 8503 | } |
| 8504 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8505 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8506 | { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 8507 | long ret; |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8508 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 8509 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8510 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 8511 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 8512 | return -EINVAL; |
| 8513 | } |
| 8514 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8515 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8516 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8517 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 8518 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 8519 | * register with the TL on after the response for this operation |
| 8520 | * is received . |
| 8521 | */ |
| 8522 | ret = wait_for_completion_interruptible_timeout( |
| 8523 | &pAdapter->tdls_link_establish_req_comp, |
| 8524 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 8525 | if (ret <= 0) |
| 8526 | { |
| 8527 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8528 | "%s: Link Establish Request Faled Status %ld", |
| 8529 | __func__, ret); |
| 8530 | return -EINVAL; |
| 8531 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8532 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8533 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 8534 | /* Mark TDLS client Authenticated .*/ |
| 8535 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 8536 | pTdlsPeer->staId, |
| 8537 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8538 | if (VOS_STATUS_SUCCESS == status) |
| 8539 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8540 | if (pTdlsPeer->is_responder == 0) |
| 8541 | { |
| 8542 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 8543 | |
| 8544 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 8545 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 8546 | WAIT_TIME_TDLS_INITIATOR); |
| 8547 | /* suspend initiator TX until it receives direct packet from the |
| 8548 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 8549 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 8550 | &staId, NULL); |
| 8551 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8552 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 8553 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8554 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8555 | |
| 8556 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 8557 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 8558 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8559 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 8560 | int ac; |
| 8561 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 8562 | WLANTL_AC_VI, |
| 8563 | WLANTL_AC_BK, |
| 8564 | WLANTL_AC_BE }; |
| 8565 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 8566 | for(ac=0; ac < 4; ac++) |
| 8567 | { |
| 8568 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 8569 | pTdlsPeer->staId, ucAc[ac], |
| 8570 | tlTid[ac], tlTid[ac], 0, 0, |
| 8571 | WLANTL_BI_DIR ); |
| 8572 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8573 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8574 | } |
| 8575 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8576 | } |
| 8577 | break; |
| 8578 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8579 | { |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8580 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8581 | |
| 8582 | if ( NULL == pTdlsPeer ) { |
| 8583 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 8584 | " (oper %d) not exsting. ignored", |
| 8585 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 8586 | return -EINVAL; |
| 8587 | } |
| 8588 | |
| 8589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8590 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 8591 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 8592 | "NL80211_TDLS_DISABLE_LINK"); |
| 8593 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8594 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8595 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8596 | long status; |
| 8597 | |
| 8598 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 8599 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8600 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8601 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8602 | |
| 8603 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 8604 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 8605 | if (status <= 0) |
| 8606 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8607 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8608 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8609 | "%s: Del station failed status %ld", |
| 8610 | __func__, status); |
| 8611 | return -EPERM; |
| 8612 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8613 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8614 | } |
| 8615 | else |
| 8616 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8617 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8618 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8619 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8620 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8621 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8622 | case NL80211_TDLS_TEARDOWN: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8623 | { |
| 8624 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8625 | " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR, |
| 8626 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8627 | |
| 8628 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 8629 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 8630 | |
| 8631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8632 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 8633 | __func__); |
| 8634 | return -ENOTSUPP; |
| 8635 | } |
| 8636 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8637 | |
| 8638 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8639 | |
| 8640 | if ( NULL == pTdlsPeer ) { |
| 8641 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR |
| 8642 | " peer not exsting", |
| 8643 | __func__, MAC_ADDR_ARRAY(peer)); |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8644 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8645 | } |
| 8646 | else { |
| 8647 | wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, |
| 8648 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 8649 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8650 | |
| 8651 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) |
| 8652 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8653 | break; |
| 8654 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8655 | case NL80211_TDLS_SETUP: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8656 | { |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8657 | hddTdlsPeer_t *pTdlsPeer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8658 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8659 | " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR, |
| 8660 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8661 | |
| 8662 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 8663 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 8664 | |
| 8665 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8666 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 8667 | __func__); |
| 8668 | return -ENOTSUPP; |
| 8669 | } |
| 8670 | |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8671 | /* To cater the requirement of establishing the TDLS link |
| 8672 | * irrespective of the data traffic , get an entry of TDLS peer. |
| 8673 | */ |
| 8674 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer); |
| 8675 | if (pTdlsPeer == NULL) { |
| 8676 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8677 | "%s: peer " MAC_ADDRESS_STR " not existing", |
| 8678 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8679 | return -EINVAL; |
| 8680 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8681 | |
| 8682 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) { |
| 8683 | |
| 8684 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8685 | " %s TDLS Add Force Peer Failed", |
| 8686 | __func__); |
| 8687 | return -EINVAL; |
| 8688 | } |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8689 | break; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8690 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8691 | case NL80211_TDLS_DISCOVERY_REQ: |
| 8692 | /* We don't support in-driver setup/teardown/discovery */ |
| 8693 | return -ENOTSUPP; |
| 8694 | default: |
| 8695 | return -ENOTSUPP; |
| 8696 | } |
| 8697 | return 0; |
| 8698 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8699 | |
| 8700 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 8701 | struct net_device *dev, u8 *peer) |
| 8702 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 8703 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8704 | "tdls send discover req: "MAC_ADDRESS_STR, |
| 8705 | MAC_ADDR_ARRAY(peer)); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8706 | |
| 8707 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 8708 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 8709 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8710 | #endif |
| 8711 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8712 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8713 | /* |
| 8714 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 8715 | * Callback rountine called upon receiving response for |
| 8716 | * get offload info |
| 8717 | */ |
| 8718 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 8719 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 8720 | { |
| 8721 | |
| 8722 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8723 | tANI_U8 tempReplayCounter[8]; |
| 8724 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8725 | |
| 8726 | ENTER(); |
| 8727 | |
| 8728 | if (NULL == pAdapter) |
| 8729 | { |
| 8730 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8731 | "%s: HDD adapter is Null", __func__); |
| 8732 | return ; |
| 8733 | } |
| 8734 | |
| 8735 | if (NULL == pGtkOffloadGetInfoRsp) |
| 8736 | { |
| 8737 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8738 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 8739 | return ; |
| 8740 | } |
| 8741 | |
| 8742 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 8743 | { |
| 8744 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8745 | "%s: wlan Failed to get replay counter value", |
| 8746 | __func__); |
| 8747 | return ; |
| 8748 | } |
| 8749 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8750 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8751 | /* Update replay counter */ |
| 8752 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 8753 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 8754 | |
| 8755 | { |
| 8756 | /* changing from little to big endian since supplicant |
| 8757 | * works on big endian format |
| 8758 | */ |
| 8759 | int i; |
| 8760 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 8761 | |
| 8762 | for (i = 0; i < 8; i++) |
| 8763 | { |
| 8764 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 8765 | } |
| 8766 | } |
| 8767 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8768 | /* Update replay counter to NL */ |
| 8769 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8770 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8771 | } |
| 8772 | |
| 8773 | /* |
| 8774 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 8775 | * This function is used to offload GTK rekeying job to the firmware. |
| 8776 | */ |
| 8777 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 8778 | struct cfg80211_gtk_rekey_data *data) |
| 8779 | { |
| 8780 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8781 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8782 | hdd_station_ctx_t *pHddStaCtx; |
| 8783 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8784 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8785 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8786 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8787 | |
| 8788 | ENTER(); |
| 8789 | |
| 8790 | if (NULL == pAdapter) |
| 8791 | { |
| 8792 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8793 | "%s: HDD adapter is Null", __func__); |
| 8794 | return -ENODEV; |
| 8795 | } |
| 8796 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8797 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8798 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8799 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8800 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8801 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8802 | "%s: HDD context is not valid", __func__); |
| 8803 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8804 | } |
| 8805 | |
| 8806 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8807 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8808 | if (NULL == hHal) |
| 8809 | { |
| 8810 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8811 | "%s: HAL context is Null!!!", __func__); |
| 8812 | return -EAGAIN; |
| 8813 | } |
| 8814 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8815 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 8816 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 8817 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 8818 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8819 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8820 | { |
| 8821 | /* changing from big to little endian since driver |
| 8822 | * works on little endian format |
| 8823 | */ |
| 8824 | tANI_U8 *p = |
| 8825 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 8826 | int i; |
| 8827 | |
| 8828 | for (i = 0; i < 8; i++) |
| 8829 | { |
| 8830 | p[7-i] = data->replay_ctr[i]; |
| 8831 | } |
| 8832 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8833 | |
| 8834 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 8835 | { |
| 8836 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8837 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 8838 | sizeof (tSirGtkOffloadParams)); |
| 8839 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8840 | pAdapter->sessionId); |
| 8841 | |
| 8842 | if (eHAL_STATUS_SUCCESS != status) |
| 8843 | { |
| 8844 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8845 | "%s: sme_SetGTKOffload failed, returned %d", |
| 8846 | __func__, status); |
| 8847 | return status; |
| 8848 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8849 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8850 | "%s: sme_SetGTKOffload successfull", __func__); |
| 8851 | } |
| 8852 | else |
| 8853 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8854 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8855 | "%s: wlan not suspended GTKOffload request is stored", |
| 8856 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8857 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8858 | |
| 8859 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8860 | } |
| 8861 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 8862 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8863 | /* |
| 8864 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 8865 | * This function is used to set access control policy |
| 8866 | */ |
| 8867 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 8868 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 8869 | { |
| 8870 | int i; |
| 8871 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8872 | hdd_hostapd_state_t *pHostapdState; |
| 8873 | tsap_Config_t *pConfig; |
| 8874 | v_CONTEXT_t pVosContext = NULL; |
| 8875 | hdd_context_t *pHddCtx; |
| 8876 | int status; |
| 8877 | |
| 8878 | ENTER(); |
| 8879 | |
| 8880 | if (NULL == pAdapter) |
| 8881 | { |
| 8882 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8883 | "%s: HDD adapter is Null", __func__); |
| 8884 | return -ENODEV; |
| 8885 | } |
| 8886 | |
| 8887 | if (NULL == params) |
| 8888 | { |
| 8889 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8890 | "%s: params is Null", __func__); |
| 8891 | return -EINVAL; |
| 8892 | } |
| 8893 | |
| 8894 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8895 | status = wlan_hdd_validate_context(pHddCtx); |
| 8896 | |
| 8897 | if (0 != status) |
| 8898 | { |
| 8899 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8900 | "%s: HDD context is not valid", __func__); |
| 8901 | return status; |
| 8902 | } |
| 8903 | |
| 8904 | pVosContext = pHddCtx->pvosContext; |
| 8905 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8906 | |
| 8907 | if (NULL == pHostapdState) |
| 8908 | { |
| 8909 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8910 | "%s: pHostapdState is Null", __func__); |
| 8911 | return -EINVAL; |
| 8912 | } |
| 8913 | |
| 8914 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 8915 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 8916 | |
| 8917 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 8918 | { |
| 8919 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 8920 | |
| 8921 | /* default value */ |
| 8922 | pConfig->num_accept_mac = 0; |
| 8923 | pConfig->num_deny_mac = 0; |
| 8924 | |
| 8925 | /** |
| 8926 | * access control policy |
| 8927 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 8928 | * listed in hostapd.deny file. |
| 8929 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 8930 | * listed in hostapd.accept file. |
| 8931 | */ |
| 8932 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 8933 | { |
| 8934 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 8935 | } |
| 8936 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 8937 | { |
| 8938 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 8939 | } |
| 8940 | else |
| 8941 | { |
| 8942 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8943 | "%s:Acl Policy : %d is not supported", |
| 8944 | __func__, params->acl_policy); |
| 8945 | return -ENOTSUPP; |
| 8946 | } |
| 8947 | |
| 8948 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 8949 | { |
| 8950 | pConfig->num_accept_mac = params->n_acl_entries; |
| 8951 | for (i = 0; i < params->n_acl_entries; i++) |
| 8952 | { |
| 8953 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8954 | "** Add ACL MAC entry %i in WhiletList :" |
| 8955 | MAC_ADDRESS_STR, i, |
| 8956 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8957 | |
| 8958 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 8959 | sizeof(qcmacaddr)); |
| 8960 | } |
| 8961 | } |
| 8962 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 8963 | { |
| 8964 | pConfig->num_deny_mac = params->n_acl_entries; |
| 8965 | for (i = 0; i < params->n_acl_entries; i++) |
| 8966 | { |
| 8967 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8968 | "** Add ACL MAC entry %i in BlackList :" |
| 8969 | MAC_ADDRESS_STR, i, |
| 8970 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8971 | |
| 8972 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 8973 | sizeof(qcmacaddr)); |
| 8974 | } |
| 8975 | } |
| 8976 | |
| 8977 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 8978 | { |
| 8979 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8980 | "%s: SAP Set Mac Acl fail", __func__); |
| 8981 | return -EINVAL; |
| 8982 | } |
| 8983 | } |
| 8984 | else |
| 8985 | { |
| 8986 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8987 | "%s: Invalid device_mode = %d", |
| 8988 | __func__, pAdapter->device_mode); |
| 8989 | return -EINVAL; |
| 8990 | } |
| 8991 | |
| 8992 | return 0; |
| 8993 | } |
| 8994 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8995 | #ifdef WLAN_NL80211_TESTMODE |
| 8996 | #ifdef FEATURE_WLAN_LPHB |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 8997 | void wlan_hdd_cfg80211_lphb_ind_handler |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8998 | ( |
| 8999 | void *pAdapter, |
| 9000 | void *indCont |
| 9001 | ) |
| 9002 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9003 | tSirLPHBInd *lphbInd; |
| 9004 | struct sk_buff *skb; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9005 | |
| 9006 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9007 | "LPHB indication arrived"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9008 | |
| 9009 | if (NULL == indCont) |
| 9010 | { |
| 9011 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9012 | "LPHB IND, invalid argument"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9013 | return; |
| 9014 | } |
| 9015 | |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9016 | lphbInd = (tSirLPHBInd *)indCont; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9017 | skb = cfg80211_testmode_alloc_event_skb( |
| 9018 | ((hdd_adapter_t *)pAdapter)->wdev.wiphy, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9019 | sizeof(tSirLPHBInd), |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9020 | GFP_ATOMIC); |
| 9021 | if (!skb) |
| 9022 | { |
| 9023 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9024 | "LPHB timeout, NL buffer alloc fail"); |
| 9025 | return; |
| 9026 | } |
| 9027 | |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9028 | 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] | 9029 | { |
| 9030 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9031 | "WLAN_HDD_TM_ATTR_CMD put fail"); |
| 9032 | goto nla_put_failure; |
| 9033 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9034 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9035 | { |
| 9036 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9037 | "WLAN_HDD_TM_ATTR_TYPE put fail"); |
| 9038 | goto nla_put_failure; |
| 9039 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9040 | if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9041 | sizeof(tSirLPHBInd), lphbInd)) |
| 9042 | { |
| 9043 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9044 | "WLAN_HDD_TM_ATTR_DATA put fail"); |
| 9045 | goto nla_put_failure; |
| 9046 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9047 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 9048 | return; |
| 9049 | |
| 9050 | nla_put_failure: |
| 9051 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9052 | "NLA Put fail"); |
| 9053 | kfree_skb(skb); |
| 9054 | |
| 9055 | return; |
| 9056 | } |
| 9057 | #endif /* FEATURE_WLAN_LPHB */ |
| 9058 | |
| 9059 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 9060 | { |
| 9061 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 9062 | int err = 0; |
| 9063 | #ifdef FEATURE_WLAN_LPHB |
| 9064 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9065 | eHalStatus smeStatus; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9066 | #endif /* FEATURE_WLAN_LPHB */ |
| 9067 | |
| 9068 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 9069 | if (err) |
| 9070 | { |
| 9071 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9072 | "%s Testmode INV ATTR", __func__); |
| 9073 | return err; |
| 9074 | } |
| 9075 | |
| 9076 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 9077 | { |
| 9078 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9079 | "%s Testmode INV CMD", __func__); |
| 9080 | return -EINVAL; |
| 9081 | } |
| 9082 | |
| 9083 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 9084 | { |
| 9085 | #ifdef FEATURE_WLAN_LPHB |
| 9086 | /* Low Power Heartbeat configuration request */ |
| 9087 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 9088 | { |
| 9089 | int buf_len; |
| 9090 | void *buf; |
| 9091 | tSirLPHBReq *hb_params = NULL; |
| 9092 | |
| 9093 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 9094 | { |
| 9095 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9096 | "%s Testmode INV DATA", __func__); |
| 9097 | return -EINVAL; |
| 9098 | } |
| 9099 | |
| 9100 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 9101 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 9102 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 9103 | if (NULL == hb_params) |
| 9104 | { |
| 9105 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9106 | "%s Request Buffer Alloc Fail", __func__); |
| 9107 | return -EINVAL; |
| 9108 | } |
| 9109 | |
| 9110 | vos_mem_copy(hb_params, buf, buf_len); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9111 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 9112 | hb_params, |
| 9113 | wlan_hdd_cfg80211_lphb_ind_handler); |
| 9114 | if (eHAL_STATUS_SUCCESS != smeStatus) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9115 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9116 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9117 | "LPHB Config Fail, disable"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9118 | vos_mem_free(hb_params); |
| 9119 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9120 | return 0; |
| 9121 | } |
| 9122 | #endif /* FEATURE_WLAN_LPHB */ |
| 9123 | default: |
| 9124 | return -EOPNOTSUPP; |
| 9125 | } |
| 9126 | |
| 9127 | return err; |
| 9128 | } |
| 9129 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 9130 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9131 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 9132 | struct net_device *dev, |
| 9133 | int idx, struct survey_info *survey) |
| 9134 | { |
| 9135 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9136 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9137 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9138 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9139 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9140 | v_S7_t snr,rssi; |
| 9141 | int status, i, j, filled = 0; |
| 9142 | |
| 9143 | ENTER(); |
| 9144 | |
| 9145 | |
| 9146 | if (NULL == pAdapter) |
| 9147 | { |
| 9148 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9149 | "%s: HDD adapter is Null", __func__); |
| 9150 | return -ENODEV; |
| 9151 | } |
| 9152 | |
| 9153 | if (NULL == wiphy) |
| 9154 | { |
| 9155 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9156 | "%s: wiphy is Null", __func__); |
| 9157 | return -ENODEV; |
| 9158 | } |
| 9159 | |
| 9160 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9161 | status = wlan_hdd_validate_context(pHddCtx); |
| 9162 | |
| 9163 | if (0 != status) |
| 9164 | { |
| 9165 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9166 | "%s: HDD context is not valid", __func__); |
| 9167 | return status; |
| 9168 | } |
| 9169 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9170 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9171 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9172 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9173 | 0 != pAdapter->survey_idx || |
| 9174 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9175 | { |
| 9176 | /* The survey dump ops when implemented completely is expected to |
| 9177 | * return a survey of all channels and the ops is called by the |
| 9178 | * kernel with incremental values of the argument 'idx' till it |
| 9179 | * returns -ENONET. But we can only support the survey for the |
| 9180 | * operating channel for now. survey_idx is used to track |
| 9181 | * that the ops is called only once and then return -ENONET for |
| 9182 | * the next iteration |
| 9183 | */ |
| 9184 | pAdapter->survey_idx = 0; |
| 9185 | return -ENONET; |
| 9186 | } |
| 9187 | |
| 9188 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9189 | |
| 9190 | wlan_hdd_get_snr(pAdapter, &snr); |
| 9191 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 9192 | |
| 9193 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 9194 | hdd_wlan_get_freq(channel, &freq); |
| 9195 | |
| 9196 | |
| 9197 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 9198 | { |
| 9199 | if (NULL == wiphy->bands[i]) |
| 9200 | { |
| 9201 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 9202 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 9203 | continue; |
| 9204 | } |
| 9205 | |
| 9206 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 9207 | { |
| 9208 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 9209 | |
| 9210 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 9211 | { |
| 9212 | survey->channel = &band->channels[j]; |
| 9213 | /* The Rx BDs contain SNR values in dB for the received frames |
| 9214 | * while the supplicant expects noise. So we calculate and |
| 9215 | * return the value of noise (dBm) |
| 9216 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 9217 | */ |
| 9218 | survey->noise = rssi - snr; |
| 9219 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 9220 | filled = 1; |
| 9221 | } |
| 9222 | } |
| 9223 | } |
| 9224 | |
| 9225 | if (filled) |
| 9226 | pAdapter->survey_idx = 1; |
| 9227 | else |
| 9228 | { |
| 9229 | pAdapter->survey_idx = 0; |
| 9230 | return -ENONET; |
| 9231 | } |
| 9232 | |
| 9233 | return 0; |
| 9234 | } |
| 9235 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9236 | /* |
| 9237 | * FUNCTION: wlan_hdd_cfg80211_resume_wlan |
| 9238 | * this is called when cfg80211 driver resume |
| 9239 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 9240 | */ |
| 9241 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 9242 | { |
| 9243 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9244 | hdd_adapter_t *pAdapter; |
| 9245 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 9246 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9247 | |
| 9248 | ENTER(); |
| 9249 | |
| 9250 | if ( NULL == pHddCtx ) |
| 9251 | { |
| 9252 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9253 | "%s: HddCtx validation failed", __func__); |
| 9254 | return 0; |
| 9255 | } |
| 9256 | |
| 9257 | if (pHddCtx->isLogpInProgress) |
| 9258 | { |
| 9259 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9260 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 9261 | return 0; |
| 9262 | } |
| 9263 | |
| 9264 | if (pHddCtx->isLoadUnloadInProgress) |
| 9265 | { |
| 9266 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9267 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 9268 | return 0; |
| 9269 | } |
| 9270 | |
| 9271 | spin_lock(&pHddCtx->schedScan_lock); |
| 9272 | pHddCtx->isWiphySuspended = FALSE; |
| 9273 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 9274 | { |
| 9275 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9276 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9277 | "%s: Return resume is not due to PNO indication", __func__); |
| 9278 | return 0; |
| 9279 | } |
| 9280 | // Reset flag to avoid updatating cfg80211 data old results again |
| 9281 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 9282 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9283 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9284 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9285 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9286 | |
| 9287 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9288 | { |
| 9289 | pAdapter = pAdapterNode->pAdapter; |
| 9290 | if ( (NULL != pAdapter) && |
| 9291 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 9292 | { |
| 9293 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9294 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9295 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 9296 | "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9297 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9298 | else |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9299 | { |
| 9300 | /* Acquire wakelock to handle the case where APP's tries to |
| 9301 | * suspend immediately after updating the scan results. Whis |
| 9302 | * results in app's is in suspended state and not able to |
| 9303 | * process the connect request to AP |
| 9304 | */ |
| 9305 | hdd_prevent_suspend_timeout(2000); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9306 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
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 | |
| 9309 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9310 | "%s : cfg80211 scan result database updated", __func__); |
| 9311 | |
| 9312 | return 0; |
| 9313 | |
| 9314 | } |
| 9315 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9316 | pAdapterNode = pNext; |
| 9317 | } |
| 9318 | |
| 9319 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9320 | "%s: Failed to find Adapter", __func__); |
| 9321 | return 0; |
| 9322 | } |
| 9323 | |
| 9324 | /* |
| 9325 | * FUNCTION: wlan_hdd_cfg80211_suspend_wlan |
| 9326 | * this is called when cfg80211 driver suspends |
| 9327 | */ |
| 9328 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 9329 | struct cfg80211_wowlan *wow) |
| 9330 | { |
| 9331 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9332 | |
| 9333 | ENTER(); |
| 9334 | if (NULL == pHddCtx) |
| 9335 | { |
| 9336 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9337 | "%s: HddCtx validation failed", __func__); |
| 9338 | return 0; |
| 9339 | } |
| 9340 | |
| 9341 | pHddCtx->isWiphySuspended = TRUE; |
| 9342 | |
| 9343 | EXIT(); |
| 9344 | |
| 9345 | return 0; |
| 9346 | } |
| 9347 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9348 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9349 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9350 | { |
| 9351 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 9352 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 9353 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 9354 | .change_station = wlan_hdd_change_station, |
| 9355 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 9356 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 9357 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 9358 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9359 | #else |
| 9360 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 9361 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 9362 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9363 | #endif |
| 9364 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 9365 | .add_key = wlan_hdd_cfg80211_add_key, |
| 9366 | .get_key = wlan_hdd_cfg80211_get_key, |
| 9367 | .del_key = wlan_hdd_cfg80211_del_key, |
| 9368 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9369 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9370 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9371 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9372 | .scan = wlan_hdd_cfg80211_scan, |
| 9373 | .connect = wlan_hdd_cfg80211_connect, |
| 9374 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 9375 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 9376 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 9377 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 9378 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 9379 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9380 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 9381 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 9382 | .mgmt_tx = wlan_hdd_action, |
| 9383 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 9384 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 9385 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 9386 | .set_txq_params = wlan_hdd_set_txq_params, |
| 9387 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9388 | .get_station = wlan_hdd_cfg80211_get_station, |
| 9389 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 9390 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9391 | .add_station = wlan_hdd_cfg80211_add_station, |
| 9392 | #ifdef FEATURE_WLAN_LFR |
| 9393 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 9394 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 9395 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 9396 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9397 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 9398 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 9399 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 9400 | #ifdef FEATURE_WLAN_TDLS |
| 9401 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 9402 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 9403 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9404 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 9405 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 9406 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9407 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9408 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 9409 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 9410 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9411 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 9412 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9413 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9414 | #ifdef WLAN_NL80211_TESTMODE |
| 9415 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 9416 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9417 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9418 | }; |
| 9419 | |