Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
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" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 87 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 88 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 89 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 90 | |
| 91 | #define g_mode_rates_size (12) |
| 92 | #define a_mode_rates_size (8) |
| 93 | #define FREQ_BASE_80211G (2407) |
| 94 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 95 | #define MAX_SCAN_SSID 9 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 96 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 97 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 98 | |
| 99 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 100 | .band = IEEE80211_BAND_2GHZ, \ |
| 101 | .center_freq = (freq), \ |
| 102 | .hw_value = (chan),\ |
| 103 | .flags = (flag), \ |
| 104 | .max_antenna_gain = 0 ,\ |
| 105 | .max_power = 30, \ |
| 106 | } |
| 107 | |
| 108 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 109 | .band = IEEE80211_BAND_5GHZ, \ |
| 110 | .center_freq = (freq), \ |
| 111 | .hw_value = (chan),\ |
| 112 | .flags = (flag), \ |
| 113 | .max_antenna_gain = 0 ,\ |
| 114 | .max_power = 30, \ |
| 115 | } |
| 116 | |
| 117 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 118 | {\ |
| 119 | .bitrate = rate, \ |
| 120 | .hw_value = rate_id, \ |
| 121 | .flags = flag, \ |
| 122 | } |
| 123 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 124 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 125 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 126 | #else |
| 127 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 128 | #endif |
| 129 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 130 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 131 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 132 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 133 | #endif |
| 134 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 135 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 136 | { |
| 137 | WLAN_CIPHER_SUITE_WEP40, |
| 138 | WLAN_CIPHER_SUITE_WEP104, |
| 139 | WLAN_CIPHER_SUITE_TKIP, |
| 140 | #ifdef FEATURE_WLAN_CCX |
| 141 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 142 | WLAN_CIPHER_SUITE_KRK, |
| 143 | WLAN_CIPHER_SUITE_CCMP, |
| 144 | #else |
| 145 | WLAN_CIPHER_SUITE_CCMP, |
| 146 | #endif |
| 147 | #ifdef FEATURE_WLAN_WAPI |
| 148 | WLAN_CIPHER_SUITE_SMS4, |
| 149 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 150 | #ifdef WLAN_FEATURE_11W |
| 151 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 152 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 156 | { |
| 157 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 158 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 159 | } |
| 160 | |
| 161 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 162 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 163 | HDD2GHZCHAN(2412, 1, 0) , |
| 164 | HDD2GHZCHAN(2417, 2, 0) , |
| 165 | HDD2GHZCHAN(2422, 3, 0) , |
| 166 | HDD2GHZCHAN(2427, 4, 0) , |
| 167 | HDD2GHZCHAN(2432, 5, 0) , |
| 168 | HDD2GHZCHAN(2437, 6, 0) , |
| 169 | HDD2GHZCHAN(2442, 7, 0) , |
| 170 | HDD2GHZCHAN(2447, 8, 0) , |
| 171 | HDD2GHZCHAN(2452, 9, 0) , |
| 172 | HDD2GHZCHAN(2457, 10, 0) , |
| 173 | HDD2GHZCHAN(2462, 11, 0) , |
| 174 | HDD2GHZCHAN(2467, 12, 0) , |
| 175 | HDD2GHZCHAN(2472, 13, 0) , |
| 176 | HDD2GHZCHAN(2484, 14, 0) , |
| 177 | }; |
| 178 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 179 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 180 | { |
| 181 | HDD2GHZCHAN(2412, 1, 0) , |
| 182 | HDD2GHZCHAN(2437, 6, 0) , |
| 183 | HDD2GHZCHAN(2462, 11, 0) , |
| 184 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 185 | |
| 186 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 187 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 188 | HDD5GHZCHAN(4920, 240, 0) , |
| 189 | HDD5GHZCHAN(4940, 244, 0) , |
| 190 | HDD5GHZCHAN(4960, 248, 0) , |
| 191 | HDD5GHZCHAN(4980, 252, 0) , |
| 192 | HDD5GHZCHAN(5040, 208, 0) , |
| 193 | HDD5GHZCHAN(5060, 212, 0) , |
| 194 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 195 | HDD5GHZCHAN(5180, 36, 0) , |
| 196 | HDD5GHZCHAN(5200, 40, 0) , |
| 197 | HDD5GHZCHAN(5220, 44, 0) , |
| 198 | HDD5GHZCHAN(5240, 48, 0) , |
| 199 | HDD5GHZCHAN(5260, 52, 0) , |
| 200 | HDD5GHZCHAN(5280, 56, 0) , |
| 201 | HDD5GHZCHAN(5300, 60, 0) , |
| 202 | HDD5GHZCHAN(5320, 64, 0) , |
| 203 | HDD5GHZCHAN(5500,100, 0) , |
| 204 | HDD5GHZCHAN(5520,104, 0) , |
| 205 | HDD5GHZCHAN(5540,108, 0) , |
| 206 | HDD5GHZCHAN(5560,112, 0) , |
| 207 | HDD5GHZCHAN(5580,116, 0) , |
| 208 | HDD5GHZCHAN(5600,120, 0) , |
| 209 | HDD5GHZCHAN(5620,124, 0) , |
| 210 | HDD5GHZCHAN(5640,128, 0) , |
| 211 | HDD5GHZCHAN(5660,132, 0) , |
| 212 | HDD5GHZCHAN(5680,136, 0) , |
| 213 | HDD5GHZCHAN(5700,140, 0) , |
| 214 | HDD5GHZCHAN(5745,149, 0) , |
| 215 | HDD5GHZCHAN(5765,153, 0) , |
| 216 | HDD5GHZCHAN(5785,157, 0) , |
| 217 | HDD5GHZCHAN(5805,161, 0) , |
| 218 | HDD5GHZCHAN(5825,165, 0) , |
| 219 | }; |
| 220 | |
| 221 | static struct ieee80211_rate g_mode_rates[] = |
| 222 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 223 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 224 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 225 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 226 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 227 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 228 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 229 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 230 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 231 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 232 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 233 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 234 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 235 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 236 | |
| 237 | static struct ieee80211_rate a_mode_rates[] = |
| 238 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 239 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 240 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 241 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 242 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 243 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 244 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 245 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 246 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 247 | }; |
| 248 | |
| 249 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 250 | { |
| 251 | .channels = hdd_channels_2_4_GHZ, |
| 252 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 253 | .band = IEEE80211_BAND_2GHZ, |
| 254 | .bitrates = g_mode_rates, |
| 255 | .n_bitrates = g_mode_rates_size, |
| 256 | .ht_cap.ht_supported = 1, |
| 257 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 258 | | IEEE80211_HT_CAP_GRN_FLD |
| 259 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 260 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 261 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 262 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 263 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 264 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 265 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 266 | }; |
| 267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 268 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 269 | { |
| 270 | .channels = hdd_social_channels_2_4_GHZ, |
| 271 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 272 | .band = IEEE80211_BAND_2GHZ, |
| 273 | .bitrates = g_mode_rates, |
| 274 | .n_bitrates = g_mode_rates_size, |
| 275 | .ht_cap.ht_supported = 1, |
| 276 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 277 | | IEEE80211_HT_CAP_GRN_FLD |
| 278 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 279 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 280 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 281 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 282 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 283 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 284 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 285 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 286 | |
| 287 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 288 | { |
| 289 | .channels = hdd_channels_5_GHZ, |
| 290 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 291 | .band = IEEE80211_BAND_5GHZ, |
| 292 | .bitrates = a_mode_rates, |
| 293 | .n_bitrates = a_mode_rates_size, |
| 294 | .ht_cap.ht_supported = 1, |
| 295 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 296 | | IEEE80211_HT_CAP_GRN_FLD |
| 297 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 298 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 299 | | IEEE80211_HT_CAP_SGI_40 |
| 300 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 301 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 302 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 303 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 304 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 305 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 306 | }; |
| 307 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 308 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 309 | TX/RX direction for each kind of interface */ |
| 310 | static const struct ieee80211_txrx_stypes |
| 311 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 312 | [NL80211_IFTYPE_STATION] = { |
| 313 | .tx = 0xffff, |
| 314 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 315 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 316 | }, |
| 317 | [NL80211_IFTYPE_AP] = { |
| 318 | .tx = 0xffff, |
| 319 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 320 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 321 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 322 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 323 | BIT(SIR_MAC_MGMT_AUTH) | |
| 324 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 325 | BIT(SIR_MAC_MGMT_ACTION), |
| 326 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 327 | [NL80211_IFTYPE_ADHOC] = { |
| 328 | .tx = 0xffff, |
| 329 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 330 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 331 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 332 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 333 | BIT(SIR_MAC_MGMT_AUTH) | |
| 334 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 335 | BIT(SIR_MAC_MGMT_ACTION), |
| 336 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 337 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 338 | .tx = 0xffff, |
| 339 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 340 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 341 | }, |
| 342 | [NL80211_IFTYPE_P2P_GO] = { |
| 343 | /* This is also same as for SoftAP */ |
| 344 | .tx = 0xffff, |
| 345 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 346 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 347 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 348 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 349 | BIT(SIR_MAC_MGMT_AUTH) | |
| 350 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 351 | BIT(SIR_MAC_MGMT_ACTION), |
| 352 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 353 | }; |
| 354 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 355 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 356 | static const struct ieee80211_iface_limit |
| 357 | wlan_hdd_iface_limit[] = { |
| 358 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 359 | /* max = 3 ; Our driver create two interfaces during driver init |
| 360 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 361 | * interface until a group is formed. In JB architecture, once the |
| 362 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 363 | * Client. |
| 364 | * When supplicant remove the group, it first issue a set interface |
| 365 | * cmd to change the mode back to Station. In JB this works fine as |
| 366 | * we advertize two station type interface during driver init. |
| 367 | * Some vendors create separate interface for P2P GO/Client, |
| 368 | * after group formation(Third one). But while group remove |
| 369 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 370 | * But as we advertized only two sta type interfaces nl80211 was |
| 371 | * returning error for the third one which was leading to failure in |
| 372 | * delete interface. Ideally while removing the group, supplicant |
| 373 | * should not try to change the 3rd interface mode to Station type. |
| 374 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 375 | * interface type to 3 |
| 376 | */ |
| 377 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 378 | .types = BIT(NL80211_IFTYPE_STATION), |
| 379 | }, |
| 380 | { |
| 381 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 382 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 383 | }, |
| 384 | { |
| 385 | .max = 1, |
| 386 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 387 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 388 | }, |
| 389 | }; |
| 390 | |
| 391 | /* By default, only single channel concurrency is allowed */ |
| 392 | static struct ieee80211_iface_combination |
| 393 | wlan_hdd_iface_combination = { |
| 394 | .limits = wlan_hdd_iface_limit, |
| 395 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 396 | /* |
| 397 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 398 | * and p2p0 interfaces during driver init |
| 399 | * Some vendors create separate interface for P2P operations. |
| 400 | * wlan0: STA interface |
| 401 | * p2p0: P2P Device interface, action frames goes |
| 402 | * through this interface. |
| 403 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 404 | * created for p2p operations(GO/CLIENT interface). |
| 405 | */ |
| 406 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 407 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 408 | .beacon_int_infra_match = false, |
| 409 | }; |
| 410 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 412 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 413 | |
| 414 | /* Data rate 100KBPS based on IE Index */ |
| 415 | struct index_data_rate_type |
| 416 | { |
| 417 | v_U8_t beacon_rate_index; |
| 418 | v_U16_t supported_rate[4]; |
| 419 | }; |
| 420 | |
| 421 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 422 | The IDX field is the rate index |
| 423 | The HI field is the rate when RSSI is strong or being ignored |
| 424 | (in this case we report actual rate) |
| 425 | The MID field is the rate when RSSI is moderate |
| 426 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 427 | The LO field is the rate when RSSI is low |
| 428 | (in this case we don't report rates, actual current rate used) |
| 429 | */ |
| 430 | static const struct |
| 431 | { |
| 432 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 433 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 434 | } supported_data_rate[] = |
| 435 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 436 | /* IDX HI HM LM LO (RSSI-based index */ |
| 437 | {2, { 10, 10, 10, 0}}, |
| 438 | {4, { 20, 20, 10, 0}}, |
| 439 | {11, { 55, 20, 10, 0}}, |
| 440 | {12, { 60, 55, 20, 0}}, |
| 441 | {18, { 90, 55, 20, 0}}, |
| 442 | {22, {110, 55, 20, 0}}, |
| 443 | {24, {120, 90, 60, 0}}, |
| 444 | {36, {180, 120, 60, 0}}, |
| 445 | {44, {220, 180, 60, 0}}, |
| 446 | {48, {240, 180, 90, 0}}, |
| 447 | {66, {330, 180, 90, 0}}, |
| 448 | {72, {360, 240, 90, 0}}, |
| 449 | {96, {480, 240, 120, 0}}, |
| 450 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 451 | }; |
| 452 | |
| 453 | /* MCS Based rate table */ |
| 454 | static struct index_data_rate_type supported_mcs_rate[] = |
| 455 | { |
| 456 | /* MCS L20 L40 S20 S40 */ |
| 457 | {0, {65, 135, 72, 150}}, |
| 458 | {1, {130, 270, 144, 300}}, |
| 459 | {2, {195, 405, 217, 450}}, |
| 460 | {3, {260, 540, 289, 600}}, |
| 461 | {4, {390, 810, 433, 900}}, |
| 462 | {5, {520, 1080, 578, 1200}}, |
| 463 | {6, {585, 1215, 650, 1350}}, |
| 464 | {7, {650, 1350, 722, 1500}} |
| 465 | }; |
| 466 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 467 | #ifdef WLAN_FEATURE_11AC |
| 468 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 469 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 470 | |
| 471 | struct index_vht_data_rate_type |
| 472 | { |
| 473 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 474 | v_U16_t supported_VHT80_rate[2]; |
| 475 | v_U16_t supported_VHT40_rate[2]; |
| 476 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 477 | }; |
| 478 | |
| 479 | typedef enum |
| 480 | { |
| 481 | DATA_RATE_11AC_MAX_MCS_7, |
| 482 | DATA_RATE_11AC_MAX_MCS_8, |
| 483 | DATA_RATE_11AC_MAX_MCS_9, |
| 484 | DATA_RATE_11AC_MAX_MCS_NA |
| 485 | } eDataRate11ACMaxMcs; |
| 486 | |
| 487 | /* MCS Based VHT rate table */ |
| 488 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 489 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 490 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 491 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 492 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 493 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 494 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 495 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 496 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 497 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 498 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 499 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 500 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 501 | }; |
| 502 | #endif /* WLAN_FEATURE_11AC */ |
| 503 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 504 | extern struct net_device_ops net_ops_struct; |
| 505 | |
| 506 | /* |
| 507 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 508 | * This function is called by hdd_wlan_startup() |
| 509 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 510 | * This function is used to initialize and register wiphy structure. |
| 511 | */ |
| 512 | struct wiphy *wlan_hdd_cfg80211_init(int priv_size) |
| 513 | { |
| 514 | struct wiphy *wiphy; |
| 515 | ENTER(); |
| 516 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 517 | /* |
| 518 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 519 | */ |
| 520 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 521 | |
| 522 | if (!wiphy) |
| 523 | { |
| 524 | /* Print error and jump into err label and free the memory */ |
| 525 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 526 | return NULL; |
| 527 | } |
| 528 | |
| 529 | return wiphy; |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 534 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 535 | * private ioctl to change the band value |
| 536 | */ |
| 537 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 538 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 539 | int i, j; |
| 540 | eNVChannelEnabledType channelEnabledState; |
| 541 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 542 | ENTER(); |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 543 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 544 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 545 | |
| 546 | if (NULL == wiphy->bands[i]) |
| 547 | { |
| 548 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 549 | __func__, i); |
| 550 | continue; |
| 551 | } |
| 552 | |
| 553 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 554 | { |
| 555 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 556 | |
| 557 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 558 | band->channels[j].hw_value); |
| 559 | |
| 560 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 561 | { |
| 562 | // Enable Social channels for P2P |
| 563 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 564 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 565 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 566 | else |
| 567 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 568 | continue; |
| 569 | } |
| 570 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 571 | { |
| 572 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 573 | continue; |
| 574 | } |
| 575 | |
| 576 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 577 | NV_CHANNEL_INVALID == channelEnabledState) |
| 578 | { |
| 579 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 580 | } |
| 581 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 582 | { |
| 583 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 584 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 589 | |IEEE80211_CHAN_RADAR); |
| 590 | } |
| 591 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 592 | } |
| 593 | return 0; |
| 594 | } |
| 595 | /* |
| 596 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 597 | * This function is called by hdd_wlan_startup() |
| 598 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 599 | * This function is used to initialize and register wiphy structure. |
| 600 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 601 | int wlan_hdd_cfg80211_register(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 602 | struct wiphy *wiphy, |
| 603 | hdd_config_t *pCfg |
| 604 | ) |
| 605 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 606 | |
| 607 | int i, j; |
| 608 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 609 | ENTER(); |
| 610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 611 | /* Now bind the underlying wlan device with wiphy */ |
| 612 | set_wiphy_dev(wiphy, dev); |
| 613 | |
| 614 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
| 615 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 616 | wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 617 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 618 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 619 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 620 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 621 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 622 | | WIPHY_FLAG_OFFCHAN_TX; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 623 | #endif |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 624 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 625 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 626 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 627 | || pCfg->isFastRoamIniFeatureEnabled |
| 628 | #endif |
| 629 | #ifdef FEATURE_WLAN_CCX |
| 630 | || pCfg->isCcxIniFeatureEnabled |
| 631 | #endif |
| 632 | ) |
| 633 | { |
| 634 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 635 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 636 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 637 | #ifdef FEATURE_WLAN_TDLS |
| 638 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 639 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 640 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 641 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 642 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 643 | wiphy->max_sched_scan_ssids = MAX_SCAN_SSID; |
| 644 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 645 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 646 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 647 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 648 | driver can still register regulatory callback and |
| 649 | it will get CRDA setting in wiphy->band[], but |
| 650 | driver need to determine what to do with both |
| 651 | regulatory settings */ |
| 652 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 653 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 654 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 655 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 656 | wiphy->max_scan_ie_len = 200 ; //TODO: define a macro |
| 657 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 658 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 659 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 660 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 661 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 662 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 663 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 664 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 665 | | BIT(NL80211_IFTYPE_AP); |
| 666 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 667 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 668 | if( pCfg->enableMCC ) |
| 669 | { |
| 670 | /* Currently, supports up to two channels */ |
| 671 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 672 | |
| 673 | if( !pCfg->allowMCCGODiffBI ) |
| 674 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 675 | |
| 676 | } |
| 677 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 678 | wiphy->n_iface_combinations = 1; |
| 679 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 680 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 681 | /* Before registering we need to update the ht capabilitied based |
| 682 | * on ini values*/ |
| 683 | if( !pCfg->ShortGI20MhzEnable ) |
| 684 | { |
| 685 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 686 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 687 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 688 | } |
| 689 | |
| 690 | if( !pCfg->ShortGI40MhzEnable ) |
| 691 | { |
| 692 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 693 | } |
| 694 | |
| 695 | if( !pCfg->nChannelBondingMode5GHz ) |
| 696 | { |
| 697 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 698 | } |
| 699 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 700 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 701 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 702 | |
| 703 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 704 | { |
| 705 | |
| 706 | if (NULL == wiphy->bands[i]) |
| 707 | { |
| 708 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 709 | __func__, i); |
| 710 | continue; |
| 711 | } |
| 712 | |
| 713 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 714 | { |
| 715 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 716 | |
| 717 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 718 | { |
| 719 | // Enable social channels for P2P |
| 720 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 721 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 722 | else |
| 723 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 724 | continue; |
| 725 | } |
| 726 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 727 | { |
| 728 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 729 | continue; |
| 730 | } |
| 731 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 732 | } |
| 733 | /*Initialise the supported cipher suite details*/ |
| 734 | wiphy->cipher_suites = hdd_cipher_suites; |
| 735 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 736 | |
| 737 | /*signal strength in mBm (100*dBm) */ |
| 738 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 739 | |
| 740 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 741 | wiphy->max_remain_on_channel_duration = 1000; |
| 742 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 743 | |
| 744 | /* Register our wiphy dev with cfg80211 */ |
| 745 | if (0 > wiphy_register(wiphy)) |
| 746 | { |
| 747 | /* print eror */ |
| 748 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 749 | return -EIO; |
| 750 | } |
| 751 | |
| 752 | EXIT(); |
| 753 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 754 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 755 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 756 | /* In this function we will try to get default country code from crda. |
| 757 | If the gCrdaDefaultCountryCode is configured in ini file, |
| 758 | we will try to call user space crda to get the regulatory settings for |
| 759 | that country. We will timeout if we can't get it from crda. |
| 760 | It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_register. |
| 761 | */ |
| 762 | int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg) |
| 763 | { |
| 764 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 765 | if (memcmp(pCfg->crdaDefaultCountryCode, |
| 766 | CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0) |
| 767 | { |
| 768 | init_completion(&pHddCtx->driver_crda_req); |
| 769 | regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode); |
| 770 | wait_for_completion_interruptible_timeout(&pHddCtx->driver_crda_req, |
| 771 | CRDA_WAIT_TIME); |
Yunsen Wang | e3ba1fb | 2013-04-05 15:04:43 -0700 | [diff] [blame] | 772 | /* if the country is not found from current regulatory.bin, |
| 773 | fall back to world domain */ |
| 774 | if (is_crda_regulatory_entry_valid() == VOS_FALSE) |
| 775 | crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 776 | } |
| 777 | return 0; |
| 778 | } |
| 779 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 780 | /* In this function we will do all post VOS start initialization. |
| 781 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 782 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 783 | */ |
| 784 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 785 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 786 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 787 | /* Register for all P2P action, public action etc frames */ |
| 788 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 789 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 790 | ENTER(); |
| 791 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 792 | /* Right now we are registering these frame when driver is getting |
| 793 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 794 | frame register ops, we will move this code as a part of that */ |
| 795 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 796 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 797 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 798 | |
| 799 | /* GAS Initial Response */ |
| 800 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 801 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 802 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 803 | /* GAS Comeback Request */ |
| 804 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 805 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 806 | |
| 807 | /* GAS Comeback Response */ |
| 808 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 809 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 810 | |
| 811 | /* P2P Public Action */ |
| 812 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 813 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 814 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 815 | |
| 816 | /* P2P Action */ |
| 817 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 818 | (v_U8_t*)P2P_ACTION_FRAME, |
| 819 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 820 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 821 | /* WNM BSS Transition Request frame */ |
| 822 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 823 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 824 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 825 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 826 | #ifdef WLAN_FEATURE_11W |
| 827 | /* SA Query Response Action Frame */ |
| 828 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 829 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 830 | SA_QUERY_FRAME_RSP_SIZE ); |
| 831 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 835 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 836 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 837 | /* Register for all P2P action, public action etc frames */ |
| 838 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 839 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 840 | ENTER(); |
| 841 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 842 | /* Right now we are registering these frame when driver is getting |
| 843 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 844 | frame register ops, we will move this code as a part of that */ |
| 845 | /* GAS Initial Request */ |
| 846 | |
| 847 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 848 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 849 | |
| 850 | /* GAS Initial Response */ |
| 851 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 852 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 853 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 854 | /* GAS Comeback Request */ |
| 855 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 856 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 857 | |
| 858 | /* GAS Comeback Response */ |
| 859 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 860 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 861 | |
| 862 | /* P2P Public Action */ |
| 863 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 864 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 865 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 866 | |
| 867 | /* P2P Action */ |
| 868 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 869 | (v_U8_t*)P2P_ACTION_FRAME, |
| 870 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 871 | |
| 872 | #ifdef WLAN_FEATURE_11W |
| 873 | /* SA Query Response Action Frame */ |
| 874 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 875 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 876 | SA_QUERY_FRAME_RSP_SIZE ); |
| 877 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | #ifdef FEATURE_WLAN_WAPI |
| 881 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 882 | const u8 *mac_addr, u8 *key , int key_Len) |
| 883 | { |
| 884 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 885 | tCsrRoamSetKey setKey; |
| 886 | v_BOOL_t isConnected = TRUE; |
| 887 | int status = 0; |
| 888 | v_U32_t roamId= 0xFF; |
| 889 | tANI_U8 *pKeyPtr = NULL; |
| 890 | int n = 0; |
| 891 | |
| 892 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 893 | __func__,pAdapter->device_mode); |
| 894 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 895 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 896 | setKey.keyId = key_index; // Store Key ID |
| 897 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 898 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 899 | setKey.paeRole = 0 ; // the PAE role |
| 900 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 901 | { |
| 902 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 903 | } |
| 904 | else |
| 905 | { |
| 906 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 907 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 908 | } |
| 909 | setKey.keyLength = key_Len; |
| 910 | pKeyPtr = setKey.Key; |
| 911 | memcpy( pKeyPtr, key, key_Len); |
| 912 | |
| 913 | hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x", |
| 914 | __func__, key_Len); |
| 915 | for (n = 0 ; n < key_Len; n++) |
| 916 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 917 | __func__,n,setKey.Key[n]); |
| 918 | |
| 919 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 920 | if ( isConnected ) |
| 921 | { |
| 922 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 923 | pAdapter->sessionId, &setKey, &roamId ); |
| 924 | } |
| 925 | if ( status != 0 ) |
| 926 | { |
| 927 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 928 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 929 | __LINE__, status ); |
| 930 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 931 | } |
| 932 | } |
| 933 | #endif /* FEATURE_WLAN_WAPI*/ |
| 934 | |
| 935 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 936 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 937 | beacon_data_t **ppBeacon, |
| 938 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 939 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 940 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 941 | beacon_data_t **ppBeacon, |
| 942 | struct cfg80211_beacon_data *params, |
| 943 | int dtim_period) |
| 944 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 945 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 946 | int size; |
| 947 | beacon_data_t *beacon = NULL; |
| 948 | beacon_data_t *old = NULL; |
| 949 | int head_len,tail_len; |
| 950 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 951 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 952 | if (params->head && !params->head_len) |
| 953 | return -EINVAL; |
| 954 | |
| 955 | old = pAdapter->sessionCtx.ap.beacon; |
| 956 | |
| 957 | if (!params->head && !old) |
| 958 | return -EINVAL; |
| 959 | |
| 960 | if (params->tail && !params->tail_len) |
| 961 | return -EINVAL; |
| 962 | |
| 963 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 964 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 965 | if (!params->dtim_period) |
| 966 | return -EINVAL; |
| 967 | #endif |
| 968 | |
| 969 | if(params->head) |
| 970 | head_len = params->head_len; |
| 971 | else |
| 972 | head_len = old->head_len; |
| 973 | |
| 974 | if(params->tail || !old) |
| 975 | tail_len = params->tail_len; |
| 976 | else |
| 977 | tail_len = old->tail_len; |
| 978 | |
| 979 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 980 | |
| 981 | beacon = kzalloc(size, GFP_KERNEL); |
| 982 | |
| 983 | if( beacon == NULL ) |
| 984 | return -ENOMEM; |
| 985 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 986 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 987 | if(params->dtim_period || !old ) |
| 988 | beacon->dtim_period = params->dtim_period; |
| 989 | else |
| 990 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 991 | #else |
| 992 | if(dtim_period || !old ) |
| 993 | beacon->dtim_period = dtim_period; |
| 994 | else |
| 995 | beacon->dtim_period = old->dtim_period; |
| 996 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 997 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 998 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 999 | beacon->tail = beacon->head + head_len; |
| 1000 | beacon->head_len = head_len; |
| 1001 | beacon->tail_len = tail_len; |
| 1002 | |
| 1003 | if(params->head) { |
| 1004 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1005 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1006 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1007 | if(old) |
| 1008 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1009 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1010 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1011 | if(params->tail) { |
| 1012 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1013 | } |
| 1014 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1015 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1016 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1017 | } |
| 1018 | |
| 1019 | *ppBeacon = beacon; |
| 1020 | |
| 1021 | kfree(old); |
| 1022 | |
| 1023 | return 0; |
| 1024 | |
| 1025 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1026 | |
| 1027 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1028 | { |
| 1029 | int left = length; |
| 1030 | v_U8_t *ptr = pIes; |
| 1031 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1032 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1033 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1034 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1035 | elem_id = ptr[0]; |
| 1036 | elem_len = ptr[1]; |
| 1037 | left -= 2; |
| 1038 | if(elem_len > left) |
| 1039 | { |
| 1040 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1041 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1042 | eid,elem_len,left); |
| 1043 | return NULL; |
| 1044 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1045 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1046 | { |
| 1047 | return ptr; |
| 1048 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1049 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1050 | left -= elem_len; |
| 1051 | ptr += (elem_len + 2); |
| 1052 | } |
| 1053 | return NULL; |
| 1054 | } |
| 1055 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1056 | /* Check if rate is 11g rate or not */ |
| 1057 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1058 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 1059 | 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] | 1060 | u8 i; |
| 1061 | for (i = 0; i < 8; i++) |
| 1062 | { |
| 1063 | if(rate == gRateArray[i]) |
| 1064 | return TRUE; |
| 1065 | } |
| 1066 | return FALSE; |
| 1067 | } |
| 1068 | |
| 1069 | /* Check for 11g rate and set proper 11g only mode */ |
| 1070 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1071 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1072 | { |
| 1073 | u8 i, num_rates = pIe[0]; |
| 1074 | |
| 1075 | pIe += 1; |
| 1076 | for ( i = 0; i < num_rates; i++) |
| 1077 | { |
| 1078 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1079 | { |
| 1080 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1081 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1082 | if (pIe[i] & BASIC_RATE_MASK) |
| 1083 | { |
| 1084 | /* If we have 11g rate as basic rate, it means mode |
| 1085 | is 11g only mode. |
| 1086 | */ |
| 1087 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1088 | *pCheckRatesfor11g = FALSE; |
| 1089 | } |
| 1090 | } |
| 1091 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1092 | { |
| 1093 | *require_ht = TRUE; |
| 1094 | } |
| 1095 | } |
| 1096 | return; |
| 1097 | } |
| 1098 | |
| 1099 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1100 | { |
| 1101 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1102 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1103 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1104 | u8 checkRatesfor11g = TRUE; |
| 1105 | u8 require_ht = FALSE; |
| 1106 | u8 *pIe=NULL; |
| 1107 | |
| 1108 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1109 | |
| 1110 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1111 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1112 | if (pIe != NULL) |
| 1113 | { |
| 1114 | pIe += 1; |
| 1115 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1116 | &pConfig->SapHw_mode); |
| 1117 | } |
| 1118 | |
| 1119 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1120 | WLAN_EID_EXT_SUPP_RATES); |
| 1121 | if (pIe != NULL) |
| 1122 | { |
| 1123 | |
| 1124 | pIe += 1; |
| 1125 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1126 | &pConfig->SapHw_mode); |
| 1127 | } |
| 1128 | |
| 1129 | if( pConfig->channel > 14 ) |
| 1130 | { |
| 1131 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1132 | } |
| 1133 | |
| 1134 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1135 | WLAN_EID_HT_CAPABILITY); |
| 1136 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1137 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1138 | { |
| 1139 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1140 | if(require_ht) |
| 1141 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1142 | } |
| 1143 | } |
| 1144 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1145 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1146 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1147 | { |
| 1148 | v_U8_t ielen = 0; |
| 1149 | v_U8_t *pIe = NULL; |
| 1150 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1151 | |
| 1152 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1153 | pBeacon->tail, pBeacon->tail_len); |
| 1154 | |
| 1155 | if (pIe) |
| 1156 | { |
| 1157 | ielen = pIe[1] + 2; |
| 1158 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1159 | { |
| 1160 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1161 | } |
| 1162 | else |
| 1163 | { |
| 1164 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1165 | return -EINVAL; |
| 1166 | } |
| 1167 | *total_ielen += ielen; |
| 1168 | } |
| 1169 | return 0; |
| 1170 | } |
| 1171 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1172 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1173 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1174 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1175 | #else |
| 1176 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1177 | struct cfg80211_beacon_data *params) |
| 1178 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1179 | { |
| 1180 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1181 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1182 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1183 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1184 | |
| 1185 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1186 | |
| 1187 | if(genie == NULL) { |
| 1188 | |
| 1189 | return -ENOMEM; |
| 1190 | } |
| 1191 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1192 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1193 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1194 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1195 | ret = -EINVAL; |
| 1196 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1200 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1201 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1202 | { |
| 1203 | ret = -EINVAL; |
| 1204 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1205 | } |
| 1206 | #endif |
| 1207 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1208 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1209 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1210 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1211 | ret = -EINVAL; |
| 1212 | goto done; |
| 1213 | } |
| 1214 | |
| 1215 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1216 | { |
| 1217 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1218 | &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1219 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1220 | ret = -EINVAL; |
| 1221 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1222 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1223 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1224 | |
| 1225 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1226 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1227 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1228 | { |
| 1229 | hddLog(LOGE, |
| 1230 | "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] | 1231 | ret = -EINVAL; |
| 1232 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1236 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1237 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1238 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1239 | ==eHAL_STATUS_FAILURE) |
| 1240 | { |
| 1241 | hddLog(LOGE, |
| 1242 | "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] | 1243 | ret = -EINVAL; |
| 1244 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | // Added for ProResp IE |
| 1248 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1249 | { |
| 1250 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1251 | u8 probe_rsp_ie_len[3] = {0}; |
| 1252 | u8 counter = 0; |
| 1253 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1254 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1255 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1256 | Store More then 255 bytes into One Variable. |
| 1257 | */ |
| 1258 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1259 | { |
| 1260 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1261 | { |
| 1262 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1263 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1264 | } |
| 1265 | else |
| 1266 | { |
| 1267 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1268 | rem_probe_resp_ie_len = 0; |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | rem_probe_resp_ie_len = 0; |
| 1273 | |
| 1274 | if (probe_rsp_ie_len[0] > 0) |
| 1275 | { |
| 1276 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1277 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1278 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1279 | probe_rsp_ie_len[0], NULL, |
| 1280 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1281 | { |
| 1282 | hddLog(LOGE, |
| 1283 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1284 | ret = -EINVAL; |
| 1285 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1286 | } |
| 1287 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1288 | } |
| 1289 | |
| 1290 | if (probe_rsp_ie_len[1] > 0) |
| 1291 | { |
| 1292 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1293 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1294 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1295 | probe_rsp_ie_len[1], NULL, |
| 1296 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1297 | { |
| 1298 | hddLog(LOGE, |
| 1299 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1300 | ret = -EINVAL; |
| 1301 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1302 | } |
| 1303 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1304 | } |
| 1305 | |
| 1306 | if (probe_rsp_ie_len[2] > 0) |
| 1307 | { |
| 1308 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1309 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1310 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1311 | probe_rsp_ie_len[2], NULL, |
| 1312 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1313 | { |
| 1314 | hddLog(LOGE, |
| 1315 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1316 | ret = -EINVAL; |
| 1317 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1318 | } |
| 1319 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1320 | } |
| 1321 | |
| 1322 | if (probe_rsp_ie_len[1] == 0 ) |
| 1323 | { |
| 1324 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1325 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1326 | eANI_BOOLEAN_FALSE) ) |
| 1327 | { |
| 1328 | hddLog(LOGE, |
| 1329 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n"); |
| 1330 | } |
| 1331 | } |
| 1332 | |
| 1333 | if (probe_rsp_ie_len[2] == 0 ) |
| 1334 | { |
| 1335 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1336 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1337 | eANI_BOOLEAN_FALSE) ) |
| 1338 | { |
| 1339 | hddLog(LOGE, |
| 1340 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n"); |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1345 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1346 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1347 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1348 | == eHAL_STATUS_FAILURE) |
| 1349 | { |
| 1350 | hddLog(LOGE, |
| 1351 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG 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 | else |
| 1357 | { |
| 1358 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1359 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1360 | |
| 1361 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1362 | "%s: No Probe Response IE received in set beacon", |
| 1363 | __func__); |
| 1364 | } |
| 1365 | |
| 1366 | // Added for AssocResp IE |
| 1367 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1368 | { |
| 1369 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1370 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1371 | params->assocresp_ies_len, NULL, |
| 1372 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1373 | { |
| 1374 | hddLog(LOGE, |
| 1375 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1376 | ret = -EINVAL; |
| 1377 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1378 | } |
| 1379 | |
| 1380 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1381 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1382 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1383 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1384 | == eHAL_STATUS_FAILURE) |
| 1385 | { |
| 1386 | hddLog(LOGE, |
| 1387 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1388 | ret = -EINVAL; |
| 1389 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1390 | } |
| 1391 | } |
| 1392 | else |
| 1393 | { |
| 1394 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1395 | "%s: No Assoc Response IE received in set beacon", |
| 1396 | __func__); |
| 1397 | |
| 1398 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1399 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1400 | eANI_BOOLEAN_FALSE) ) |
| 1401 | { |
| 1402 | hddLog(LOGE, |
| 1403 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 1404 | } |
| 1405 | } |
| 1406 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1407 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1408 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1409 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1410 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1411 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1412 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1413 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1414 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1415 | * wlan_hdd_cfg80211_set_channel() |
| 1416 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1417 | * channel list. |
| 1418 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 1419 | 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] | 1420 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1422 | v_U32_t num_ch = 0; |
| 1423 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1424 | u32 indx = 0; |
| 1425 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1426 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1427 | 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] | 1428 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1429 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1430 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1431 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1432 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1433 | /* Validate the channel */ |
| 1434 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1435 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1436 | if ( channel == rfChannels[count].channelNum ) |
| 1437 | { |
| 1438 | fValidChannel = TRUE; |
| 1439 | break; |
| 1440 | } |
| 1441 | } |
| 1442 | if (fValidChannel != TRUE) |
| 1443 | { |
| 1444 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1445 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1446 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1447 | } |
| 1448 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1449 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1450 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1451 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1452 | valid_ch, &num_ch)) |
| 1453 | { |
| 1454 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1455 | "%s: failed to get valid channel list", __func__); |
| 1456 | return VOS_STATUS_E_FAILURE; |
| 1457 | } |
| 1458 | for (indx = 0; indx < num_ch; indx++) |
| 1459 | { |
| 1460 | if (channel == valid_ch[indx]) |
| 1461 | { |
| 1462 | break; |
| 1463 | } |
| 1464 | } |
| 1465 | |
| 1466 | if (indx >= num_ch) |
| 1467 | { |
| 1468 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1469 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1470 | return VOS_STATUS_E_FAILURE; |
| 1471 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1472 | } |
| 1473 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1474 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1475 | } |
| 1476 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1477 | /** |
| 1478 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1479 | * This function is used to set the channel number |
| 1480 | */ |
| 1481 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1482 | struct ieee80211_channel *chan, |
| 1483 | enum nl80211_channel_type channel_type |
| 1484 | ) |
| 1485 | { |
| 1486 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1487 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1488 | hdd_adapter_t *pAdapter = NULL; |
| 1489 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1490 | hdd_context_t *pHddCtx; |
| 1491 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1492 | |
| 1493 | ENTER(); |
| 1494 | |
| 1495 | if( NULL == dev ) |
| 1496 | { |
| 1497 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1498 | "%s: Called with dev = NULL.\n", __func__); |
| 1499 | return -ENODEV; |
| 1500 | } |
| 1501 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1502 | |
| 1503 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1504 | "%s: device_mode = %d freq = %d \n",__func__, |
| 1505 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1506 | |
| 1507 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1508 | status = wlan_hdd_validate_context(pHddCtx); |
| 1509 | |
| 1510 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1511 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1512 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1513 | "%s: HDD context is not valid", __func__); |
| 1514 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | /* |
| 1518 | * Do freq to chan conversion |
| 1519 | * TODO: for 11a |
| 1520 | */ |
| 1521 | |
| 1522 | channel = ieee80211_frequency_to_channel(freq); |
| 1523 | |
| 1524 | /* Check freq range */ |
| 1525 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1526 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1527 | { |
| 1528 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1529 | "%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1530 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1531 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1532 | return -EINVAL; |
| 1533 | } |
| 1534 | |
| 1535 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1536 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1537 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1538 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1539 | { |
| 1540 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1541 | { |
| 1542 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1543 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1544 | return -EINVAL; |
| 1545 | } |
| 1546 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1547 | "%s: set channel to [%d] for device mode =%d", |
| 1548 | __func__, channel,pAdapter->device_mode); |
| 1549 | } |
| 1550 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1551 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1552 | ) |
| 1553 | { |
| 1554 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1555 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1556 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1557 | |
| 1558 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1559 | { |
| 1560 | /* Link is up then return cant set channel*/ |
| 1561 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1562 | "%s: IBSS Associated, can't set the channel\n", __func__); |
| 1563 | return -EINVAL; |
| 1564 | } |
| 1565 | |
| 1566 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1567 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1568 | pRoamProfile->ChannelInfo.ChannelList = |
| 1569 | &pHddStaCtx->conn_info.operationChannel; |
| 1570 | } |
| 1571 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1572 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1573 | ) |
| 1574 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1575 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1576 | { |
| 1577 | if(VOS_STATUS_SUCCESS != |
| 1578 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1579 | { |
| 1580 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1581 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1582 | return -EINVAL; |
| 1583 | } |
| 1584 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1585 | } |
| 1586 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1587 | { |
| 1588 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1589 | |
| 1590 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1591 | channel set by supplicant |
| 1592 | */ |
| 1593 | if ( cfg_param->apAutoChannelSelection ) |
| 1594 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1595 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1596 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1597 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1598 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1599 | __func__, pAdapter->device_mode); |
| 1600 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1601 | else |
| 1602 | { |
| 1603 | if(VOS_STATUS_SUCCESS != |
| 1604 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1605 | { |
| 1606 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1607 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1608 | return -EINVAL; |
| 1609 | } |
| 1610 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1611 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1612 | } |
| 1613 | } |
| 1614 | else |
| 1615 | { |
| 1616 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1617 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1618 | return -EINVAL; |
| 1619 | } |
| 1620 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1621 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1622 | } |
| 1623 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1624 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1625 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1626 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1627 | #else |
| 1628 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1629 | struct cfg80211_beacon_data *params, |
| 1630 | const u8 *ssid, size_t ssid_len, |
| 1631 | enum nl80211_hidden_ssid hidden_ssid) |
| 1632 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1633 | { |
| 1634 | tsap_Config_t *pConfig; |
| 1635 | beacon_data_t *pBeacon = NULL; |
| 1636 | struct ieee80211_mgmt *pMgmt_frame; |
| 1637 | v_U8_t *pIe=NULL; |
| 1638 | v_U16_t capab_info; |
| 1639 | eCsrAuthType RSNAuthType; |
| 1640 | eCsrEncryptionType RSNEncryptType; |
| 1641 | eCsrEncryptionType mcRSNEncryptType; |
| 1642 | int status = VOS_STATUS_SUCCESS; |
| 1643 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1644 | hdd_hostapd_state_t *pHostapdState; |
| 1645 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1646 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1647 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1648 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1649 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1650 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1651 | |
| 1652 | ENTER(); |
| 1653 | |
| 1654 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1655 | |
| 1656 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1657 | |
| 1658 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1659 | |
| 1660 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1661 | |
| 1662 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1663 | |
| 1664 | //channel is already set in the set_channel Call back |
| 1665 | //pConfig->channel = pCommitConfig->channel; |
| 1666 | |
| 1667 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1668 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1669 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1670 | |
| 1671 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1672 | |
| 1673 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1674 | pConfig->dtim_period); |
| 1675 | |
| 1676 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1677 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1678 | { |
| 1679 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1680 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1681 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1682 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1683 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1684 | pConfig->ieee80211d = 1; |
| 1685 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1686 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1687 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1688 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1689 | else |
| 1690 | { |
| 1691 | pConfig->ieee80211d = 0; |
| 1692 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1693 | /* |
| 1694 | * If auto channel is configured i.e. channel is 0, |
| 1695 | * so skip channel validation. |
| 1696 | */ |
| 1697 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1698 | { |
| 1699 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1700 | { |
| 1701 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1702 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1703 | return -EINVAL; |
| 1704 | } |
| 1705 | } |
| 1706 | else |
| 1707 | { |
| 1708 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1709 | { |
| 1710 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1711 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1712 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1713 | } |
| 1714 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1715 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1716 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1717 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1718 | { |
| 1719 | pConfig->ieee80211d = 0; |
| 1720 | } |
| 1721 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1722 | |
| 1723 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1724 | |
| 1725 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1726 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1727 | |
| 1728 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1729 | |
| 1730 | /*Set wps station to configured*/ |
| 1731 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1732 | |
| 1733 | if(pIe) |
| 1734 | { |
| 1735 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1736 | { |
| 1737 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1738 | return -EINVAL; |
| 1739 | } |
| 1740 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1741 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1742 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1743 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1744 | * WPS state |
| 1745 | */ |
| 1746 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1747 | { |
| 1748 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1749 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1750 | { |
| 1751 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1752 | } |
| 1753 | } |
| 1754 | } |
| 1755 | else |
| 1756 | { |
| 1757 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1758 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1759 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1760 | |
| 1761 | pConfig->RSNWPAReqIELength = 0; |
| 1762 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1763 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1764 | WLAN_EID_RSN); |
| 1765 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1766 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1767 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1768 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1769 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1770 | /* The actual processing may eventually be more extensive than |
| 1771 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1772 | * by the app. |
| 1773 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1774 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1775 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1776 | &RSNEncryptType, |
| 1777 | &mcRSNEncryptType, |
| 1778 | &RSNAuthType, |
| 1779 | pConfig->pRSNWPAReqIE[1]+2, |
| 1780 | pConfig->pRSNWPAReqIE ); |
| 1781 | |
| 1782 | if( VOS_STATUS_SUCCESS == status ) |
| 1783 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1784 | /* Now copy over all the security attributes you have |
| 1785 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1786 | * */ |
| 1787 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1788 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1789 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1790 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1791 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1792 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1793 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1794 | } |
| 1795 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1796 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1797 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1798 | pBeacon->tail, pBeacon->tail_len); |
| 1799 | |
| 1800 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1801 | { |
| 1802 | if (pConfig->pRSNWPAReqIE) |
| 1803 | { |
| 1804 | /*Mixed mode WPA/WPA2*/ |
| 1805 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1806 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1807 | } |
| 1808 | else |
| 1809 | { |
| 1810 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1811 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1812 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1813 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1814 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1815 | &RSNEncryptType, |
| 1816 | &mcRSNEncryptType, |
| 1817 | &RSNAuthType, |
| 1818 | pConfig->pRSNWPAReqIE[1]+2, |
| 1819 | pConfig->pRSNWPAReqIE ); |
| 1820 | |
| 1821 | if( VOS_STATUS_SUCCESS == status ) |
| 1822 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1823 | /* Now copy over all the security attributes you have |
| 1824 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1825 | * */ |
| 1826 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1827 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1828 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1829 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1830 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1831 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1832 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1833 | } |
| 1834 | } |
| 1835 | } |
| 1836 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1837 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1838 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1839 | return -EINVAL; |
| 1840 | } |
| 1841 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1842 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1843 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1844 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1845 | if (params->ssid != NULL) |
| 1846 | { |
| 1847 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1848 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1849 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1850 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1851 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1852 | #else |
| 1853 | if (ssid != NULL) |
| 1854 | { |
| 1855 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1856 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1857 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1858 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1859 | } |
| 1860 | #endif |
| 1861 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1862 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1863 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1864 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1865 | /* default value */ |
| 1866 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1867 | pConfig->num_accept_mac = 0; |
| 1868 | pConfig->num_deny_mac = 0; |
| 1869 | |
| 1870 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1871 | pBeacon->tail, pBeacon->tail_len); |
| 1872 | |
| 1873 | /* pIe for black list is following form: |
| 1874 | type : 1 byte |
| 1875 | length : 1 byte |
| 1876 | OUI : 4 bytes |
| 1877 | acl type : 1 byte |
| 1878 | no of mac addr in black list: 1 byte |
| 1879 | 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] | 1880 | */ |
| 1881 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1882 | { |
| 1883 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1884 | pConfig->num_deny_mac = pIe[7]; |
| 1885 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1886 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1887 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 1888 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1889 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1890 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1891 | { |
| 1892 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1893 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1894 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1895 | } |
| 1896 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1897 | pBeacon->tail, pBeacon->tail_len); |
| 1898 | |
| 1899 | /* pIe for white list is following form: |
| 1900 | type : 1 byte |
| 1901 | length : 1 byte |
| 1902 | OUI : 4 bytes |
| 1903 | acl type : 1 byte |
| 1904 | no of mac addr in white list: 1 byte |
| 1905 | 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] | 1906 | */ |
| 1907 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1908 | { |
| 1909 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1910 | pConfig->num_accept_mac = pIe[7]; |
| 1911 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 1912 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1913 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 1914 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1915 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1916 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 1917 | { |
| 1918 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1919 | acl_entry++; |
| 1920 | } |
| 1921 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1922 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1923 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 1924 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1925 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 1926 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 1927 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 1928 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 1929 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 1930 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1931 | (((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] | 1932 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 1933 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1934 | { |
| 1935 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 1936 | |
| 1937 | /* Disable VHT support in 2.4 GHz band */ |
| 1938 | if (pConfig->channel <= 14 && |
| 1939 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE) |
| 1940 | { |
| 1941 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 1942 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1943 | } |
| 1944 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1945 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 1946 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1947 | { |
| 1948 | sme_SelectCBMode(hHal, |
| 1949 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 1950 | pConfig->channel); |
| 1951 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1952 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 1953 | pConfig->ht_capab = |
| 1954 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 1955 | |
| 1956 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 1957 | { |
| 1958 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 1959 | return -EINVAL; |
| 1960 | } |
| 1961 | |
| 1962 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1963 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1964 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 1965 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1966 | pConfig->obssProtEnabled = |
| 1967 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1968 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1969 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1970 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1971 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1972 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 1973 | (int)pConfig->channel); |
| 1974 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1975 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 1976 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1977 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1978 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1979 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 1980 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 1981 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1982 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1983 | { |
| 1984 | //Bss already started. just return. |
| 1985 | //TODO Probably it should update some beacon params. |
| 1986 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 1987 | EXIT(); |
| 1988 | return 0; |
| 1989 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1990 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1991 | pConfig->persona = pHostapdAdapter->device_mode; |
| 1992 | |
| 1993 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 1994 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 1995 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 1996 | { |
| 1997 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 1998 | return -EINVAL; |
| 1999 | } |
| 2000 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2001 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2002 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2003 | |
| 2004 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2005 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2006 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2007 | { |
| 2008 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2009 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2010 | VOS_ASSERT(0); |
| 2011 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2012 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2013 | //Succesfully started Bss update the state bit. |
| 2014 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2015 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2016 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2017 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2018 | { |
| 2019 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2020 | { |
| 2021 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2022 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2023 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2024 | } |
| 2025 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2026 | { |
| 2027 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2028 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2029 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2030 | } |
| 2031 | } |
| 2032 | #endif |
| 2033 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2034 | pHostapdState->bCommit = TRUE; |
| 2035 | EXIT(); |
| 2036 | |
| 2037 | return 0; |
| 2038 | } |
| 2039 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2040 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2041 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2042 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2043 | struct beacon_parameters *params) |
| 2044 | { |
| 2045 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2046 | hdd_context_t *pHddCtx; |
| 2047 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2048 | |
| 2049 | ENTER(); |
| 2050 | |
| 2051 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 2052 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2053 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2054 | status = wlan_hdd_validate_context(pHddCtx); |
| 2055 | |
| 2056 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2057 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2059 | "%s: HDD context is not valid", __func__); |
| 2060 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2061 | } |
| 2062 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2063 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2064 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2065 | ) |
| 2066 | { |
| 2067 | beacon_data_t *old,*new; |
| 2068 | |
| 2069 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2070 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2071 | if (old) |
| 2072 | return -EALREADY; |
| 2073 | |
| 2074 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2075 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2076 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2077 | { |
| 2078 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2079 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 2080 | return -EINVAL; |
| 2081 | } |
| 2082 | |
| 2083 | pAdapter->sessionCtx.ap.beacon = new; |
| 2084 | |
| 2085 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2086 | } |
| 2087 | |
| 2088 | EXIT(); |
| 2089 | return status; |
| 2090 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2091 | |
| 2092 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2093 | struct net_device *dev, |
| 2094 | struct beacon_parameters *params) |
| 2095 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2096 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2097 | hdd_context_t *pHddCtx; |
| 2098 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2099 | |
| 2100 | ENTER(); |
| 2101 | |
| 2102 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2103 | __func__,pAdapter->device_mode); |
| 2104 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2105 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2106 | status = wlan_hdd_validate_context(pHddCtx); |
| 2107 | |
| 2108 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2109 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2110 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2111 | "%s: HDD context is not valid", __func__); |
| 2112 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2113 | } |
| 2114 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2115 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2116 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2117 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2118 | { |
| 2119 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2121 | old = pAdapter->sessionCtx.ap.beacon; |
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 | if (!old) |
| 2124 | return -ENOENT; |
| 2125 | |
| 2126 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2127 | |
| 2128 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2129 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2130 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2131 | return -EINVAL; |
| 2132 | } |
| 2133 | |
| 2134 | pAdapter->sessionCtx.ap.beacon = new; |
| 2135 | |
| 2136 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2137 | } |
| 2138 | |
| 2139 | EXIT(); |
| 2140 | return status; |
| 2141 | } |
| 2142 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2143 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2144 | |
| 2145 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2146 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2147 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2148 | #else |
| 2149 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2150 | struct net_device *dev) |
| 2151 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2152 | { |
| 2153 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2154 | hdd_context_t *pHddCtx = NULL; |
| 2155 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2156 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2157 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2158 | |
| 2159 | ENTER(); |
| 2160 | |
| 2161 | if (NULL == pAdapter) |
| 2162 | { |
| 2163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2164 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2165 | return -ENODEV; |
| 2166 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2167 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2168 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2169 | status = wlan_hdd_validate_context(pHddCtx); |
| 2170 | |
| 2171 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2172 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2173 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2174 | "%s: HDD context is not valid", __func__); |
| 2175 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2176 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2177 | |
| 2178 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2179 | if (NULL == staAdapter) |
| 2180 | { |
| 2181 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2182 | if (NULL == staAdapter) |
| 2183 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2185 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2186 | return -ENODEV; |
| 2187 | } |
| 2188 | } |
| 2189 | |
| 2190 | pScanInfo = &pHddCtx->scan_info; |
| 2191 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2192 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2193 | __func__,pAdapter->device_mode); |
| 2194 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2195 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2196 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2197 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2198 | hdd_abort_mac_scan(staAdapter->pHddCtx); |
| 2199 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2200 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2201 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2202 | if (!status) |
| 2203 | { |
| 2204 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2205 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2206 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2207 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2208 | return 0; |
| 2209 | } |
| 2210 | } |
| 2211 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2212 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2213 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2214 | ) |
| 2215 | { |
| 2216 | beacon_data_t *old; |
| 2217 | |
| 2218 | old = pAdapter->sessionCtx.ap.beacon; |
| 2219 | |
| 2220 | if (!old) |
| 2221 | return -ENOENT; |
| 2222 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2223 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2224 | |
| 2225 | mutex_lock(&pHddCtx->sap_lock); |
| 2226 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2227 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2228 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2229 | { |
| 2230 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2231 | |
| 2232 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2233 | |
| 2234 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2235 | { |
| 2236 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2237 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2238 | VOS_ASSERT(0); |
| 2239 | } |
| 2240 | } |
| 2241 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2242 | } |
| 2243 | mutex_unlock(&pHddCtx->sap_lock); |
| 2244 | |
| 2245 | if(status != VOS_STATUS_SUCCESS) |
| 2246 | { |
| 2247 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2248 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2249 | return -EINVAL; |
| 2250 | } |
| 2251 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2252 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2253 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2254 | ==eHAL_STATUS_FAILURE) |
| 2255 | { |
| 2256 | hddLog(LOGE, |
| 2257 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2258 | } |
| 2259 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2260 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2261 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2262 | eANI_BOOLEAN_FALSE) ) |
| 2263 | { |
| 2264 | hddLog(LOGE, |
| 2265 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2266 | } |
| 2267 | |
| 2268 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2269 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2270 | |
| 2271 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2272 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2273 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2274 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2275 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2276 | { |
| 2277 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2278 | "GO got removed"); |
| 2279 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2280 | } |
| 2281 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2282 | } |
| 2283 | EXIT(); |
| 2284 | return status; |
| 2285 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2286 | |
| 2287 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2288 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2289 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2290 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2291 | struct cfg80211_ap_settings *params) |
| 2292 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2293 | hdd_adapter_t *pAdapter; |
| 2294 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2295 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2296 | |
| 2297 | ENTER(); |
| 2298 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2299 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2300 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2301 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2302 | "%s: Device is Null", __func__); |
| 2303 | return -ENODEV; |
| 2304 | } |
| 2305 | |
| 2306 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2307 | if (NULL == pAdapter) |
| 2308 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2310 | "%s: HDD adapter is Null", __func__); |
| 2311 | return -ENODEV; |
| 2312 | } |
| 2313 | |
| 2314 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2315 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2316 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2317 | "%s: HDD adapter magic is invalid", __func__); |
| 2318 | return -ENODEV; |
| 2319 | } |
| 2320 | |
| 2321 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2322 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2323 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2324 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2325 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2326 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2327 | "%s: HDD context is not valid", __func__); |
| 2328 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2329 | } |
| 2330 | |
| 2331 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2332 | __func__, pAdapter->device_mode); |
| 2333 | |
| 2334 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2335 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2336 | ) |
| 2337 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2338 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2339 | |
| 2340 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2341 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2342 | if (old) |
| 2343 | return -EALREADY; |
| 2344 | |
| 2345 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2346 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2347 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2348 | { |
| 2349 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2350 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2351 | return -EINVAL; |
| 2352 | } |
| 2353 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2354 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2355 | wlan_hdd_cfg80211_set_channel(wiphy, dev, params->channel, params->channel_type); |
| 2356 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2357 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2358 | params->ssid_len, params->hidden_ssid); |
| 2359 | } |
| 2360 | |
| 2361 | EXIT(); |
| 2362 | return status; |
| 2363 | } |
| 2364 | |
| 2365 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2366 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2367 | struct net_device *dev, |
| 2368 | struct cfg80211_beacon_data *params) |
| 2369 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2370 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2371 | hdd_context_t *pHddCtx; |
| 2372 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2373 | |
| 2374 | ENTER(); |
| 2375 | |
| 2376 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2377 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2378 | |
| 2379 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2380 | status = wlan_hdd_validate_context(pHddCtx); |
| 2381 | |
| 2382 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2383 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2384 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2385 | "%s: HDD context is not valid", __func__); |
| 2386 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2387 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2388 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2389 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2390 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2391 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2392 | { |
| 2393 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2394 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2395 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2396 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2397 | if (!old) |
| 2398 | return -ENOENT; |
| 2399 | |
| 2400 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2401 | |
| 2402 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2403 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2404 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2405 | return -EINVAL; |
| 2406 | } |
| 2407 | |
| 2408 | pAdapter->sessionCtx.ap.beacon = new; |
| 2409 | |
| 2410 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2411 | } |
| 2412 | |
| 2413 | EXIT(); |
| 2414 | return status; |
| 2415 | } |
| 2416 | |
| 2417 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2418 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2419 | |
| 2420 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2421 | struct net_device *dev, |
| 2422 | struct bss_parameters *params) |
| 2423 | { |
| 2424 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2425 | |
| 2426 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2427 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2428 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2429 | __func__,pAdapter->device_mode); |
| 2430 | |
| 2431 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2432 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2433 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2434 | { |
| 2435 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2436 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2437 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2438 | { |
| 2439 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2440 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2441 | } |
| 2442 | |
| 2443 | EXIT(); |
| 2444 | return 0; |
| 2445 | } |
| 2446 | |
| 2447 | /* |
| 2448 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2449 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2450 | */ |
| 2451 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2452 | struct net_device *ndev, |
| 2453 | enum nl80211_iftype type, |
| 2454 | u32 *flags, |
| 2455 | struct vif_params *params |
| 2456 | ) |
| 2457 | { |
| 2458 | struct wireless_dev *wdev; |
| 2459 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2460 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2461 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2462 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2463 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2464 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2465 | eMib_dot11DesiredBssType connectedBssType; |
| 2466 | VOS_STATUS status; |
| 2467 | |
| 2468 | ENTER(); |
| 2469 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2470 | status = wlan_hdd_validate_context(pHddCtx); |
| 2471 | |
| 2472 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2473 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2474 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2475 | "%s: HDD context is not valid", __func__); |
| 2476 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2477 | } |
| 2478 | |
| 2479 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2480 | __func__, pAdapter->device_mode); |
| 2481 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2482 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2483 | wdev = ndev->ieee80211_ptr; |
| 2484 | |
| 2485 | #ifdef WLAN_BTAMP_FEATURE |
| 2486 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2487 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2488 | (NL80211_IFTYPE_AP == type)|| |
| 2489 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2490 | { |
| 2491 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2492 | // stop AMP traffic |
| 2493 | status = WLANBAP_StopAmp(); |
| 2494 | if(VOS_STATUS_SUCCESS != status ) |
| 2495 | { |
| 2496 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2497 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2498 | "%s: Failed to stop AMP", __func__); |
| 2499 | return -EINVAL; |
| 2500 | } |
| 2501 | } |
| 2502 | #endif //WLAN_BTAMP_FEATURE |
| 2503 | /* Reset the current device mode bit mask*/ |
| 2504 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2505 | |
| 2506 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2507 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2508 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2509 | ) |
| 2510 | { |
| 2511 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2512 | pRoamProfile = &pWextState->roamProfile; |
| 2513 | LastBSSType = pRoamProfile->BSSType; |
| 2514 | |
| 2515 | switch (type) |
| 2516 | { |
| 2517 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2518 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2519 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2520 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2521 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2522 | #ifdef WLAN_FEATURE_11AC |
| 2523 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2524 | { |
| 2525 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2526 | } |
| 2527 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2528 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2529 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2530 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2531 | //Check for sub-string p2p to confirm its a p2p interface |
| 2532 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2533 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2534 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2535 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2536 | } |
| 2537 | else |
| 2538 | { |
| 2539 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2540 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2541 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2542 | break; |
| 2543 | case NL80211_IFTYPE_ADHOC: |
| 2544 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2545 | "%s: setting interface Type to ADHOC", __func__); |
| 2546 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2547 | pRoamProfile->phyMode = |
| 2548 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2549 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2550 | wdev->iftype = type; |
| 2551 | break; |
| 2552 | |
| 2553 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2554 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2555 | { |
| 2556 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2557 | "%s: setting interface Type to %s", __func__, |
| 2558 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2559 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2560 | //Cancel any remain on channel for GO mode |
| 2561 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2562 | { |
| 2563 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2564 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2565 | if (NL80211_IFTYPE_AP == type) |
| 2566 | { |
| 2567 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2568 | * address. This will take one HW STA and the max number of clients |
| 2569 | * that can connect to softAP will be reduced by one. so while changing |
| 2570 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2571 | * interface as it is not required in SoftAP mode. |
| 2572 | */ |
| 2573 | |
| 2574 | // Get P2P Adapter |
| 2575 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2576 | |
| 2577 | if (pP2pAdapter) |
| 2578 | { |
| 2579 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2580 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2581 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2582 | } |
| 2583 | } |
| 2584 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2585 | //De-init the adapter. |
| 2586 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2587 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2588 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2589 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2590 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2591 | |
| 2592 | //Disable BMPS and IMPS if enabled |
| 2593 | //before starting Go |
| 2594 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2595 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2596 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2597 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2598 | { |
| 2599 | //Fail to Exit BMPS |
| 2600 | VOS_ASSERT(0); |
| 2601 | } |
| 2602 | } |
| 2603 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2604 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2605 | (pConfig->apRandomBssidEnabled)) |
| 2606 | { |
| 2607 | /* To meet Android requirements create a randomized |
| 2608 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2609 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2610 | ndev->dev_addr[0] = 0x02; |
| 2611 | ndev->dev_addr[1] = 0x1A; |
| 2612 | ndev->dev_addr[2] = 0x11; |
| 2613 | ndev->dev_addr[3] |= 0xF0; |
| 2614 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2615 | VOS_MAC_ADDR_SIZE); |
| 2616 | pr_info("wlan: Generated HotSpot BSSID " |
| 2617 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2618 | ndev->dev_addr[0], |
| 2619 | ndev->dev_addr[1], |
| 2620 | ndev->dev_addr[2], |
| 2621 | ndev->dev_addr[3], |
| 2622 | ndev->dev_addr[4], |
| 2623 | ndev->dev_addr[5]); |
| 2624 | } |
| 2625 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2626 | hdd_set_ap_ops( pAdapter->dev ); |
| 2627 | |
| 2628 | status = hdd_init_ap_mode(pAdapter); |
| 2629 | if(status != VOS_STATUS_SUCCESS) |
| 2630 | { |
| 2631 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2632 | "%s: Error initializing the ap mode", __func__); |
| 2633 | return -EINVAL; |
| 2634 | } |
| 2635 | hdd_set_conparam(1); |
| 2636 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2637 | /*interface type changed update in wiphy structure*/ |
| 2638 | if(wdev) |
| 2639 | { |
| 2640 | wdev->iftype = type; |
| 2641 | pHddCtx->change_iface = type; |
| 2642 | } |
| 2643 | else |
| 2644 | { |
| 2645 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2646 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2647 | return -EINVAL; |
| 2648 | } |
| 2649 | goto done; |
| 2650 | } |
| 2651 | |
| 2652 | default: |
| 2653 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2654 | __func__); |
| 2655 | return -EOPNOTSUPP; |
| 2656 | } |
| 2657 | } |
| 2658 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2659 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2660 | ) |
| 2661 | { |
| 2662 | switch(type) |
| 2663 | { |
| 2664 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2665 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2666 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2667 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2668 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2669 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2670 | //Check for sub-string p2p to confirm its a p2p interface |
| 2671 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2672 | { |
| 2673 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2674 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2675 | } |
| 2676 | else |
| 2677 | { |
| 2678 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2679 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2680 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2681 | hdd_set_conparam(0); |
| 2682 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2683 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2684 | hdd_set_station_ops( pAdapter->dev ); |
| 2685 | status = hdd_init_station_mode( pAdapter ); |
| 2686 | if( VOS_STATUS_SUCCESS != status ) |
| 2687 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2688 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2689 | * This is the right place to enable back bmps_imps() |
| 2690 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 2691 | if (pHddCtx->hdd_wlan_suspended) |
| 2692 | { |
| 2693 | hdd_set_pwrparams(pHddCtx); |
| 2694 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2695 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2696 | goto done; |
| 2697 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2698 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2699 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2700 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2701 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2702 | goto done; |
| 2703 | default: |
| 2704 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2705 | __func__); |
| 2706 | return -EOPNOTSUPP; |
| 2707 | |
| 2708 | } |
| 2709 | |
| 2710 | } |
| 2711 | else |
| 2712 | { |
| 2713 | return -EOPNOTSUPP; |
| 2714 | } |
| 2715 | |
| 2716 | |
| 2717 | if(pRoamProfile) |
| 2718 | { |
| 2719 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2720 | { |
| 2721 | /*interface type changed update in wiphy structure*/ |
| 2722 | wdev->iftype = type; |
| 2723 | |
| 2724 | /*the BSS mode changed, We need to issue disconnect |
| 2725 | if connected or in IBSS disconnect state*/ |
| 2726 | if ( hdd_connGetConnectedBssType( |
| 2727 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2728 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2729 | { |
| 2730 | /*need to issue a disconnect to CSR.*/ |
| 2731 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2732 | if( eHAL_STATUS_SUCCESS == |
| 2733 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2734 | pAdapter->sessionId, |
| 2735 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2736 | { |
| 2737 | wait_for_completion_interruptible_timeout( |
| 2738 | &pAdapter->disconnect_comp_var, |
| 2739 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2740 | } |
| 2741 | } |
| 2742 | } |
| 2743 | } |
| 2744 | |
| 2745 | done: |
| 2746 | /*set bitmask based on updated value*/ |
| 2747 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 2748 | |
| 2749 | /* Only STA mode support TM now |
| 2750 | * all other mode, TM feature should be disabled */ |
| 2751 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 2752 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 2753 | { |
| 2754 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 2755 | } |
| 2756 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2757 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2758 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2759 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2760 | { |
| 2761 | //we are ok to do AMP |
| 2762 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2763 | } |
| 2764 | #endif //WLAN_BTAMP_FEATURE |
| 2765 | EXIT(); |
| 2766 | return 0; |
| 2767 | } |
| 2768 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2769 | #ifdef FEATURE_WLAN_TDLS |
| 2770 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2771 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2772 | { |
| 2773 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2774 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2775 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2776 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2777 | |
| 2778 | ENTER(); |
| 2779 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2780 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2781 | { |
| 2782 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2783 | "Invalid arguments"); |
| 2784 | return -EINVAL; |
| 2785 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2786 | |
| 2787 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2788 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2789 | { |
| 2790 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2791 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2792 | MAC_ADDRESS_STR " Request declined.", |
| 2793 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2794 | return -ENOTSUPP; |
| 2795 | } |
| 2796 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2797 | if (pHddCtx->isLogpInProgress) |
| 2798 | { |
| 2799 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2800 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2801 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2802 | return -EBUSY; |
| 2803 | } |
| 2804 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2805 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2806 | |
| 2807 | if ( NULL == pTdlsPeer ) { |
| 2808 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2809 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2810 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2811 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2812 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2813 | |
| 2814 | /* in add station, we accept existing valid staId if there is */ |
| 2815 | if ((0 == update) && |
| 2816 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2817 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2818 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2819 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2820 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2821 | " link_status %d. staId %d. add station ignored.", |
| 2822 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2823 | return 0; |
| 2824 | } |
| 2825 | /* in change station, we accept only when staId is valid */ |
| 2826 | if ((1 == update) && |
| 2827 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2828 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2829 | { |
| 2830 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2831 | "%s: " MAC_ADDRESS_STR |
| 2832 | " link status %d. staId %d. change station %s.", |
| 2833 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2834 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2835 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2836 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2837 | |
| 2838 | /* when others are on-going, we want to change link_status to idle */ |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2839 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2840 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2841 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2842 | "%s: " MAC_ADDRESS_STR |
| 2843 | " TDLS setup is ongoing. Request declined.", |
| 2844 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2845 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2846 | } |
| 2847 | |
| 2848 | /* first to check if we reached to maximum supported TDLS peer. |
| 2849 | TODO: for now, return -EPERM looks working fine, |
| 2850 | but need to check if any other errno fit into this category.*/ |
| 2851 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2852 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2853 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2854 | "%s: " MAC_ADDRESS_STR |
| 2855 | " TDLS Max peer already connected. Request declined.", |
| 2856 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2857 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2858 | } |
| 2859 | else |
| 2860 | { |
| 2861 | hddTdlsPeer_t *pTdlsPeer; |
| 2862 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2863 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2864 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2865 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2866 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2867 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2868 | return -EPERM; |
| 2869 | } |
| 2870 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2871 | if (0 == update) |
| 2872 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2873 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2874 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2875 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2876 | { |
| 2877 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2878 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2879 | if(StaParams->htcap_present) |
| 2880 | { |
| 2881 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2882 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 2883 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2884 | "ht_capa->extended_capabilities: %0x", |
| 2885 | StaParams->HTCap.extendedHtCapInfo); |
| 2886 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2887 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2888 | "params->capability: %0x",StaParams->capability); |
| 2889 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2890 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2891 | if(StaParams->vhtcap_present) |
| 2892 | { |
| 2893 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2894 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 2895 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 2896 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 2897 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2898 | { |
| 2899 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2900 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2901 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 2902 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2903 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 2904 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2905 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2906 | else if ((1 == update) && (NULL == StaParams)) |
| 2907 | { |
| 2908 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2909 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 2910 | return -EPERM; |
| 2911 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2912 | |
| 2913 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 2914 | |
| 2915 | if (!update) |
| 2916 | { |
| 2917 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2918 | pAdapter->sessionId, mac); |
| 2919 | } |
| 2920 | else |
| 2921 | { |
| 2922 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2923 | pAdapter->sessionId, mac, StaParams); |
| 2924 | } |
| 2925 | |
| 2926 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 2927 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 2928 | |
| 2929 | if (!status) |
| 2930 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2931 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2932 | "%s: timeout waiting for tdls add station indication", |
| 2933 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2934 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2935 | } |
| 2936 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 2937 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2938 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2939 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2940 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2941 | } |
| 2942 | |
| 2943 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2944 | |
| 2945 | error: |
| 2946 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 2947 | return -EPERM; |
| 2948 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2949 | } |
| 2950 | #endif |
| 2951 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2952 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 2953 | struct net_device *dev, |
| 2954 | u8 *mac, |
| 2955 | struct station_parameters *params) |
| 2956 | { |
| 2957 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2958 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2959 | hdd_context_t *pHddCtx; |
| 2960 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2961 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2962 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2963 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2964 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2965 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2966 | ENTER(); |
| 2967 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2968 | if ((NULL == pAdapter)) |
| 2969 | { |
| 2970 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2971 | "invalid adapter "); |
| 2972 | return -EINVAL; |
| 2973 | } |
| 2974 | |
| 2975 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2976 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2977 | |
| 2978 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 2979 | { |
| 2980 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2981 | "invalid HDD state or HDD station context"); |
| 2982 | return -EINVAL; |
| 2983 | } |
| 2984 | |
| 2985 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2986 | { |
| 2987 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2988 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2989 | return -EAGAIN; |
| 2990 | } |
| 2991 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2992 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 2993 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2994 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 2995 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2996 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2997 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2998 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2999 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3000 | WLANTL_STA_AUTHENTICATED); |
| 3001 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3002 | if (status != VOS_STATUS_SUCCESS) |
| 3003 | { |
| 3004 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3005 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3006 | return -EINVAL; |
| 3007 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3008 | } |
| 3009 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3010 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3011 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3012 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3013 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3014 | StaParams.capability = params->capability; |
| 3015 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3016 | StaParams.max_sp = params->max_sp; |
| 3017 | |
| 3018 | if (0 != params->ext_capab_len) |
| 3019 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3020 | sizeof(StaParams.extn_capability)); |
| 3021 | |
| 3022 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3023 | { |
| 3024 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3025 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3026 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3027 | |
| 3028 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3029 | |
| 3030 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3031 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3032 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3033 | * modified to send more rates. |
| 3034 | */ |
| 3035 | |
| 3036 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3037 | */ |
| 3038 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3039 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3040 | |
| 3041 | if (0 != StaParams.supported_rates_len) { |
| 3042 | int i = 0; |
| 3043 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3044 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3045 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3046 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3047 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3048 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3049 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3050 | } |
| 3051 | |
| 3052 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3053 | { |
| 3054 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3055 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3056 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3057 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3058 | if (0 != params->ext_capab_len ) { |
| 3059 | /*Define A Macro : TODO Sunil*/ |
| 3060 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3061 | isBufSta = 1; |
| 3062 | } |
| 3063 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3064 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues, |
| 3065 | params->max_sp, isBufSta); |
| 3066 | if (VOS_STATUS_SUCCESS != status) { |
| 3067 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3068 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3069 | return -EINVAL; |
| 3070 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3071 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3072 | |
| 3073 | if (VOS_STATUS_SUCCESS != status) { |
| 3074 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3075 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3076 | return -EINVAL; |
| 3077 | } |
| 3078 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3079 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3080 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3081 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3082 | return status; |
| 3083 | } |
| 3084 | |
| 3085 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3086 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3087 | * This function is used to initialize the key information |
| 3088 | */ |
| 3089 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3090 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3091 | struct net_device *ndev, |
| 3092 | u8 key_index, bool pairwise, |
| 3093 | const u8 *mac_addr, |
| 3094 | struct key_params *params |
| 3095 | ) |
| 3096 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3097 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3098 | struct net_device *ndev, |
| 3099 | u8 key_index, const u8 *mac_addr, |
| 3100 | struct key_params *params |
| 3101 | ) |
| 3102 | #endif |
| 3103 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3104 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3105 | tCsrRoamSetKey setKey; |
| 3106 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3107 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3108 | v_U32_t roamId= 0xFF; |
| 3109 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3110 | hdd_hostapd_state_t *pHostapdState; |
| 3111 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3112 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3113 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3114 | |
| 3115 | ENTER(); |
| 3116 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3117 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3118 | status = wlan_hdd_validate_context(pHddCtx); |
| 3119 | |
| 3120 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3121 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3122 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3123 | "%s: HDD context is not valid", __func__); |
| 3124 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3125 | } |
| 3126 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3127 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3128 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3129 | |
| 3130 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3131 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3132 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3133 | key_index); |
| 3134 | |
| 3135 | return -EINVAL; |
| 3136 | } |
| 3137 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3138 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3139 | { |
| 3140 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3141 | params->key_len); |
| 3142 | |
| 3143 | return -EINVAL; |
| 3144 | } |
| 3145 | |
| 3146 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3147 | "%s: called with key index = %d & key length %d", |
| 3148 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3149 | |
| 3150 | /*extract key idx, key len and key*/ |
| 3151 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3152 | setKey.keyId = key_index; |
| 3153 | setKey.keyLength = params->key_len; |
| 3154 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3155 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3156 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3157 | { |
| 3158 | case WLAN_CIPHER_SUITE_WEP40: |
| 3159 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3160 | break; |
| 3161 | |
| 3162 | case WLAN_CIPHER_SUITE_WEP104: |
| 3163 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3164 | break; |
| 3165 | |
| 3166 | case WLAN_CIPHER_SUITE_TKIP: |
| 3167 | { |
| 3168 | u8 *pKey = &setKey.Key[0]; |
| 3169 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3170 | |
| 3171 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3172 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3173 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3174 | |
| 3175 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3176 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3177 | |--------------|----------|----------| |
| 3178 | <---16bytes---><--8bytes--><--8bytes--> |
| 3179 | |
| 3180 | */ |
| 3181 | /*Sme expects the 32 bytes key to be in the below order |
| 3182 | |
| 3183 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3184 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3185 | |--------------|----------|----------| |
| 3186 | <---16bytes---><--8bytes--><--8bytes--> |
| 3187 | */ |
| 3188 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3189 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3190 | |
| 3191 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3192 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3193 | |
| 3194 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3195 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3196 | |
| 3197 | |
| 3198 | break; |
| 3199 | } |
| 3200 | |
| 3201 | case WLAN_CIPHER_SUITE_CCMP: |
| 3202 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3203 | break; |
| 3204 | |
| 3205 | #ifdef FEATURE_WLAN_WAPI |
| 3206 | case WLAN_CIPHER_SUITE_SMS4: |
| 3207 | { |
| 3208 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3209 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3210 | params->key, params->key_len); |
| 3211 | return 0; |
| 3212 | } |
| 3213 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3214 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3215 | #ifdef FEATURE_WLAN_CCX |
| 3216 | case WLAN_CIPHER_SUITE_KRK: |
| 3217 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3218 | break; |
| 3219 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3220 | |
| 3221 | #ifdef WLAN_FEATURE_11W |
| 3222 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3223 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3224 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3225 | #endif |
| 3226 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3227 | default: |
| 3228 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3229 | __func__, params->cipher); |
| 3230 | return -EOPNOTSUPP; |
| 3231 | } |
| 3232 | |
| 3233 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3234 | __func__, setKey.encType); |
| 3235 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3236 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3237 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3238 | (!pairwise) |
| 3239 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3240 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3241 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3242 | ) |
| 3243 | { |
| 3244 | /* set group key*/ |
| 3245 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3246 | "%s- %d: setting Broadcast key", |
| 3247 | __func__, __LINE__); |
| 3248 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3249 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3250 | } |
| 3251 | else |
| 3252 | { |
| 3253 | /* set pairwise key*/ |
| 3254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3255 | "%s- %d: setting pairwise key", |
| 3256 | __func__, __LINE__); |
| 3257 | setKey.keyDirection = eSIR_TX_RX; |
| 3258 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3259 | } |
| 3260 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3261 | { |
| 3262 | setKey.keyDirection = eSIR_TX_RX; |
| 3263 | /*Set the group key*/ |
| 3264 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3265 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3266 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3267 | if ( 0 != status ) |
| 3268 | { |
| 3269 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3270 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3271 | return -EINVAL; |
| 3272 | } |
| 3273 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3274 | the PTK after peer joins the IBSS network*/ |
| 3275 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3276 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3277 | return status; |
| 3278 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3279 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3280 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3281 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3282 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3283 | if( pHostapdState->bssState == BSS_START ) |
| 3284 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3285 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3286 | |
| 3287 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3288 | { |
| 3289 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3290 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3291 | __LINE__, status ); |
| 3292 | } |
| 3293 | } |
| 3294 | |
| 3295 | /* Saving WEP keys */ |
| 3296 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3297 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3298 | { |
| 3299 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3300 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3301 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3302 | } |
| 3303 | else |
| 3304 | { |
| 3305 | //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] | 3306 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3307 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3308 | } |
| 3309 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3310 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3311 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3312 | { |
| 3313 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3314 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3315 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3316 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3317 | if (!pairwise) |
| 3318 | #else |
| 3319 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3320 | #endif |
| 3321 | { |
| 3322 | /* set group key*/ |
| 3323 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3324 | { |
| 3325 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3326 | "%s- %d: Perform Set key Complete", |
| 3327 | __func__, __LINE__); |
| 3328 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3329 | } |
| 3330 | } |
| 3331 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3332 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3333 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3334 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3335 | |
| 3336 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3337 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3338 | params->key, params->key_len); |
| 3339 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3340 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3341 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3342 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3343 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3344 | "%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] | 3345 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3346 | setKey.peerMac[2], setKey.peerMac[3], |
| 3347 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3348 | setKey.keyDirection); |
| 3349 | |
| 3350 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3351 | |
| 3352 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3353 | { |
| 3354 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3355 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3356 | __LINE__, vos_status ); |
| 3357 | |
| 3358 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3359 | |
| 3360 | return -EINVAL; |
| 3361 | |
| 3362 | } |
| 3363 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3364 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3365 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3366 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3367 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3368 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3369 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3370 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3371 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3372 | "%s: Update PreAuth Key success", __func__); |
| 3373 | return 0; |
| 3374 | } |
| 3375 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3376 | { |
| 3377 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3378 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3379 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3380 | } |
| 3381 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3382 | |
| 3383 | /* issue set key request to SME*/ |
| 3384 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3385 | pAdapter->sessionId, &setKey, &roamId ); |
| 3386 | |
| 3387 | if ( 0 != status ) |
| 3388 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3389 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3390 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3391 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3392 | return -EINVAL; |
| 3393 | } |
| 3394 | |
| 3395 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3396 | /* in case of IBSS as there was no information available about WEP keys during |
| 3397 | * 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] | 3398 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3399 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3400 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3401 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3402 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3403 | ) |
| 3404 | && |
| 3405 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3406 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3407 | ) |
| 3408 | ) |
| 3409 | { |
| 3410 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3411 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3412 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3413 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3414 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3415 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3416 | setKey.peerMac[2], setKey.peerMac[3], |
| 3417 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3418 | setKey.keyDirection); |
| 3419 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3420 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3421 | pAdapter->sessionId, &setKey, &roamId ); |
| 3422 | |
| 3423 | if ( 0 != status ) |
| 3424 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3425 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3426 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3427 | __func__, status); |
| 3428 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3429 | return -EINVAL; |
| 3430 | } |
| 3431 | } |
| 3432 | } |
| 3433 | |
| 3434 | return 0; |
| 3435 | } |
| 3436 | |
| 3437 | /* |
| 3438 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3439 | * This function is used to get the key information |
| 3440 | */ |
| 3441 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3442 | static int wlan_hdd_cfg80211_get_key( |
| 3443 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3444 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3445 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3446 | const u8 *mac_addr, void *cookie, |
| 3447 | void (*callback)(void *cookie, struct key_params*) |
| 3448 | ) |
| 3449 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3450 | static int wlan_hdd_cfg80211_get_key( |
| 3451 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3452 | struct net_device *ndev, |
| 3453 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3454 | void (*callback)(void *cookie, struct key_params*) |
| 3455 | ) |
| 3456 | #endif |
| 3457 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3458 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3459 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3460 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3461 | struct key_params params; |
| 3462 | |
| 3463 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3464 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3465 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3466 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3467 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3468 | memset(¶ms, 0, sizeof(params)); |
| 3469 | |
| 3470 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3471 | { |
| 3472 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3473 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3474 | |
| 3475 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3476 | { |
| 3477 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3478 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3479 | break; |
| 3480 | |
| 3481 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3482 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3483 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3484 | break; |
| 3485 | |
| 3486 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3487 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3488 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3489 | break; |
| 3490 | |
| 3491 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3492 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3493 | break; |
| 3494 | |
| 3495 | case eCSR_ENCRYPT_TYPE_AES: |
| 3496 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3497 | break; |
| 3498 | |
| 3499 | default: |
| 3500 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3501 | break; |
| 3502 | } |
| 3503 | |
| 3504 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3505 | params.seq_len = 0; |
| 3506 | params.seq = NULL; |
| 3507 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3508 | callback(cookie, ¶ms); |
| 3509 | return 0; |
| 3510 | } |
| 3511 | |
| 3512 | /* |
| 3513 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3514 | * This function is used to delete the key information |
| 3515 | */ |
| 3516 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3517 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3518 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3519 | u8 key_index, |
| 3520 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3521 | const u8 *mac_addr |
| 3522 | ) |
| 3523 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3524 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3525 | struct net_device *ndev, |
| 3526 | u8 key_index, |
| 3527 | const u8 *mac_addr |
| 3528 | ) |
| 3529 | #endif |
| 3530 | { |
| 3531 | int status = 0; |
| 3532 | |
| 3533 | //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] | 3534 | //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] | 3535 | //it is observed that this is invalidating peer |
| 3536 | //key index whenever re-key is done. This is affecting data link. |
| 3537 | //It should be ok to ignore del_key. |
| 3538 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3539 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3540 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3541 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3542 | tCsrRoamSetKey setKey; |
| 3543 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3544 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3545 | ENTER(); |
| 3546 | |
| 3547 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3548 | __func__,pAdapter->device_mode); |
| 3549 | |
| 3550 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3551 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3552 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3553 | key_index); |
| 3554 | |
| 3555 | return -EINVAL; |
| 3556 | } |
| 3557 | |
| 3558 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3559 | setKey.keyId = key_index; |
| 3560 | |
| 3561 | if (mac_addr) |
| 3562 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3563 | else |
| 3564 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3565 | |
| 3566 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3567 | |
| 3568 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3569 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3570 | ) |
| 3571 | { |
| 3572 | |
| 3573 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3574 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3575 | if( pHostapdState->bssState == BSS_START) |
| 3576 | { |
| 3577 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3578 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3579 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3580 | { |
| 3581 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3582 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3583 | __LINE__, status ); |
| 3584 | } |
| 3585 | } |
| 3586 | } |
| 3587 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3588 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3589 | ) |
| 3590 | { |
| 3591 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3592 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3593 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3594 | |
| 3595 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3596 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3597 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3598 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3599 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3600 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3601 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3602 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3603 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3604 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3605 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3606 | if ( 0 != status ) |
| 3607 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3608 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3609 | "%s: sme_RoamSetKey failure, returned %d", |
| 3610 | __func__, status); |
| 3611 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3612 | return -EINVAL; |
| 3613 | } |
| 3614 | } |
| 3615 | } |
| 3616 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3617 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3618 | return status; |
| 3619 | } |
| 3620 | |
| 3621 | /* |
| 3622 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3623 | * This function is used to set the default tx key index |
| 3624 | */ |
| 3625 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3626 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3627 | struct net_device *ndev, |
| 3628 | u8 key_index, |
| 3629 | bool unicast, bool multicast) |
| 3630 | #else |
| 3631 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3632 | struct net_device *ndev, |
| 3633 | u8 key_index) |
| 3634 | #endif |
| 3635 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3636 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3637 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3638 | hdd_wext_state_t *pWextState; |
| 3639 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3640 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3641 | |
| 3642 | ENTER(); |
| 3643 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3644 | if ((NULL == pAdapter)) |
| 3645 | { |
| 3646 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3647 | "invalid adapter"); |
| 3648 | return -EINVAL; |
| 3649 | } |
| 3650 | |
| 3651 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3652 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3653 | |
| 3654 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3655 | { |
| 3656 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3657 | "invalid Wext state or HDD context"); |
| 3658 | return -EINVAL; |
| 3659 | } |
| 3660 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3661 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3662 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3663 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3664 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3665 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3666 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3667 | key_index); |
| 3668 | |
| 3669 | return -EINVAL; |
| 3670 | } |
| 3671 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3672 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3673 | status = wlan_hdd_validate_context(pHddCtx); |
| 3674 | |
| 3675 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3676 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3677 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3678 | "%s: HDD context is not valid", __func__); |
| 3679 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3680 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3681 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3682 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3683 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3684 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3685 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3686 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3687 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3688 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3689 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3690 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3691 | { |
| 3692 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3693 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3694 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3695 | tCsrRoamSetKey setKey; |
| 3696 | v_U32_t roamId= 0xFF; |
| 3697 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3698 | |
| 3699 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3700 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3701 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3702 | Keys->defaultIndex = (u8)key_index; |
| 3703 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3704 | setKey.keyId = key_index; |
| 3705 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3706 | |
| 3707 | vos_mem_copy(&setKey.Key[0], |
| 3708 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3709 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3710 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3711 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3712 | |
| 3713 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3714 | &pHddStaCtx->conn_info.bssId[0], |
| 3715 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3716 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3717 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3718 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3719 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3720 | { |
| 3721 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3722 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3723 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3724 | type(104) and switching encryption type to 40*/ |
| 3725 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3726 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3727 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3728 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3729 | } |
| 3730 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3731 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3732 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3733 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3734 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3735 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3736 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3737 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3738 | if ( 0 != status ) |
| 3739 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3740 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3741 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3742 | status); |
| 3743 | return -EINVAL; |
| 3744 | } |
| 3745 | } |
| 3746 | } |
| 3747 | |
| 3748 | /* In SoftAp mode setting key direction for default mode */ |
| 3749 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3750 | { |
| 3751 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3752 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3753 | (eCSR_ENCRYPT_TYPE_AES != |
| 3754 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3755 | ) |
| 3756 | { |
| 3757 | /* Saving key direction for default key index to TX default */ |
| 3758 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3759 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3760 | } |
| 3761 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3762 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3763 | return status; |
| 3764 | } |
| 3765 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3766 | /* |
| 3767 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3768 | * This function is used to inform the BSS details to nl80211 interface. |
| 3769 | */ |
| 3770 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3771 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3772 | { |
| 3773 | struct net_device *dev = pAdapter->dev; |
| 3774 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3775 | struct wiphy *wiphy = wdev->wiphy; |
| 3776 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3777 | int chan_no; |
| 3778 | int ie_length; |
| 3779 | const char *ie; |
| 3780 | unsigned int freq; |
| 3781 | struct ieee80211_channel *chan; |
| 3782 | int rssi = 0; |
| 3783 | struct cfg80211_bss *bss = NULL; |
| 3784 | |
| 3785 | ENTER(); |
| 3786 | |
| 3787 | if( NULL == pBssDesc ) |
| 3788 | { |
| 3789 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3790 | return bss; |
| 3791 | } |
| 3792 | |
| 3793 | chan_no = pBssDesc->channelId; |
| 3794 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3795 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3796 | |
| 3797 | if( NULL == ie ) |
| 3798 | { |
| 3799 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3800 | return bss; |
| 3801 | } |
| 3802 | |
| 3803 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3804 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3805 | { |
| 3806 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3807 | } |
| 3808 | else |
| 3809 | { |
| 3810 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3811 | } |
| 3812 | #else |
| 3813 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3814 | #endif |
| 3815 | |
| 3816 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3817 | |
| 3818 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3819 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3820 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3821 | if (bss == NULL) |
| 3822 | { |
| 3823 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3824 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3825 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3826 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3827 | pBssDesc->capabilityInfo, |
| 3828 | pBssDesc->beaconInterval, ie, ie_length, |
| 3829 | rssi, GFP_KERNEL )); |
| 3830 | } |
| 3831 | else |
| 3832 | { |
| 3833 | return bss; |
| 3834 | } |
| 3835 | } |
| 3836 | |
| 3837 | |
| 3838 | |
| 3839 | /* |
| 3840 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3841 | * This function is used to inform the BSS details to nl80211 interface. |
| 3842 | */ |
| 3843 | struct cfg80211_bss* |
| 3844 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3845 | tSirBssDescription *bss_desc |
| 3846 | ) |
| 3847 | { |
| 3848 | /* |
| 3849 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3850 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3851 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3852 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3853 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3854 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3855 | cfg80211_inform_bss_frame. |
| 3856 | */ |
| 3857 | struct net_device *dev = pAdapter->dev; |
| 3858 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3859 | struct wiphy *wiphy = wdev->wiphy; |
| 3860 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3861 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3862 | qcom_ie_age *qie_age = NULL; |
| 3863 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3864 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3865 | 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] | 3866 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3867 | const char *ie = |
| 3868 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3869 | unsigned int freq; |
| 3870 | struct ieee80211_channel *chan; |
| 3871 | struct ieee80211_mgmt *mgmt = |
| 3872 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 3873 | struct cfg80211_bss *bss_status = NULL; |
| 3874 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 3875 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3876 | #ifdef WLAN_OPEN_SOURCE |
| 3877 | struct timespec ts; |
| 3878 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3879 | |
| 3880 | ENTER(); |
| 3881 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 3882 | if (!mgmt) |
| 3883 | return NULL; |
| 3884 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3885 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3886 | |
| 3887 | #ifdef WLAN_OPEN_SOURCE |
| 3888 | /* Android does not want the timestamp from the frame. |
| 3889 | Instead it wants a monotonic increasing value */ |
| 3890 | get_monotonic_boottime(&ts); |
| 3891 | mgmt->u.probe_resp.timestamp = |
| 3892 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 3893 | #else |
| 3894 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3895 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 3896 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3897 | |
| 3898 | #endif |
| 3899 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3900 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 3901 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3902 | |
| 3903 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3904 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 3905 | /* Assuming this is the last IE, copy at the end */ |
| 3906 | ie_length -=sizeof(qcom_ie_age); |
| 3907 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 3908 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 3909 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 3910 | qie_age->oui_1 = QCOM_OUI1; |
| 3911 | qie_age->oui_2 = QCOM_OUI2; |
| 3912 | qie_age->oui_3 = QCOM_OUI3; |
| 3913 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 3914 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 3915 | #endif |
| 3916 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3917 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 3918 | if (bss_desc->fProbeRsp) |
| 3919 | { |
| 3920 | mgmt->frame_control |= |
| 3921 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 3922 | } |
| 3923 | else |
| 3924 | { |
| 3925 | mgmt->frame_control |= |
| 3926 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 3927 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3928 | |
| 3929 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3930 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3931 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 3932 | { |
| 3933 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3934 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3935 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3936 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 3937 | |
| 3938 | { |
| 3939 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3940 | } |
| 3941 | else |
| 3942 | { |
| 3943 | kfree(mgmt); |
| 3944 | return NULL; |
| 3945 | } |
| 3946 | #else |
| 3947 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3948 | #endif |
| 3949 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3950 | /*when the band is changed on the fly using the GUI, three things are done |
| 3951 | * 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) |
| 3952 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 3953 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 3954 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 3955 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 3956 | * 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 |
| 3957 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 3958 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 3959 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 3960 | * So drop the bss and continue to next bss. |
| 3961 | */ |
| 3962 | if(chan == NULL) |
| 3963 | { |
| 3964 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 3965 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3966 | return NULL; |
| 3967 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3968 | /*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] | 3969 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3970 | * */ |
| 3971 | if (( eConnectionState_Associated == |
| 3972 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 3973 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 3974 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 3975 | WNI_CFG_BSSID_LEN))) |
| 3976 | { |
| 3977 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 3978 | rssi = (pAdapter->rssi * 100); |
| 3979 | } |
| 3980 | else |
| 3981 | { |
| 3982 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 3983 | } |
| 3984 | |
| 3985 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 3986 | frame_len, rssi, GFP_KERNEL); |
| 3987 | kfree(mgmt); |
| 3988 | return bss_status; |
| 3989 | } |
| 3990 | |
| 3991 | /* |
| 3992 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 3993 | * This function is used to update the BSS data base of CFG8011 |
| 3994 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3995 | 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] | 3996 | tCsrRoamInfo *pRoamInfo |
| 3997 | ) |
| 3998 | { |
| 3999 | tCsrRoamConnectedProfile roamProfile; |
| 4000 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4001 | struct cfg80211_bss *bss = NULL; |
| 4002 | |
| 4003 | ENTER(); |
| 4004 | |
| 4005 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4006 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4007 | |
| 4008 | if (NULL != roamProfile.pBssDesc) |
| 4009 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4010 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4011 | &roamProfile); |
| 4012 | |
| 4013 | if (NULL == bss) |
| 4014 | { |
| 4015 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4016 | __func__); |
| 4017 | } |
| 4018 | |
| 4019 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4020 | } |
| 4021 | else |
| 4022 | { |
| 4023 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4024 | __func__); |
| 4025 | } |
| 4026 | return bss; |
| 4027 | } |
| 4028 | |
| 4029 | /* |
| 4030 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4031 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4032 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4033 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4034 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4035 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4036 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4037 | tCsrScanResultInfo *pScanResult; |
| 4038 | eHalStatus status = 0; |
| 4039 | tScanResultHandle pResult; |
| 4040 | struct cfg80211_bss *bss_status = NULL; |
| 4041 | |
| 4042 | ENTER(); |
| 4043 | |
| 4044 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4045 | { |
| 4046 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4047 | return -EAGAIN; |
| 4048 | } |
| 4049 | |
| 4050 | /* |
| 4051 | * start getting scan results and populate cgf80211 BSS database |
| 4052 | */ |
| 4053 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4054 | |
| 4055 | /* no scan results */ |
| 4056 | if (NULL == pResult) |
| 4057 | { |
| 4058 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 4059 | return status; |
| 4060 | } |
| 4061 | |
| 4062 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4063 | |
| 4064 | while (pScanResult) |
| 4065 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4066 | /* |
| 4067 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4068 | * entry already exists in bss data base of cfg80211 for that |
| 4069 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4070 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4071 | * mgmt packet as input. As of now there is no possibility to get |
| 4072 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4073 | * ieee80211_mgmt(probe response) and passing to c |
| 4074 | * fg80211_inform_bss_frame. |
| 4075 | * */ |
| 4076 | |
| 4077 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4078 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4079 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4080 | |
| 4081 | if (NULL == bss_status) |
| 4082 | { |
| 4083 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4084 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 4085 | } |
| 4086 | else |
| 4087 | { |
| 4088 | cfg80211_put_bss(bss_status); |
| 4089 | } |
| 4090 | |
| 4091 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4092 | } |
| 4093 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4094 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4095 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4096 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4097 | } |
| 4098 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4099 | void |
| 4100 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4101 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4102 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4103 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4104 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 4105 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4106 | } /****** end hddPrintMacAddr() ******/ |
| 4107 | |
| 4108 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4109 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4110 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4111 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4112 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4113 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4114 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4115 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4116 | } /****** end hddPrintPmkId() ******/ |
| 4117 | |
| 4118 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4119 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4120 | |
| 4121 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4122 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4123 | |
| 4124 | #define dump_bssid(bssid) \ |
| 4125 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4126 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4127 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 4128 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4129 | } |
| 4130 | |
| 4131 | #define dump_pmkid(pMac, pmkid) \ |
| 4132 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4133 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4134 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4135 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4136 | } |
| 4137 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4138 | #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] | 4139 | /* |
| 4140 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4141 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4142 | */ |
| 4143 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4144 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4145 | int index, bool preauth ) |
| 4146 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4147 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4148 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4149 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4150 | |
| 4151 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4152 | 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] | 4153 | |
| 4154 | if( NULL == pRoamInfo ) |
| 4155 | { |
| 4156 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4157 | return -EINVAL; |
| 4158 | } |
| 4159 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4160 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4161 | { |
| 4162 | dump_bssid(pRoamInfo->bssid); |
| 4163 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4164 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4165 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4166 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4167 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4168 | } |
| 4169 | #endif //FEATURE_WLAN_LFR |
| 4170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4171 | /* |
| 4172 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4173 | * scanning callback function, called after finishing scan |
| 4174 | * |
| 4175 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4176 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4177 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4178 | { |
| 4179 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4180 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4181 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4182 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4183 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4184 | struct cfg80211_scan_request *req = NULL; |
| 4185 | int ret = 0; |
| 4186 | |
| 4187 | ENTER(); |
| 4188 | |
| 4189 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4190 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4191 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4192 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4193 | |
| 4194 | //Block on scan req completion variable. Can't wait forever though. |
| 4195 | ret = wait_for_completion_interruptible_timeout( |
| 4196 | &pScanInfo->scan_req_completion_event, |
| 4197 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4198 | if (!ret) |
| 4199 | { |
| 4200 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4201 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4202 | } |
| 4203 | |
| 4204 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4205 | { |
| 4206 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4207 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4208 | } |
| 4209 | |
| 4210 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4211 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4212 | { |
| 4213 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4214 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4215 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4216 | (int) scanId); |
| 4217 | } |
| 4218 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4219 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4220 | pAdapter); |
| 4221 | |
| 4222 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4223 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4224 | |
| 4225 | |
| 4226 | /* If any client wait scan result through WEXT |
| 4227 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4228 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4229 | { |
| 4230 | /* The other scan request waiting for current scan finish |
| 4231 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4232 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4233 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4234 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4235 | } |
| 4236 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4237 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4238 | { |
| 4239 | struct net_device *dev = pAdapter->dev; |
| 4240 | union iwreq_data wrqu; |
| 4241 | int we_event; |
| 4242 | char *msg; |
| 4243 | |
| 4244 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4245 | we_event = SIOCGIWSCAN; |
| 4246 | msg = NULL; |
| 4247 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4248 | } |
| 4249 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4250 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4251 | |
| 4252 | /* Get the Scan Req */ |
| 4253 | req = pAdapter->request; |
| 4254 | |
| 4255 | if (!req) |
| 4256 | { |
| 4257 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4258 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4259 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4260 | } |
| 4261 | |
| 4262 | /* |
| 4263 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4264 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4265 | req->n_ssids = 0; |
| 4266 | req->n_channels = 0; |
| 4267 | req->ie = 0; |
| 4268 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4269 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4270 | /* Scan is no longer pending */ |
| 4271 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4272 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4273 | /* |
| 4274 | * cfg80211_scan_done informing NL80211 about completion |
| 4275 | * of scanning |
| 4276 | */ |
| 4277 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4278 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4279 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4280 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4281 | /* release the wake lock at the end of the scan*/ |
| 4282 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4283 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4284 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4285 | * immediatly after the driver gets connect request(i.e after scan) |
| 4286 | * from supplicant, this result in app's is suspending and not able |
| 4287 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4288 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4289 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4290 | #ifdef FEATURE_WLAN_TDLS |
| 4291 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4292 | #endif |
| 4293 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4294 | EXIT(); |
| 4295 | return 0; |
| 4296 | } |
| 4297 | |
| 4298 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4299 | * FUNCTION: hdd_isScanAllowed |
| 4300 | * Go through each adapter and check if scan allowed |
| 4301 | * |
| 4302 | */ |
| 4303 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4304 | { |
| 4305 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4306 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4307 | hdd_adapter_t *pAdapter = NULL; |
| 4308 | VOS_STATUS status = 0; |
| 4309 | v_U8_t staId = 0; |
| 4310 | v_U8_t *staMac = NULL; |
| 4311 | |
| 4312 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4313 | |
| 4314 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4315 | { |
| 4316 | pAdapter = pAdapterNode->pAdapter; |
| 4317 | |
| 4318 | if( pAdapter ) |
| 4319 | { |
| 4320 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4321 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4322 | __func__, pAdapter->device_mode); |
| 4323 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4324 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4325 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4326 | { |
| 4327 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4328 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4329 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4330 | { |
| 4331 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4332 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4333 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4334 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4335 | staMac[0], staMac[1], staMac[2], |
| 4336 | staMac[3], staMac[4], staMac[5]); |
| 4337 | return VOS_FALSE; |
| 4338 | } |
| 4339 | } |
| 4340 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4341 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4342 | { |
| 4343 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4344 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4345 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4346 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4347 | { |
| 4348 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4349 | |
| 4350 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4351 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4352 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4353 | staMac[0], staMac[1], staMac[2], |
| 4354 | staMac[3], staMac[4], staMac[5]); |
| 4355 | return VOS_FALSE; |
| 4356 | } |
| 4357 | } |
| 4358 | } |
| 4359 | } |
| 4360 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4361 | pAdapterNode = pNext; |
| 4362 | } |
| 4363 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4364 | "%s: Scan allowed", __func__); |
| 4365 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4366 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4367 | |
| 4368 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4369 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4370 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4371 | * later, scan dump command can be used to recieve scan results |
| 4372 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4373 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4374 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4375 | struct net_device *dev, |
| 4376 | #endif |
| 4377 | struct cfg80211_scan_request *request) |
| 4378 | { |
| 4379 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4380 | struct net_device *dev = request->wdev->netdev; |
| 4381 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4382 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4383 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4384 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4385 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4386 | tCsrScanRequest scanRequest; |
| 4387 | tANI_U8 *channelList = NULL, i; |
| 4388 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4389 | int status; |
| 4390 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4391 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4392 | |
| 4393 | ENTER(); |
| 4394 | |
| 4395 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4396 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4397 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4398 | status = wlan_hdd_validate_context(pHddCtx); |
| 4399 | |
| 4400 | if (0 != status) |
| 4401 | { |
| 4402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4403 | "%s: HDD context is not valid", __func__); |
| 4404 | return status; |
| 4405 | } |
| 4406 | |
| 4407 | cfg_param = pHddCtx->cfg_ini; |
| 4408 | pScanInfo = &pHddCtx->scan_info; |
| 4409 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4410 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4411 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4412 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4413 | { |
| 4414 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4415 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4416 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4417 | return -EBUSY; |
| 4418 | } |
| 4419 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4420 | #ifdef WLAN_BTAMP_FEATURE |
| 4421 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4422 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4423 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4424 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4425 | "%s: No scanning when AMP is on", __func__); |
| 4426 | return -EOPNOTSUPP; |
| 4427 | } |
| 4428 | #endif |
| 4429 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4430 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4431 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4432 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4433 | "%s: Not scanning on device_mode = %d", |
| 4434 | __func__, pAdapter->device_mode); |
| 4435 | return -EOPNOTSUPP; |
| 4436 | } |
| 4437 | |
| 4438 | if (TRUE == pScanInfo->mScanPending) |
| 4439 | { |
| 4440 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4441 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4442 | } |
| 4443 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4444 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4445 | //Channel and action frame is pending |
| 4446 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4447 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4448 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4449 | { |
| 4450 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4451 | return -EBUSY; |
| 4452 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4453 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4454 | /* if tdls disagree scan right now, return immediately. |
| 4455 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4456 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4457 | */ |
| 4458 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4459 | wiphy, |
| 4460 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4461 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4462 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4463 | request); |
| 4464 | if(status <= 0) |
| 4465 | { |
| 4466 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4467 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4468 | } |
| 4469 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4470 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4471 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4472 | { |
| 4473 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4474 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4475 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4476 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4477 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4478 | { |
| 4479 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4480 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4481 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4482 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4483 | } |
| 4484 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4485 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4486 | /* Check if scan is allowed at this point of time. |
| 4487 | */ |
| 4488 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4489 | { |
| 4490 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4491 | return -EBUSY; |
| 4492 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4493 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4494 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4495 | |
| 4496 | if (NULL != request) |
| 4497 | { |
| 4498 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4499 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4500 | |
| 4501 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4502 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4503 | * is not aging out the scan results. |
| 4504 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4505 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4506 | { |
| 4507 | request->n_ssids = 0; |
| 4508 | } |
| 4509 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4510 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4511 | { |
| 4512 | tCsrSSIDInfo *SsidInfo; |
| 4513 | int j; |
| 4514 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4515 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4516 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4517 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4518 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4519 | |
| 4520 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4521 | { |
| 4522 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4523 | "memory alloc failed SSIDInfo buffer"); |
| 4524 | return -ENOMEM; |
| 4525 | } |
| 4526 | |
| 4527 | /* copy all the ssid's and their length */ |
| 4528 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4529 | { |
| 4530 | /* get the ssid length */ |
| 4531 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4532 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4533 | SsidInfo->SSID.length); |
| 4534 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4535 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4536 | j, SsidInfo->SSID.ssId); |
| 4537 | } |
| 4538 | /* set the scan type to active */ |
| 4539 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4540 | } |
| 4541 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4542 | { |
| 4543 | /* set the scan type to active */ |
| 4544 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4545 | } |
| 4546 | else |
| 4547 | { |
| 4548 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4549 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4550 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4551 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4552 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4553 | } |
| 4554 | else |
| 4555 | { |
| 4556 | /* set the scan type to active */ |
| 4557 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4558 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4559 | |
| 4560 | /* set min and max channel time to zero */ |
| 4561 | scanRequest.minChnTime = 0; |
| 4562 | scanRequest.maxChnTime = 0; |
| 4563 | } |
| 4564 | |
| 4565 | /* set BSSType to default type */ |
| 4566 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4567 | |
| 4568 | /*TODO: scan the requested channels only*/ |
| 4569 | |
| 4570 | /*Right now scanning all the channels */ |
| 4571 | if( request ) |
| 4572 | { |
| 4573 | if( request->n_channels ) |
| 4574 | { |
| 4575 | channelList = vos_mem_malloc( request->n_channels ); |
| 4576 | if( NULL == channelList ) |
| 4577 | { |
| 4578 | status = -ENOMEM; |
| 4579 | goto free_mem; |
| 4580 | } |
| 4581 | |
| 4582 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4583 | channelList[i] = request->channels[i]->hw_value; |
| 4584 | } |
| 4585 | |
| 4586 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4587 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4588 | |
| 4589 | /* set requestType to full scan */ |
| 4590 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4591 | |
| 4592 | /* 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] | 4593 | * 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] | 4594 | * 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] | 4595 | */ |
| 4596 | |
| 4597 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4598 | * and in that case driver shoudnt flush scan results. If |
| 4599 | * driver flushes the scan results here and unfortunately if |
| 4600 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4601 | * fails which is not desired |
| 4602 | */ |
| 4603 | |
| 4604 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4605 | { |
| 4606 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4607 | pAdapter->sessionId ); |
| 4608 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4609 | |
| 4610 | if( request->ie_len ) |
| 4611 | { |
| 4612 | /* save this for future association (join requires this) */ |
| 4613 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4614 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4615 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4616 | |
| 4617 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4618 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4619 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4620 | ) |
| 4621 | { |
| 4622 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4623 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4624 | } |
| 4625 | |
| 4626 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4627 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4628 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4629 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4630 | request->ie_len); |
| 4631 | if (pP2pIe != NULL) |
| 4632 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4633 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4634 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4635 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4636 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4637 | { |
| 4638 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4639 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4640 | "Go nego completed to Connection is started"); |
| 4641 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4642 | "for 8way Handshake"); |
| 4643 | } |
| 4644 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4645 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4646 | { |
| 4647 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4648 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4649 | "Disconnected state to Connection is started"); |
| 4650 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4651 | "for 4way Handshake"); |
| 4652 | } |
| 4653 | #endif |
| 4654 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4655 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4656 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4657 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4658 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4659 | "%s: This is a P2P Search", __func__); |
| 4660 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4661 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4662 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4663 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4664 | /* set requestType to P2P Discovery */ |
| 4665 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4666 | } |
| 4667 | |
| 4668 | /* |
| 4669 | Skip Dfs Channel in case of P2P Search |
| 4670 | if it is set in ini file |
| 4671 | */ |
| 4672 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4673 | { |
| 4674 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4675 | } |
| 4676 | else |
| 4677 | { |
| 4678 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4679 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4680 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4681 | } |
| 4682 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4683 | } |
| 4684 | } |
| 4685 | |
| 4686 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4687 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4688 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4689 | * address the following issues. |
| 4690 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4691 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4692 | * for long time, this result in apps running at full power for long time. |
| 4693 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4694 | * be stuck in full power because of resume BMPS |
| 4695 | */ |
| 4696 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4697 | |
| 4698 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4699 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4700 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4701 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4702 | if (eHAL_STATUS_SUCCESS != status) |
| 4703 | { |
| 4704 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4705 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4706 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4707 | if(eHAL_STATUS_RESOURCES == status) |
| 4708 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4709 | 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] | 4710 | status = -EBUSY; |
| 4711 | } else { |
| 4712 | status = -EIO; |
| 4713 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4714 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4715 | goto free_mem; |
| 4716 | } |
| 4717 | |
| 4718 | pScanInfo->mScanPending = TRUE; |
| 4719 | pAdapter->request = request; |
| 4720 | pScanInfo->scanId = scanId; |
| 4721 | |
| 4722 | complete(&pScanInfo->scan_req_completion_event); |
| 4723 | |
| 4724 | free_mem: |
| 4725 | if( scanRequest.SSIDs.SSIDList ) |
| 4726 | { |
| 4727 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4728 | } |
| 4729 | |
| 4730 | if( channelList ) |
| 4731 | vos_mem_free( channelList ); |
| 4732 | |
| 4733 | EXIT(); |
| 4734 | |
| 4735 | return status; |
| 4736 | } |
| 4737 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4738 | |
| 4739 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 4740 | { |
| 4741 | v_U8_t iniDot11Mode = |
| 4742 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 4743 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 4744 | |
| 4745 | switch ( iniDot11Mode ) |
| 4746 | { |
| 4747 | case eHDD_DOT11_MODE_AUTO: |
| 4748 | case eHDD_DOT11_MODE_11ac: |
| 4749 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 4750 | #ifdef WLAN_FEATURE_11AC |
| 4751 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 4752 | #else |
| 4753 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4754 | #endif |
| 4755 | break; |
| 4756 | case eHDD_DOT11_MODE_11n: |
| 4757 | case eHDD_DOT11_MODE_11n_ONLY: |
| 4758 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4759 | break; |
| 4760 | default: |
| 4761 | hddDot11Mode = iniDot11Mode; |
| 4762 | break; |
| 4763 | } |
| 4764 | /* This call decides required channel bonding mode */ |
| 4765 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 4766 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 4767 | operationChannel); |
| 4768 | } |
| 4769 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4770 | /* |
| 4771 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4772 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4773 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4774 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4775 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4776 | { |
| 4777 | int status = 0; |
| 4778 | hdd_wext_state_t *pWextState; |
| 4779 | v_U32_t roamId; |
| 4780 | tCsrRoamProfile *pRoamProfile; |
| 4781 | eMib_dot11DesiredBssType connectedBssType; |
| 4782 | eCsrAuthType RSNAuthType; |
| 4783 | |
| 4784 | ENTER(); |
| 4785 | |
| 4786 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4787 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4788 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4789 | { |
| 4790 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4791 | return -EINVAL; |
| 4792 | } |
| 4793 | |
| 4794 | pRoamProfile = &pWextState->roamProfile; |
| 4795 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4796 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4797 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4798 | int ret = 0; |
| 4799 | hdd_station_ctx_t *pHddStaCtx; |
| 4800 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4801 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4802 | |
| 4803 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4804 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4805 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4806 | { |
| 4807 | /* Issue disconnect to CSR */ |
| 4808 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4809 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4810 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4811 | pAdapter->sessionId, |
| 4812 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4813 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4814 | ret = wait_for_completion_interruptible_timeout( |
| 4815 | &pAdapter->disconnect_comp_var, |
| 4816 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4817 | if (0 == ret) |
| 4818 | { |
| 4819 | VOS_ASSERT(0); |
| 4820 | } |
| 4821 | } |
| 4822 | } |
| 4823 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4824 | { |
| 4825 | ret = wait_for_completion_interruptible_timeout( |
| 4826 | &pAdapter->disconnect_comp_var, |
| 4827 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4828 | if (0 == ret) |
| 4829 | { |
| 4830 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4831 | } |
| 4832 | } |
| 4833 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4834 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4835 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4836 | { |
| 4837 | /*QoS not enabled in cfg file*/ |
| 4838 | pRoamProfile->uapsd_mask = 0; |
| 4839 | } |
| 4840 | else |
| 4841 | { |
| 4842 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4843 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4844 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4845 | } |
| 4846 | |
| 4847 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4848 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4849 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4850 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4851 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4852 | ssid, ssid_len); |
| 4853 | |
| 4854 | if (bssid) |
| 4855 | { |
| 4856 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4857 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4858 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4859 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4860 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4861 | case of join failure we should send valid BSSID to supplicant |
| 4862 | */ |
| 4863 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4864 | WNI_CFG_BSSID_LEN); |
| 4865 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 4866 | else |
| 4867 | { |
| 4868 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 4869 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4870 | |
| 4871 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 4872 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4873 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4874 | /*set gen ie*/ |
| 4875 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 4876 | /*set auth*/ |
| 4877 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 4878 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4879 | #ifdef FEATURE_WLAN_WAPI |
| 4880 | if (pAdapter->wapi_info.nWapiMode) |
| 4881 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4882 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4883 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 4884 | { |
| 4885 | case WAPI_AUTH_MODE_PSK: |
| 4886 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4887 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4888 | pAdapter->wapi_info.wapiAuthMode); |
| 4889 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 4890 | break; |
| 4891 | } |
| 4892 | case WAPI_AUTH_MODE_CERT: |
| 4893 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4894 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4895 | pAdapter->wapi_info.wapiAuthMode); |
| 4896 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 4897 | break; |
| 4898 | } |
| 4899 | } // End of switch |
| 4900 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 4901 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 4902 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4903 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4904 | pRoamProfile->AuthType.numEntries = 1; |
| 4905 | pRoamProfile->EncryptionType.numEntries = 1; |
| 4906 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4907 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 4908 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4909 | } |
| 4910 | } |
| 4911 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 4912 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 4913 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 4914 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4915 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4916 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 4917 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 4918 | sizeof (tSirGtkOffloadParams)); |
| 4919 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 4920 | } |
| 4921 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4922 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 4923 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4924 | if( operatingChannel ) |
| 4925 | { |
| 4926 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 4927 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 4928 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 4929 | else |
| 4930 | { |
| 4931 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4932 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4933 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4934 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 4935 | { |
| 4936 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 4937 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4938 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 4939 | * 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] | 4940 | * 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] | 4941 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4942 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 4943 | */ |
| 4944 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 4945 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 4946 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4947 | |
| 4948 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4949 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 4950 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4951 | if( (eHAL_STATUS_SUCCESS != status) && |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4952 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 4953 | |
| 4954 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4955 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 4956 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 4957 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4958 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4959 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4960 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4961 | |
| 4962 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4963 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4964 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4965 | } |
| 4966 | else |
| 4967 | { |
| 4968 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 4969 | return -EINVAL; |
| 4970 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4971 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4972 | return status; |
| 4973 | } |
| 4974 | |
| 4975 | /* |
| 4976 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 4977 | * This function is used to set the authentication type (OPEN/SHARED). |
| 4978 | * |
| 4979 | */ |
| 4980 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 4981 | enum nl80211_auth_type auth_type) |
| 4982 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4983 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4984 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4985 | |
| 4986 | ENTER(); |
| 4987 | |
| 4988 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4989 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4990 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4991 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4992 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4993 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 4994 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 4995 | break; |
| 4996 | |
| 4997 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 4998 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4999 | case NL80211_AUTHTYPE_FT: |
| 5000 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5001 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5002 | "%s: set authentication type to OPEN", __func__); |
| 5003 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5004 | break; |
| 5005 | |
| 5006 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5007 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5008 | "%s: set authentication type to SHARED", __func__); |
| 5009 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5010 | break; |
| 5011 | #ifdef FEATURE_WLAN_CCX |
| 5012 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5013 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5014 | "%s: set authentication type to CCKM WPA", __func__); |
| 5015 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5016 | break; |
| 5017 | #endif |
| 5018 | |
| 5019 | |
| 5020 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5021 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5022 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5023 | auth_type); |
| 5024 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5025 | return -EINVAL; |
| 5026 | } |
| 5027 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5028 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5029 | pHddStaCtx->conn_info.authType; |
| 5030 | return 0; |
| 5031 | } |
| 5032 | |
| 5033 | /* |
| 5034 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5035 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5036 | * |
| 5037 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5038 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5039 | u32 key_mgmt |
| 5040 | ) |
| 5041 | { |
| 5042 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5043 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5044 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5045 | /*set key mgmt type*/ |
| 5046 | switch(key_mgmt) |
| 5047 | { |
| 5048 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5049 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5050 | case WLAN_AKM_SUITE_FT_PSK: |
| 5051 | #endif |
| 5052 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5053 | __func__); |
| 5054 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5055 | break; |
| 5056 | |
| 5057 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5058 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5059 | case WLAN_AKM_SUITE_FT_8021X: |
| 5060 | #endif |
| 5061 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5062 | __func__); |
| 5063 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5064 | break; |
| 5065 | #ifdef FEATURE_WLAN_CCX |
| 5066 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5067 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5068 | case WLAN_AKM_SUITE_CCKM: |
| 5069 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5070 | __func__); |
| 5071 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5072 | break; |
| 5073 | #endif |
| 5074 | |
| 5075 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5076 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5077 | __func__, key_mgmt); |
| 5078 | return -EINVAL; |
| 5079 | |
| 5080 | } |
| 5081 | return 0; |
| 5082 | } |
| 5083 | |
| 5084 | /* |
| 5085 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5086 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5087 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5088 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5089 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5090 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5091 | bool ucast |
| 5092 | ) |
| 5093 | { |
| 5094 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5095 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5096 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5097 | |
| 5098 | ENTER(); |
| 5099 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5100 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5101 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5102 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5103 | __func__, cipher); |
| 5104 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5105 | } |
| 5106 | else |
| 5107 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5108 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5110 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5111 | { |
| 5112 | case IW_AUTH_CIPHER_NONE: |
| 5113 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5114 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5115 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5116 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5117 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5118 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5119 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5120 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5121 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5122 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5123 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5124 | case WLAN_CIPHER_SUITE_TKIP: |
| 5125 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5126 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5127 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5128 | case WLAN_CIPHER_SUITE_CCMP: |
| 5129 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5130 | break; |
| 5131 | #ifdef FEATURE_WLAN_WAPI |
| 5132 | case WLAN_CIPHER_SUITE_SMS4: |
| 5133 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5134 | break; |
| 5135 | #endif |
| 5136 | |
| 5137 | #ifdef FEATURE_WLAN_CCX |
| 5138 | case WLAN_CIPHER_SUITE_KRK: |
| 5139 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5140 | break; |
| 5141 | #endif |
| 5142 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5143 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5144 | __func__, cipher); |
| 5145 | return -EOPNOTSUPP; |
| 5146 | } |
| 5147 | } |
| 5148 | |
| 5149 | if (ucast) |
| 5150 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5151 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5152 | __func__, encryptionType); |
| 5153 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5154 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5155 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5156 | encryptionType; |
| 5157 | } |
| 5158 | else |
| 5159 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5160 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5161 | __func__, encryptionType); |
| 5162 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5163 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5164 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5165 | } |
| 5166 | |
| 5167 | return 0; |
| 5168 | } |
| 5169 | |
| 5170 | |
| 5171 | /* |
| 5172 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5173 | * This function is used to parse WPA/RSN IE's. |
| 5174 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5175 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5176 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5177 | size_t ie_len |
| 5178 | ) |
| 5179 | { |
| 5180 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5181 | u8 *genie = ie; |
| 5182 | v_U16_t remLen = ie_len; |
| 5183 | #ifdef FEATURE_WLAN_WAPI |
| 5184 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5185 | u16 *tmp; |
| 5186 | v_U16_t akmsuiteCount; |
| 5187 | int *akmlist; |
| 5188 | #endif |
| 5189 | ENTER(); |
| 5190 | |
| 5191 | /* clear previous assocAddIE */ |
| 5192 | pWextState->assocAddIE.length = 0; |
| 5193 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5194 | |
| 5195 | while (remLen >= 2) |
| 5196 | { |
| 5197 | v_U16_t eLen = 0; |
| 5198 | v_U8_t elementId; |
| 5199 | elementId = *genie++; |
| 5200 | eLen = *genie++; |
| 5201 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5202 | |
| 5203 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5204 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5205 | |
| 5206 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5207 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5208 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5209 | 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] | 5210 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5211 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5212 | "%s: Invalid WPA IE", __func__); |
| 5213 | return -EINVAL; |
| 5214 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5215 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5216 | { |
| 5217 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5218 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5219 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5220 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5221 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5222 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5223 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5224 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5225 | VOS_ASSERT(0); |
| 5226 | return -ENOMEM; |
| 5227 | } |
| 5228 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5229 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5230 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5231 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5232 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5233 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5234 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5235 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5236 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5237 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5238 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5239 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5240 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5241 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5242 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5243 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5244 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5245 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5246 | /*Consider P2P IE, only for P2P Client */ |
| 5247 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5248 | { |
| 5249 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5250 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5251 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5252 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5253 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5254 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5255 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5256 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5257 | VOS_ASSERT(0); |
| 5258 | return -ENOMEM; |
| 5259 | } |
| 5260 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5261 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5262 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5263 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5264 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5265 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5266 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5267 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5268 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5269 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5270 | /*Consider WFD IE, only for P2P Client */ |
| 5271 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5272 | { |
| 5273 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5274 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5275 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5276 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5277 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5278 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5279 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5280 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5281 | VOS_ASSERT(0); |
| 5282 | return -ENOMEM; |
| 5283 | } |
| 5284 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5285 | // WPS IE + P2P IE + WFD IE |
| 5286 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5287 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5288 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5289 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5290 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5291 | } |
| 5292 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5293 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5294 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5295 | HS20_OUI_TYPE_SIZE)) ) |
| 5296 | { |
| 5297 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5298 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5299 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5300 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5301 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5302 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5303 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5304 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5305 | VOS_ASSERT(0); |
| 5306 | return -ENOMEM; |
| 5307 | } |
| 5308 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5309 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5310 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5311 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5312 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5313 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5315 | break; |
| 5316 | case DOT11F_EID_RSN: |
| 5317 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5318 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5319 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5320 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5321 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5322 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5323 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5324 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5325 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5326 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5327 | 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] | 5328 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5329 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5330 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5331 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5332 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5333 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5334 | VOS_ASSERT(0); |
| 5335 | return -ENOMEM; |
| 5336 | } |
| 5337 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5338 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5339 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5340 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5341 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5342 | break; |
| 5343 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5344 | #ifdef FEATURE_WLAN_WAPI |
| 5345 | case WLAN_EID_WAPI: |
| 5346 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5347 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5348 | pAdapter->wapi_info.nWapiMode); |
| 5349 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5350 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5351 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5352 | tmp = tmp + 1; |
| 5353 | akmlist = (int *)(tmp); |
| 5354 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5355 | { |
| 5356 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5357 | } |
| 5358 | else |
| 5359 | { |
| 5360 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5361 | VOS_ASSERT(0); |
| 5362 | return -EINVAL; |
| 5363 | } |
| 5364 | |
| 5365 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5366 | { |
| 5367 | 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] | 5368 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5369 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5370 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5371 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5372 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5373 | 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] | 5374 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5375 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5376 | } |
| 5377 | break; |
| 5378 | #endif |
| 5379 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5380 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5381 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5382 | /* when Unknown IE is received we should break and continue |
| 5383 | * to the next IE in the buffer instead we were returning |
| 5384 | * so changing this to break */ |
| 5385 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5386 | } |
| 5387 | genie += eLen; |
| 5388 | remLen -= eLen; |
| 5389 | } |
| 5390 | EXIT(); |
| 5391 | return 0; |
| 5392 | } |
| 5393 | |
| 5394 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5395 | * FUNCTION: hdd_isWPAIEPresent |
| 5396 | * Parse the received IE to find the WPA IE |
| 5397 | * |
| 5398 | */ |
| 5399 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5400 | { |
| 5401 | v_U8_t eLen = 0; |
| 5402 | v_U16_t remLen = ie_len; |
| 5403 | v_U8_t elementId = 0; |
| 5404 | |
| 5405 | while (remLen >= 2) |
| 5406 | { |
| 5407 | elementId = *ie++; |
| 5408 | eLen = *ie++; |
| 5409 | remLen -= 2; |
| 5410 | if (eLen > remLen) |
| 5411 | { |
| 5412 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5413 | "%s: IE length is wrong %d", __func__, eLen); |
| 5414 | return FALSE; |
| 5415 | } |
| 5416 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5417 | { |
| 5418 | /* OUI - 0x00 0X50 0XF2 |
| 5419 | WPA Information Element - 0x01 |
| 5420 | WPA version - 0x01*/ |
| 5421 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5422 | return TRUE; |
| 5423 | } |
| 5424 | ie += eLen; |
| 5425 | remLen -= eLen; |
| 5426 | } |
| 5427 | return FALSE; |
| 5428 | } |
| 5429 | |
| 5430 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5431 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5432 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5433 | * parameters during connect operation. |
| 5434 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5435 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5436 | struct cfg80211_connect_params *req |
| 5437 | ) |
| 5438 | { |
| 5439 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5440 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5441 | ENTER(); |
| 5442 | |
| 5443 | /*set wpa version*/ |
| 5444 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5445 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5446 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5447 | { |
| 5448 | if ( (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5449 | && ( (req->ie_len) |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5450 | && (hdd_isWPAIEPresent(req->ie, req->ie_len) ) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5451 | // Make sure that it is including a WPA IE. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5452 | /* Currently NL is putting WPA version 1 even for open, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5453 | * since p2p ie is also put in same buffer. |
| 5454 | * */ |
| 5455 | { |
| 5456 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5457 | } |
| 5458 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5459 | { |
| 5460 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5461 | } |
| 5462 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5463 | |
| 5464 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5465 | pWextState->wpaVersion); |
| 5466 | |
| 5467 | /*set authentication type*/ |
| 5468 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5469 | |
| 5470 | if (0 > status) |
| 5471 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5472 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5473 | "%s: failed to set authentication type ", __func__); |
| 5474 | return status; |
| 5475 | } |
| 5476 | |
| 5477 | /*set key mgmt type*/ |
| 5478 | if (req->crypto.n_akm_suites) |
| 5479 | { |
| 5480 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5481 | if (0 > status) |
| 5482 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5483 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5484 | __func__); |
| 5485 | return status; |
| 5486 | } |
| 5487 | } |
| 5488 | |
| 5489 | /*set pairwise cipher type*/ |
| 5490 | if (req->crypto.n_ciphers_pairwise) |
| 5491 | { |
| 5492 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5493 | req->crypto.ciphers_pairwise[0], true); |
| 5494 | if (0 > status) |
| 5495 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5496 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5497 | "%s: failed to set unicast cipher type", __func__); |
| 5498 | return status; |
| 5499 | } |
| 5500 | } |
| 5501 | else |
| 5502 | { |
| 5503 | /*Reset previous cipher suite to none*/ |
| 5504 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5505 | if (0 > status) |
| 5506 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5507 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5508 | "%s: failed to set unicast cipher type", __func__); |
| 5509 | return status; |
| 5510 | } |
| 5511 | } |
| 5512 | |
| 5513 | /*set group cipher type*/ |
| 5514 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5515 | false); |
| 5516 | |
| 5517 | if (0 > status) |
| 5518 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5519 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5520 | __func__); |
| 5521 | return status; |
| 5522 | } |
| 5523 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5524 | #ifdef WLAN_FEATURE_11W |
| 5525 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5526 | #endif |
| 5527 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5528 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5529 | if (req->ie_len) |
| 5530 | { |
| 5531 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5532 | if ( 0 > status) |
| 5533 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5534 | 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] | 5535 | __func__); |
| 5536 | return status; |
| 5537 | } |
| 5538 | } |
| 5539 | |
| 5540 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5541 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5542 | { |
| 5543 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5544 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5545 | ) |
| 5546 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5547 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5548 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5549 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5550 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5551 | __func__); |
| 5552 | return -EOPNOTSUPP; |
| 5553 | } |
| 5554 | else |
| 5555 | { |
| 5556 | u8 key_len = req->key_len; |
| 5557 | u8 key_idx = req->key_idx; |
| 5558 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5559 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5560 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5561 | ) |
| 5562 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5563 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5564 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5565 | __func__, key_idx, key_len); |
| 5566 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5567 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5568 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5569 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5570 | (u8)key_len; |
| 5571 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5572 | } |
| 5573 | } |
| 5574 | } |
| 5575 | } |
| 5576 | |
| 5577 | return status; |
| 5578 | } |
| 5579 | |
| 5580 | /* |
| 5581 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5582 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5583 | * parameters during connect operation. |
| 5584 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5585 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5586 | struct net_device *ndev, |
| 5587 | struct cfg80211_connect_params *req |
| 5588 | ) |
| 5589 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5590 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5591 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5592 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5593 | hdd_context_t *pHddCtx = NULL; |
| 5594 | |
| 5595 | ENTER(); |
| 5596 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5597 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5598 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5599 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5600 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5601 | status = wlan_hdd_validate_context(pHddCtx); |
| 5602 | |
| 5603 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5604 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5605 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5606 | "%s: HDD context is not valid", __func__); |
| 5607 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5608 | } |
| 5609 | |
| 5610 | #ifdef WLAN_BTAMP_FEATURE |
| 5611 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5612 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5613 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5614 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5615 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5616 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5617 | } |
| 5618 | #endif |
| 5619 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5620 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5621 | |
| 5622 | if ( 0 > status) |
| 5623 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5624 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5625 | __func__); |
| 5626 | return status; |
| 5627 | } |
| 5628 | |
| 5629 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5630 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5631 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5632 | (vos_concurrent_sessions_running())) |
| 5633 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5634 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5635 | } |
| 5636 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5637 | if ( req->channel ) |
| 5638 | { |
| 5639 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5640 | req->ssid_len, req->bssid, |
| 5641 | req->channel->hw_value); |
| 5642 | } |
| 5643 | else |
| 5644 | { |
| 5645 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5646 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5647 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5648 | |
| 5649 | if (0 > status) |
| 5650 | { |
| 5651 | //ReEnable BMPS if disabled |
| 5652 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5653 | (NULL != pHddCtx)) |
| 5654 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5655 | if (pHddCtx->hdd_wlan_suspended) |
| 5656 | { |
| 5657 | hdd_set_pwrparams(pHddCtx); |
| 5658 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5659 | //ReEnable Bmps and Imps back |
| 5660 | hdd_enable_bmps_imps(pHddCtx); |
| 5661 | } |
| 5662 | |
| 5663 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5664 | return status; |
| 5665 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5666 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5667 | EXIT(); |
| 5668 | return status; |
| 5669 | } |
| 5670 | |
| 5671 | |
| 5672 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5673 | * FUNCTION: wlan_hdd_disconnect |
| 5674 | * This function is used to issue a disconnect request to SME |
| 5675 | */ |
| 5676 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 5677 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5678 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5679 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5680 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5681 | |
| 5682 | status = wlan_hdd_validate_context(pHddCtx); |
| 5683 | |
| 5684 | if (0 != status) |
| 5685 | { |
| 5686 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5687 | "%s: HDD context is not valid", __func__); |
| 5688 | return status; |
| 5689 | } |
| 5690 | |
| 5691 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5692 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5693 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5694 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5695 | /*issue disconnect*/ |
| 5696 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5697 | pAdapter->sessionId, reason); |
| 5698 | |
| 5699 | if ( 0 != status ) |
| 5700 | { |
| 5701 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5702 | "%s csrRoamDisconnect failure, returned %d \n", |
| 5703 | __func__, (int)status ); |
| 5704 | return -EINVAL; |
| 5705 | } |
| 5706 | wait_for_completion_interruptible_timeout( |
| 5707 | &pAdapter->disconnect_comp_var, |
| 5708 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5709 | /*stop tx queues*/ |
| 5710 | netif_tx_disable(pAdapter->dev); |
| 5711 | netif_carrier_off(pAdapter->dev); |
| 5712 | return status; |
| 5713 | } |
| 5714 | |
| 5715 | |
| 5716 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5717 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5718 | * This function is used to issue a disconnect request to SME |
| 5719 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5720 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5721 | struct net_device *dev, |
| 5722 | u16 reason |
| 5723 | ) |
| 5724 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5725 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5726 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5727 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5728 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5729 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5730 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5731 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5732 | tANI_U8 staIdx; |
| 5733 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5734 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5735 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5736 | |
| 5737 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5738 | __func__,pAdapter->device_mode); |
| 5739 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5740 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5741 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5742 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5743 | status = wlan_hdd_validate_context(pHddCtx); |
| 5744 | |
| 5745 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5746 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5747 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5748 | "%s: HDD context is not valid", __func__); |
| 5749 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5750 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5751 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5752 | if (NULL != pRoamProfile) |
| 5753 | { |
| 5754 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5755 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5756 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5757 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5758 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5759 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5760 | switch(reason) |
| 5761 | { |
| 5762 | case WLAN_REASON_MIC_FAILURE: |
| 5763 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5764 | break; |
| 5765 | |
| 5766 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5767 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5768 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5769 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5770 | break; |
| 5771 | |
| 5772 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5773 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5774 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5775 | break; |
| 5776 | |
| 5777 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5778 | default: |
| 5779 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5780 | break; |
| 5781 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5782 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5783 | pScanInfo = &pHddCtx->scan_info; |
| 5784 | if (pScanInfo->mScanPending) |
| 5785 | { |
| 5786 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 5787 | "Aborting Scan"); |
| 5788 | hdd_abort_mac_scan(pHddCtx); |
| 5789 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5790 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5791 | #ifdef FEATURE_WLAN_TDLS |
| 5792 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5793 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5794 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5795 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5796 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5797 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5798 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5799 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5800 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5801 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5802 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5803 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5804 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5805 | pAdapter->sessionId, |
| 5806 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5807 | } |
| 5808 | } |
| 5809 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5810 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 5811 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5812 | { |
| 5813 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5814 | "%s wlan_hdd_disconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5815 | __func__, (int)status ); |
| 5816 | return -EINVAL; |
| 5817 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5818 | } |
| 5819 | } |
| 5820 | else |
| 5821 | { |
| 5822 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5823 | } |
| 5824 | |
| 5825 | return status; |
| 5826 | } |
| 5827 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5829 | /* |
| 5830 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5831 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5832 | * settings in IBSS mode. |
| 5833 | */ |
| 5834 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5835 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5836 | struct cfg80211_ibss_params *params |
| 5837 | ) |
| 5838 | { |
| 5839 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5840 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5841 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5842 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5843 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5844 | ENTER(); |
| 5845 | |
| 5846 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5847 | |
| 5848 | if (params->ie_len && ( NULL != params->ie) ) |
| 5849 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5850 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5851 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5852 | { |
| 5853 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5854 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5855 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5856 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5858 | tDot11fIEWPA dot11WPAIE; |
| 5859 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5860 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5861 | |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5862 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5863 | params->ie_len, DOT11F_EID_WPA); |
| 5864 | if ( NULL != ie ) |
| 5865 | { |
| 5866 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5867 | // Unpack the WPA IE |
| 5868 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 5869 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 5870 | &ie[2+4], |
| 5871 | ie[1] - 4, |
| 5872 | &dot11WPAIE); |
| 5873 | /*Extract the multicast cipher, the encType for unicast |
| 5874 | cipher for wpa-none is none*/ |
| 5875 | encryptionType = |
| 5876 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 5877 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5878 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5880 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 5881 | |
| 5882 | if (0 > status) |
| 5883 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5884 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5885 | __func__); |
| 5886 | return status; |
| 5887 | } |
| 5888 | } |
| 5889 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5890 | pWextState->roamProfile.AuthType.authType[0] = |
| 5891 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5892 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5893 | |
| 5894 | if (params->privacy) |
| 5895 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5896 | /* Security enabled IBSS, At this time there is no information available |
| 5897 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5898 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5899 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5900 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5901 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5902 | *enable privacy bit in beacons */ |
| 5903 | |
| 5904 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5905 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5906 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5907 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5908 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5909 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 5910 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5911 | return status; |
| 5912 | } |
| 5913 | |
| 5914 | /* |
| 5915 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5916 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5917 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5918 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5919 | struct net_device *dev, |
| 5920 | struct cfg80211_ibss_params *params |
| 5921 | ) |
| 5922 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5923 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5924 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5925 | tCsrRoamProfile *pRoamProfile; |
| 5926 | int status; |
| 5927 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5928 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5929 | |
| 5930 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5931 | |
| 5932 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5933 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5934 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5935 | status = wlan_hdd_validate_context(pHddCtx); |
| 5936 | |
| 5937 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5938 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5939 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5940 | "%s: HDD context is not valid", __func__); |
| 5941 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5942 | } |
| 5943 | |
| 5944 | if (NULL == pWextState) |
| 5945 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5946 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5947 | __func__); |
| 5948 | return -EIO; |
| 5949 | } |
| 5950 | |
| 5951 | pRoamProfile = &pWextState->roamProfile; |
| 5952 | |
| 5953 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 5954 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5955 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5956 | "%s Interface type is not set to IBSS \n", __func__); |
| 5957 | return -EINVAL; |
| 5958 | } |
| 5959 | |
| 5960 | /* Set Channel */ |
| 5961 | if (NULL != params->channel) |
| 5962 | { |
| 5963 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5964 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 5965 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5966 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5967 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5968 | |
| 5969 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5970 | channelNum = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5971 | ieee80211_frequency_to_channel(params->channel->center_freq); |
| 5972 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5973 | |
| 5974 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 5975 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5976 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5977 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 5978 | __func__); |
| 5979 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5980 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5981 | |
| 5982 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5983 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5984 | if (channelNum == validChan[indx]) |
| 5985 | { |
| 5986 | break; |
| 5987 | } |
| 5988 | } |
| 5989 | if (indx >= numChans) |
| 5990 | { |
| 5991 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5992 | __func__, channelNum); |
| 5993 | return -EINVAL; |
| 5994 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5995 | /* Set the Operational Channel */ |
| 5996 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 5997 | channelNum); |
| 5998 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5999 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6000 | pRoamProfile->ChannelInfo.ChannelList = |
| 6001 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6002 | } |
| 6003 | |
| 6004 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6005 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6006 | if (status < 0) |
| 6007 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6008 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6009 | __func__); |
| 6010 | return status; |
| 6011 | } |
| 6012 | |
| 6013 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6014 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6015 | params->ssid_len, params->bssid, |
| 6016 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6017 | |
| 6018 | if (0 > status) |
| 6019 | { |
| 6020 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6021 | return status; |
| 6022 | } |
| 6023 | |
| 6024 | return 0; |
| 6025 | } |
| 6026 | |
| 6027 | /* |
| 6028 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6029 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6030 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6031 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6032 | struct net_device *dev |
| 6033 | ) |
| 6034 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6035 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6036 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6037 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6038 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6039 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6040 | |
| 6041 | ENTER(); |
| 6042 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6043 | status = wlan_hdd_validate_context(pHddCtx); |
| 6044 | |
| 6045 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6046 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6047 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6048 | "%s: HDD context is not valid", __func__); |
| 6049 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6050 | } |
| 6051 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6052 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6053 | if (NULL == pWextState) |
| 6054 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6055 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6056 | __func__); |
| 6057 | return -EIO; |
| 6058 | } |
| 6059 | |
| 6060 | pRoamProfile = &pWextState->roamProfile; |
| 6061 | |
| 6062 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6063 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6064 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6065 | 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] | 6066 | __func__); |
| 6067 | return -EINVAL; |
| 6068 | } |
| 6069 | |
| 6070 | /* Issue Disconnect request */ |
| 6071 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6072 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6073 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6074 | |
| 6075 | return 0; |
| 6076 | } |
| 6077 | |
| 6078 | /* |
| 6079 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6080 | * This function is used to set the phy parameters |
| 6081 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6082 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6083 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6084 | u32 changed) |
| 6085 | { |
| 6086 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6087 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6088 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6089 | |
| 6090 | ENTER(); |
| 6091 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6092 | status = wlan_hdd_validate_context(pHddCtx); |
| 6093 | |
| 6094 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6095 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6096 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6097 | "%s: HDD context is not valid", __func__); |
| 6098 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6099 | } |
| 6100 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6101 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6102 | { |
| 6103 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6104 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6105 | wiphy->rts_threshold; |
| 6106 | |
| 6107 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6108 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6109 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6110 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6111 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6112 | __func__, rts_threshold); |
| 6113 | return -EINVAL; |
| 6114 | } |
| 6115 | |
| 6116 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6117 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6118 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6119 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6120 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6121 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6122 | __func__, rts_threshold); |
| 6123 | return -EIO; |
| 6124 | } |
| 6125 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6126 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6127 | rts_threshold); |
| 6128 | } |
| 6129 | |
| 6130 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6131 | { |
| 6132 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6133 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6134 | wiphy->frag_threshold; |
| 6135 | |
| 6136 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6137 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6138 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6139 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6140 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6141 | frag_threshold); |
| 6142 | return -EINVAL; |
| 6143 | } |
| 6144 | |
| 6145 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6146 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6147 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6148 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6149 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6150 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6151 | __func__, frag_threshold); |
| 6152 | return -EIO; |
| 6153 | } |
| 6154 | |
| 6155 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6156 | frag_threshold); |
| 6157 | } |
| 6158 | |
| 6159 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6160 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6161 | { |
| 6162 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6163 | wiphy->retry_short : |
| 6164 | wiphy->retry_long; |
| 6165 | |
| 6166 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6167 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6168 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6169 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6170 | __func__, retry_value); |
| 6171 | return -EINVAL; |
| 6172 | } |
| 6173 | |
| 6174 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6175 | { |
| 6176 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6177 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6178 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6179 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6180 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6181 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6182 | __func__, retry_value); |
| 6183 | return -EIO; |
| 6184 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6185 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6186 | __func__, retry_value); |
| 6187 | } |
| 6188 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6189 | { |
| 6190 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6191 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6192 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6193 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6194 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6195 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6196 | __func__, retry_value); |
| 6197 | return -EIO; |
| 6198 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6199 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6200 | __func__, retry_value); |
| 6201 | } |
| 6202 | } |
| 6203 | |
| 6204 | return 0; |
| 6205 | } |
| 6206 | |
| 6207 | /* |
| 6208 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6209 | * This function is used to set the txpower |
| 6210 | */ |
| 6211 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 6212 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6213 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6214 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6215 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6216 | #endif |
| 6217 | int dbm) |
| 6218 | { |
| 6219 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6220 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6221 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6222 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6223 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6224 | |
| 6225 | ENTER(); |
| 6226 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6227 | status = wlan_hdd_validate_context(pHddCtx); |
| 6228 | |
| 6229 | if (0 != status) |
| 6230 | { |
| 6231 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6232 | "%s: HDD context is not valid", __func__); |
| 6233 | return status; |
| 6234 | } |
| 6235 | |
| 6236 | hHal = pHddCtx->hHal; |
| 6237 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6238 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6239 | dbm, ccmCfgSetCallback, |
| 6240 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6241 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6242 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6243 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6244 | return -EIO; |
| 6245 | } |
| 6246 | |
| 6247 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6248 | dbm); |
| 6249 | |
| 6250 | switch(type) |
| 6251 | { |
| 6252 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6253 | /* Fall through */ |
| 6254 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6255 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6256 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6257 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6258 | __func__); |
| 6259 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6260 | } |
| 6261 | break; |
| 6262 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6263 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6264 | __func__); |
| 6265 | return -EOPNOTSUPP; |
| 6266 | break; |
| 6267 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6268 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6269 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6270 | return -EIO; |
| 6271 | } |
| 6272 | |
| 6273 | return 0; |
| 6274 | } |
| 6275 | |
| 6276 | /* |
| 6277 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6278 | * This function is used to read the txpower |
| 6279 | */ |
| 6280 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) |
| 6281 | { |
| 6282 | |
| 6283 | hdd_adapter_t *pAdapter; |
| 6284 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
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 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6287 | ENTER(); |
| 6288 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6289 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6290 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6291 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6292 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6293 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6294 | "%s: HDD context is not valid", __func__); |
| 6295 | *dbm = 0; |
| 6296 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6297 | } |
| 6298 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6299 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6300 | if (NULL == pAdapter) |
| 6301 | { |
| 6302 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6303 | return -ENOENT; |
| 6304 | } |
| 6305 | |
| 6306 | wlan_hdd_get_classAstats(pAdapter); |
| 6307 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6308 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6309 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6310 | return 0; |
| 6311 | } |
| 6312 | |
| 6313 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6314 | u8* mac, struct station_info *sinfo) |
| 6315 | { |
| 6316 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6317 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6318 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6319 | tANI_U8 rate_flags; |
| 6320 | |
| 6321 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6322 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6323 | |
| 6324 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6325 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6326 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6327 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6328 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6329 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6330 | tANI_U16 maxRate = 0; |
| 6331 | tANI_U16 myRate; |
| 6332 | tANI_U16 currentRate = 0; |
| 6333 | tANI_U8 maxSpeedMCS = 0; |
| 6334 | tANI_U8 maxMCSIdx = 0; |
| 6335 | tANI_U8 rateFlag = 1; |
| 6336 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6337 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6338 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6339 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6340 | #ifdef WLAN_FEATURE_11AC |
| 6341 | tANI_U32 vht_mcs_map; |
| 6342 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6343 | #endif /* WLAN_FEATURE_11AC */ |
| 6344 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6345 | ENTER(); |
| 6346 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6347 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6348 | (0 == ssidlen)) |
| 6349 | { |
| 6350 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6351 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6352 | /*To keep GUI happy*/ |
| 6353 | return 0; |
| 6354 | } |
| 6355 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6356 | status = wlan_hdd_validate_context(pHddCtx); |
| 6357 | |
| 6358 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6359 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6360 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6361 | "%s: HDD context is not valid", __func__); |
| 6362 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6363 | } |
| 6364 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6365 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6366 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6367 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6368 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6369 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6370 | |
| 6371 | //convert to the UI units of 100kbps |
| 6372 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6373 | |
| 6374 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6375 | 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] | 6376 | sinfo->signal, |
| 6377 | pCfg->reportMaxLinkSpeed, |
| 6378 | myRate, |
| 6379 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6380 | (int) pCfg->linkSpeedRssiMid, |
| 6381 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6382 | (int) rate_flags, |
| 6383 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6384 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6385 | |
| 6386 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6387 | { |
| 6388 | // we do not want to necessarily report the current speed |
| 6389 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6390 | { |
| 6391 | // report the max possible speed |
| 6392 | rssidx = 0; |
| 6393 | } |
| 6394 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6395 | { |
| 6396 | // report the max possible speed with RSSI scaling |
| 6397 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6398 | { |
| 6399 | // report the max possible speed |
| 6400 | rssidx = 0; |
| 6401 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6402 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6403 | { |
| 6404 | // report middle speed |
| 6405 | rssidx = 1; |
| 6406 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6407 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6408 | { |
| 6409 | // report middle speed |
| 6410 | rssidx = 2; |
| 6411 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6412 | else |
| 6413 | { |
| 6414 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6415 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6416 | } |
| 6417 | } |
| 6418 | else |
| 6419 | { |
| 6420 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6421 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6422 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6423 | __func__, pCfg->reportMaxLinkSpeed); |
| 6424 | rssidx = 0; |
| 6425 | } |
| 6426 | |
| 6427 | maxRate = 0; |
| 6428 | |
| 6429 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6430 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6431 | OperationalRates, &ORLeng)) |
| 6432 | { |
| 6433 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6434 | /*To keep GUI happy*/ |
| 6435 | return 0; |
| 6436 | } |
| 6437 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6438 | for (i = 0; i < ORLeng; i++) |
| 6439 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6440 | 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] | 6441 | { |
| 6442 | /* Validate Rate Set */ |
| 6443 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6444 | { |
| 6445 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6446 | break; |
| 6447 | } |
| 6448 | } |
| 6449 | /* Update MAX rate */ |
| 6450 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6451 | } |
| 6452 | |
| 6453 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6454 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6455 | ExtendedRates, &ERLeng)) |
| 6456 | { |
| 6457 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6458 | /*To keep GUI happy*/ |
| 6459 | return 0; |
| 6460 | } |
| 6461 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6462 | for (i = 0; i < ERLeng; i++) |
| 6463 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6464 | 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] | 6465 | { |
| 6466 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6467 | { |
| 6468 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6469 | break; |
| 6470 | } |
| 6471 | } |
| 6472 | /* Update MAX rate */ |
| 6473 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6474 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6475 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6476 | rates or if we are always reporting max speed or if we have |
| 6477 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6478 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6479 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6480 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6481 | MCSRates, &MCSLeng)) |
| 6482 | { |
| 6483 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6484 | /*To keep GUI happy*/ |
| 6485 | return 0; |
| 6486 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6487 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6488 | #ifdef WLAN_FEATURE_11AC |
| 6489 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6490 | 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] | 6491 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6492 | 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] | 6493 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6494 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6495 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6496 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6497 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6498 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6499 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6500 | maxMCSIdx = 7; |
| 6501 | } |
| 6502 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6503 | { |
| 6504 | maxMCSIdx = 8; |
| 6505 | } |
| 6506 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6507 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6508 | //VHT20 is supporting 0~8 |
| 6509 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6510 | maxMCSIdx = 8; |
| 6511 | else |
| 6512 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6513 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6514 | |
| 6515 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6516 | { |
| 6517 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6518 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6519 | } |
| 6520 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6521 | { |
| 6522 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6523 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6524 | } |
| 6525 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6526 | { |
| 6527 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6528 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6529 | } |
| 6530 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6531 | maxSpeedMCS = 1; |
| 6532 | if (currentRate > maxRate) |
| 6533 | { |
| 6534 | maxRate = currentRate; |
| 6535 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6536 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6537 | } |
| 6538 | else |
| 6539 | #endif /* WLAN_FEATURE_11AC */ |
| 6540 | { |
| 6541 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6542 | { |
| 6543 | rateFlag |= 1; |
| 6544 | } |
| 6545 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6546 | { |
| 6547 | rateFlag |= 2; |
| 6548 | } |
| 6549 | |
| 6550 | for (i = 0; i < MCSLeng; i++) |
| 6551 | { |
| 6552 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6553 | for (j = 0; j < temp; j++) |
| 6554 | { |
| 6555 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6556 | { |
| 6557 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6558 | break; |
| 6559 | } |
| 6560 | } |
| 6561 | if ((j < temp) && (currentRate > maxRate)) |
| 6562 | { |
| 6563 | maxRate = currentRate; |
| 6564 | maxSpeedMCS = 1; |
| 6565 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6566 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6567 | } |
| 6568 | } |
| 6569 | } |
| 6570 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6571 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6572 | { |
| 6573 | maxRate = myRate; |
| 6574 | maxSpeedMCS = 1; |
| 6575 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6576 | } |
| 6577 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6578 | // 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] | 6579 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6580 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6581 | { |
| 6582 | maxRate = myRate; |
| 6583 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6584 | { |
| 6585 | maxSpeedMCS = 0; |
| 6586 | } |
| 6587 | else |
| 6588 | { |
| 6589 | maxSpeedMCS = 1; |
| 6590 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6591 | } |
| 6592 | } |
| 6593 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6594 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6595 | { |
| 6596 | sinfo->txrate.legacy = maxRate; |
| 6597 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6598 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6599 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6600 | } |
| 6601 | else |
| 6602 | { |
| 6603 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6604 | #ifdef WLAN_FEATURE_11AC |
| 6605 | sinfo->txrate.nss = 1; |
| 6606 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6607 | { |
| 6608 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6609 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6610 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6611 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6612 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6613 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6614 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6615 | } |
| 6616 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6617 | { |
| 6618 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6619 | } |
| 6620 | #endif /* WLAN_FEATURE_11AC */ |
| 6621 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6622 | { |
| 6623 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6624 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6625 | { |
| 6626 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6627 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6628 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6629 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6630 | { |
| 6631 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6632 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6633 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6634 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6635 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6636 | sinfo->txrate.mcs, |
| 6637 | sinfo->txrate.flags ); |
| 6638 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6639 | } |
| 6640 | } |
| 6641 | else |
| 6642 | { |
| 6643 | // report current rate instead of max rate |
| 6644 | |
| 6645 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6646 | { |
| 6647 | //provide to the UI in units of 100kbps |
| 6648 | sinfo->txrate.legacy = myRate; |
| 6649 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6650 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6651 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6652 | } |
| 6653 | else |
| 6654 | { |
| 6655 | //must be MCS |
| 6656 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6657 | #ifdef WLAN_FEATURE_11AC |
| 6658 | sinfo->txrate.nss = 1; |
| 6659 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6660 | { |
| 6661 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6662 | } |
| 6663 | else |
| 6664 | #endif /* WLAN_FEATURE_11AC */ |
| 6665 | { |
| 6666 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6667 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6668 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6669 | { |
| 6670 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6671 | } |
| 6672 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6673 | { |
| 6674 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6675 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6676 | #ifdef WLAN_FEATURE_11AC |
| 6677 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6678 | { |
| 6679 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6680 | } |
| 6681 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6682 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6683 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6684 | sinfo->txrate.mcs, |
| 6685 | sinfo->txrate.flags ); |
| 6686 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6687 | } |
| 6688 | } |
| 6689 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6690 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6691 | sinfo->tx_packets = |
| 6692 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6693 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6694 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6695 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6696 | |
| 6697 | sinfo->tx_retries = |
| 6698 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6699 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6700 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6701 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6702 | |
| 6703 | sinfo->tx_failed = |
| 6704 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6705 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6706 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6707 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6708 | |
| 6709 | sinfo->filled |= |
| 6710 | STATION_INFO_TX_PACKETS | |
| 6711 | STATION_INFO_TX_RETRIES | |
| 6712 | STATION_INFO_TX_FAILED; |
| 6713 | |
| 6714 | EXIT(); |
| 6715 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6716 | } |
| 6717 | |
| 6718 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 6719 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6720 | { |
| 6721 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6722 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6723 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6724 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6725 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6726 | ENTER(); |
| 6727 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6728 | if (NULL == pAdapter) |
| 6729 | { |
| 6730 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6731 | return -ENODEV; |
| 6732 | } |
| 6733 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6734 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6735 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6736 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6737 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6738 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6739 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6740 | "%s: HDD context is not valid", __func__); |
| 6741 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6742 | } |
| 6743 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6744 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6745 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6746 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6747 | (eConnectionState_Associated == |
| 6748 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6749 | { |
| 6750 | vos_status = hdd_conf_hostarpoffload(pAdapter, TRUE); |
| 6751 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6752 | { |
| 6753 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6754 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6755 | __func__, vos_status); |
| 6756 | } |
| 6757 | } |
| 6758 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6759 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6760 | *on successful execution of the function call |
| 6761 | *we are oppositely mapped w.r.t mode in the driver |
| 6762 | **/ |
| 6763 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6764 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6765 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6766 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6767 | { |
| 6768 | return -EINVAL; |
| 6769 | } |
| 6770 | return 0; |
| 6771 | } |
| 6772 | |
| 6773 | |
| 6774 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6775 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6776 | struct net_device *netdev, |
| 6777 | u8 key_index) |
| 6778 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6779 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6780 | return 0; |
| 6781 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6782 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6783 | |
| 6784 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6785 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6786 | struct net_device *dev, |
| 6787 | struct ieee80211_txq_params *params) |
| 6788 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6789 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6790 | return 0; |
| 6791 | } |
| 6792 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6793 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6794 | struct ieee80211_txq_params *params) |
| 6795 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6796 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6797 | return 0; |
| 6798 | } |
| 6799 | #endif //LINUX_VERSION_CODE |
| 6800 | |
| 6801 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6802 | struct net_device *dev, u8 *mac) |
| 6803 | { |
| 6804 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6805 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6806 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6807 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6808 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6809 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6810 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6811 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6812 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6813 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6814 | return -EINVAL; |
| 6815 | } |
| 6816 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6817 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6818 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6819 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6820 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6821 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6822 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6823 | "%s: HDD context is not valid", __func__); |
| 6824 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6825 | } |
| 6826 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6827 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6828 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6829 | ) |
| 6830 | { |
| 6831 | if( NULL == mac ) |
| 6832 | { |
| 6833 | v_U16_t i; |
| 6834 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6835 | { |
| 6836 | if(pAdapter->aStaInfo[i].isUsed) |
| 6837 | { |
| 6838 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6839 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6840 | "%s: Delete STA with MAC::" |
| 6841 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6842 | __func__, |
| 6843 | macAddr[0], macAddr[1], macAddr[2], |
| 6844 | macAddr[3], macAddr[4], macAddr[5]); |
| 6845 | hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6846 | } |
| 6847 | } |
| 6848 | } |
| 6849 | else |
| 6850 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6851 | |
| 6852 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6853 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6854 | { |
| 6855 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6856 | "%s: Skip this DEL STA as this is not used::" |
| 6857 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6858 | __func__, |
| 6859 | mac[0], mac[1], mac[2], |
| 6860 | mac[3], mac[4], mac[5]); |
| 6861 | return -ENOENT; |
| 6862 | } |
| 6863 | |
| 6864 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 6865 | { |
| 6866 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6867 | "%s: Skip this DEL STA as deauth is in progress::" |
| 6868 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6869 | __func__, |
| 6870 | mac[0], mac[1], mac[2], |
| 6871 | mac[3], mac[4], mac[5]); |
| 6872 | return -ENOENT; |
| 6873 | } |
| 6874 | |
| 6875 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 6876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6877 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6878 | "%s: Delete STA with MAC::" |
| 6879 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6880 | __func__, |
| 6881 | mac[0], mac[1], mac[2], |
| 6882 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6883 | |
| 6884 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 6885 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6886 | { |
| 6887 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 6888 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6889 | "%s: STA removal failed for ::" |
| 6890 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6891 | __func__, |
| 6892 | mac[0], mac[1], mac[2], |
| 6893 | mac[3], mac[4], mac[5]); |
| 6894 | return -ENOENT; |
| 6895 | } |
| 6896 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6897 | } |
| 6898 | } |
| 6899 | |
| 6900 | EXIT(); |
| 6901 | |
| 6902 | return 0; |
| 6903 | } |
| 6904 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6905 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 6906 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 6907 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6908 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6909 | #ifdef FEATURE_WLAN_TDLS |
| 6910 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6911 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6912 | mask = params->sta_flags_mask; |
| 6913 | |
| 6914 | set = params->sta_flags_set; |
| 6915 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6916 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 6917 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6918 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 6919 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 6920 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6921 | |
| 6922 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 6923 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6924 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6925 | } |
| 6926 | } |
| 6927 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6928 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6929 | } |
| 6930 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6931 | |
| 6932 | #ifdef FEATURE_WLAN_LFR |
| 6933 | 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] | 6934 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6935 | { |
| 6936 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 6937 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6938 | static tANI_U32 i; // HDD Local Cache index |
| 6939 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6940 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6941 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6942 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6943 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6944 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6945 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6946 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6947 | ENTER(); |
| 6948 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6949 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6950 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6951 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6952 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6953 | return -EINVAL; |
| 6954 | } |
| 6955 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6956 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6957 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6958 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6959 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6960 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6961 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6962 | "%s: HDD context is not valid", __func__); |
| 6963 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6964 | } |
| 6965 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6966 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6967 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6968 | |
| 6969 | for (j = 0; j < i; j++) |
| 6970 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6971 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6972 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 6973 | { |
| 6974 | /* BSSID matched previous entry. Overwrite it. */ |
| 6975 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6976 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6977 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6978 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 6979 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6980 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6981 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6982 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6983 | dump_bssid(pmksa->bssid); |
| 6984 | dump_pmkid(halHandle, pmksa->pmkid); |
| 6985 | break; |
| 6986 | } |
| 6987 | } |
| 6988 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 6989 | /* Check we compared all entries,if then take the first slot now */ |
| 6990 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 6991 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6992 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6993 | { |
| 6994 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 6995 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 6996 | pmksa->bssid, ETHER_ADDR_LEN); |
| 6997 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 6998 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6999 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7000 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7001 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7002 | dump_bssid(pmksa->bssid); |
| 7003 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7004 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7005 | // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7006 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7007 | } |
| 7008 | |
| 7009 | |
| 7010 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7011 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7012 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7013 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7014 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7015 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7016 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7017 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7018 | i ); |
| 7019 | return 0; |
| 7020 | } |
| 7021 | |
| 7022 | |
| 7023 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 7024 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7025 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7026 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7027 | // TODO: Implement this later. |
| 7028 | return 0; |
| 7029 | } |
| 7030 | |
| 7031 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 7032 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7033 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7034 | // TODO: Implement this later. |
| 7035 | return 0; |
| 7036 | } |
| 7037 | #endif |
| 7038 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7039 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7040 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7041 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 7042 | { |
| 7043 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7044 | hdd_station_ctx_t *pHddStaCtx; |
| 7045 | |
| 7046 | if (NULL == pAdapter) |
| 7047 | { |
| 7048 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 7049 | return -ENODEV; |
| 7050 | } |
| 7051 | |
| 7052 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7053 | |
| 7054 | // Added for debug on reception of Re-assoc Req. |
| 7055 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 7056 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7057 | hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"), |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7058 | ftie->ie_len); |
| 7059 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 7060 | } |
| 7061 | |
| 7062 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7063 | hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7064 | ftie->ie_len); |
| 7065 | #endif |
| 7066 | |
| 7067 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7068 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 7069 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7070 | ftie->ie_len); |
| 7071 | return 0; |
| 7072 | } |
| 7073 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7074 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7075 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7076 | |
| 7077 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 7078 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7079 | { |
| 7080 | int ret; |
| 7081 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 7082 | hdd_context_t *pHddCtx; |
| 7083 | |
| 7084 | if (NULL == pAdapter) |
| 7085 | { |
| 7086 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7087 | "%s: HDD adapter is Null", __func__); |
| 7088 | return ; |
| 7089 | } |
| 7090 | |
| 7091 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7092 | if (NULL == pHddCtx) |
| 7093 | { |
| 7094 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7095 | "%s: HDD context is Null!!!", __func__); |
| 7096 | return ; |
| 7097 | } |
| 7098 | |
| 7099 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7100 | |
| 7101 | if (0 > ret) |
| 7102 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7103 | |
| 7104 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
| 7105 | } |
| 7106 | |
| 7107 | /* |
| 7108 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7109 | * NL interface to enable PNO |
| 7110 | */ |
| 7111 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7112 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7113 | { |
| 7114 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7115 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7116 | hdd_context_t *pHddCtx; |
| 7117 | tHalHandle hHal; |
| 7118 | v_U32_t i, indx, num_ch; |
| 7119 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7120 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7121 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7122 | eHalStatus status = eHAL_STATUS_FAILURE; |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7123 | int result; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7124 | |
| 7125 | if (NULL == pAdapter) |
| 7126 | { |
| 7127 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7128 | "%s: HDD adapter is Null", __func__); |
| 7129 | return -ENODEV; |
| 7130 | } |
| 7131 | |
| 7132 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7133 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7134 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7135 | if (0 != result) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7136 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7137 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7138 | "%s: HDD context is not valid", __func__); |
| 7139 | return result; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7140 | } |
| 7141 | |
| 7142 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7143 | if (NULL == hHal) |
| 7144 | { |
| 7145 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7146 | "%s: HAL context is Null!!!", __func__); |
| 7147 | return -EAGAIN; |
| 7148 | } |
| 7149 | |
| 7150 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7151 | if (NULL == pPnoRequest) |
| 7152 | { |
| 7153 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7154 | "%s: vos_mem_malloc failed", __func__); |
| 7155 | return -ENODEV; |
| 7156 | } |
| 7157 | |
| 7158 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 7159 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 7160 | |
| 7161 | if (( !pPnoRequest->ucNetworksCount ) || |
| 7162 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 7163 | { |
| 7164 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7165 | "Network input is not correct"); |
| 7166 | goto error; |
| 7167 | } |
| 7168 | |
| 7169 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 7170 | { |
| 7171 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7172 | "Incorrect number of channels"); |
| 7173 | goto error; |
| 7174 | } |
| 7175 | |
| 7176 | /* Framework provides one set of channels(all) |
| 7177 | * common for all saved profile */ |
| 7178 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 7179 | channels_allowed, &num_channels_allowed)) |
| 7180 | { |
| 7181 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7182 | "%s: failed to get valid channel list", __func__); |
| 7183 | goto error; |
| 7184 | } |
| 7185 | /* Checking each channel against allowed channel list */ |
| 7186 | num_ch = 0; |
| 7187 | for (i = 0; i < request->n_channels; i++) |
| 7188 | { |
| 7189 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 7190 | { |
| 7191 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 7192 | { |
| 7193 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 7194 | break ; |
| 7195 | } |
| 7196 | } |
| 7197 | } |
| 7198 | |
| 7199 | /* Filling per profile params */ |
| 7200 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 7201 | { |
| 7202 | pPnoRequest->aNetworks[i].ssId.length = |
| 7203 | request->match_sets[i].ssid.ssid_len; |
| 7204 | |
| 7205 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 7206 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 7207 | { |
| 7208 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7209 | "SSID Len %d is not correct for network %d", |
| 7210 | pPnoRequest->aNetworks[i].ssId.length, i); |
| 7211 | goto error; |
| 7212 | } |
| 7213 | |
| 7214 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 7215 | request->match_sets[i].ssid.ssid, |
| 7216 | request->match_sets[i].ssid.ssid_len); |
| 7217 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 7218 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 7219 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 7220 | |
| 7221 | /*Copying list of valid channel into request */ |
| 7222 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 7223 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 7224 | |
| 7225 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 7226 | } |
| 7227 | |
| 7228 | /* framework provides interval in ms */ |
| 7229 | pPnoRequest->scanTimers.ucScanTimersCount = 1; |
| 7230 | pPnoRequest->scanTimers.aTimerValues[0].uTimerValue = |
| 7231 | (request->interval)/1000; |
| 7232 | pPnoRequest->scanTimers.aTimerValues[0].uTimerRepeat = 0; |
| 7233 | pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND; |
| 7234 | |
| 7235 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7236 | pPnoRequest, pAdapter->sessionId, |
| 7237 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 7238 | if (eHAL_STATUS_SUCCESS != status) |
| 7239 | { |
| 7240 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7241 | "Failed to enable PNO"); |
| 7242 | goto error; |
| 7243 | } |
| 7244 | |
| 7245 | error: |
| 7246 | vos_mem_free(pPnoRequest); |
| 7247 | return status; |
| 7248 | } |
| 7249 | |
| 7250 | /* |
| 7251 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 7252 | * NL interface to disable PNO |
| 7253 | */ |
| 7254 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 7255 | struct net_device *dev) |
| 7256 | { |
| 7257 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7258 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7259 | hdd_context_t *pHddCtx; |
| 7260 | tHalHandle hHal; |
| 7261 | tpSirPNOScanReq pPnoRequest = NULL; |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7262 | int result; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7263 | |
| 7264 | ENTER(); |
| 7265 | |
| 7266 | if (NULL == pAdapter) |
| 7267 | { |
| 7268 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7269 | "%s: HDD adapter is Null", __func__); |
| 7270 | return -ENODEV; |
| 7271 | } |
| 7272 | |
| 7273 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7274 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7275 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7276 | if (0 != result) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7277 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7278 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7279 | "%s: HDD context is not valid", __func__); |
| 7280 | return result; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7281 | } |
| 7282 | |
| 7283 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7284 | if (NULL == hHal) |
| 7285 | { |
| 7286 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7287 | "%s: HAL context is Null!!!", __func__); |
| 7288 | return -EAGAIN; |
| 7289 | } |
| 7290 | |
| 7291 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7292 | if (NULL == pPnoRequest) |
| 7293 | { |
| 7294 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7295 | "%s: vos_mem_malloc failed", __func__); |
| 7296 | return -ENODEV; |
| 7297 | } |
| 7298 | |
| 7299 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 7300 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 7301 | pPnoRequest->ucNetworksCount = 0; |
| 7302 | |
| 7303 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 7304 | pAdapter->sessionId, |
| 7305 | NULL, pAdapter); |
| 7306 | if (eHAL_STATUS_SUCCESS != status) |
| 7307 | { |
| 7308 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7309 | "Failed to disabled PNO"); |
| 7310 | } |
| 7311 | |
| 7312 | vos_mem_free(pPnoRequest); |
| 7313 | |
| 7314 | EXIT(); |
| 7315 | return status; |
| 7316 | } |
| 7317 | |
| 7318 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 7319 | |
| 7320 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7321 | #ifdef FEATURE_WLAN_TDLS |
| 7322 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 7323 | u8 *peer, u8 action_code, u8 dialog_token, |
| 7324 | u16 status_code, const u8 *buf, size_t len) |
| 7325 | { |
| 7326 | |
| 7327 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7328 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7329 | u8 peerMac[6]; |
| 7330 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7331 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7332 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7333 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7334 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7335 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7336 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7337 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7338 | "Invalid arguments"); |
| 7339 | return -EINVAL; |
| 7340 | } |
| 7341 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7342 | if (pHddCtx->isLogpInProgress) |
| 7343 | { |
| 7344 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7345 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7346 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7347 | return -EBUSY; |
| 7348 | } |
| 7349 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7350 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7351 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7352 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7353 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7354 | MAC_ADDRESS_STR " action %d declined.", |
| 7355 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7356 | return -ENOTSUPP; |
| 7357 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7358 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7359 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 7360 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 7361 | { |
| 7362 | /* if tdls_mode is disabled to respond to peer's request */ |
| 7363 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 7364 | { |
| 7365 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7366 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7367 | " TDLS mode is disabled. action %d declined.", |
| 7368 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7369 | |
| 7370 | return -ENOTSUPP; |
| 7371 | } |
| 7372 | } |
| 7373 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7374 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 7375 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 7376 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7377 | { |
| 7378 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7379 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7380 | " TDLS setup is ongoing. action %d declined.", |
| 7381 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7382 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7383 | } |
| 7384 | } |
| 7385 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7386 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 7387 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7388 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7389 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7390 | { |
| 7391 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 7392 | we return error code at 'add_station()'. Hence we have this |
| 7393 | check again in addtion to add_station(). |
| 7394 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7395 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7396 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7397 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7398 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7399 | " TDLS Max peer already connected. action %d declined.", |
| 7400 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7401 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7402 | } |
| 7403 | else |
| 7404 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7405 | /* maximum reached. tweak to send error code to peer and return |
| 7406 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7407 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7408 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7409 | "%s: " MAC_ADDRESS_STR |
| 7410 | " TDLS Max peer already connected send response status %d", |
| 7411 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7412 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7413 | /* fall through to send setup resp with failure status |
| 7414 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7415 | } |
| 7416 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7417 | else |
| 7418 | { |
| 7419 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7420 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7421 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7422 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7423 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7424 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 7425 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7426 | return -EPERM; |
| 7427 | } |
| 7428 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7429 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7430 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7431 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7432 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7433 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7434 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 7435 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 7436 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7437 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7438 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7439 | /*Except teardown responder will not be used so just make 0*/ |
| 7440 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7441 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7442 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7443 | |
| 7444 | hddTdlsPeer_t *pTdlsPeer; |
| 7445 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 7446 | |
| 7447 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 7448 | responder = pTdlsPeer->is_responder; |
| 7449 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7450 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7451 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7452 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 7453 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 7454 | dialog_token, status_code, len); |
| 7455 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7456 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7457 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7458 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7459 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
| 7460 | (SIR_MAC_TDLS_DIS_RSP == action_code)) |
| 7461 | { |
| 7462 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 7463 | { |
| 7464 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7465 | "%s: Sending Disc/Setup Rsp Frame.Disable BMPS", __func__); |
| 7466 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7467 | } |
| 7468 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
| 7469 | } |
| 7470 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7471 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7472 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7473 | { |
| 7474 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7475 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7476 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7477 | return -EBUSY; |
| 7478 | } |
| 7479 | |
| 7480 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7481 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7482 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7483 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7484 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7485 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7486 | if (VOS_STATUS_SUCCESS != status) |
| 7487 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7488 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7489 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7490 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7491 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7492 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7493 | } |
| 7494 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7495 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7496 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7497 | |
| 7498 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7499 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7500 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7501 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7502 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7503 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7504 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7505 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7506 | } |
| 7507 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7508 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7509 | { |
| 7510 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7511 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7512 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7513 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7514 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7515 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7516 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7517 | } |
| 7518 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7519 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7520 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7521 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7522 | |
| 7523 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7524 | error: |
| 7525 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7526 | because we already know that this transaction will be failed, |
| 7527 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7528 | to be safe, do not change the state mahine. |
| 7529 | */ |
| 7530 | if(max_sta_failed == 0 && |
| 7531 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7532 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7533 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7534 | } |
| 7535 | |
| 7536 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7537 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7538 | { |
| 7539 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7540 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7541 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7542 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7543 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7544 | tANI_U8 staIdx; |
| 7545 | #endif |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7546 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7547 | const char *tdls_oper_str[]= { |
| 7548 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7549 | "NL80211_TDLS_SETUP", |
| 7550 | "NL80211_TDLS_TEARDOWN", |
| 7551 | "NL80211_TDLS_ENABLE_LINK", |
| 7552 | "NL80211_TDLS_DISABLE_LINK", |
Gopichand Nakkala | 29d0019 | 2013-06-20 19:03:52 +0530 | [diff] [blame] | 7553 | "NL80211_TDLS_UNKNOWN_OPER"}; |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7554 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7555 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7556 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7557 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7558 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7559 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7560 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7561 | return -EINVAL; |
| 7562 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7563 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7564 | status = wlan_hdd_validate_context(pHddCtx); |
| 7565 | |
| 7566 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7567 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7568 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7569 | "%s: HDD context is not valid", __func__); |
| 7570 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7571 | } |
| 7572 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7573 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7574 | |
| 7575 | if ( NULL == pTdlsPeer ) { |
| 7576 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7577 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7578 | return -EINVAL; |
| 7579 | } |
| 7580 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7581 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7582 | if((int)oper > 4) |
| 7583 | oper = 5; |
| 7584 | |
| 7585 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7586 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7587 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7588 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7589 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7590 | |
| 7591 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7592 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7593 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7594 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7595 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7596 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7597 | return -ENOTSUPP; |
| 7598 | } |
| 7599 | |
| 7600 | switch (oper) { |
| 7601 | case NL80211_TDLS_ENABLE_LINK: |
| 7602 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7603 | VOS_STATUS status; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7604 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7605 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7606 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7607 | { |
| 7608 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7609 | MAC_ADDRESS_STR " failed", |
| 7610 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7611 | return -EINVAL; |
| 7612 | } |
| 7613 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7614 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7615 | { |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7616 | if (0 != wlan_hdd_tdls_get_link_establish_params(pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 7617 | return -EINVAL; |
| 7618 | } |
| 7619 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
| 7620 | |
| 7621 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7622 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 7623 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 7624 | * register with the TL on after the response for this operation |
| 7625 | * is received . |
| 7626 | */ |
| 7627 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_link_establish_req_comp, |
| 7628 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 7629 | if (status <= 0) |
| 7630 | { |
| 7631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7632 | "%s: Link Establish Request Faled Status %ld", |
| 7633 | __func__, status); |
| 7634 | return -EINVAL; |
| 7635 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7636 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 7637 | /* Mark TDLS client Authenticated .*/ |
| 7638 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 7639 | pTdlsPeer->staId, |
| 7640 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7641 | if (VOS_STATUS_SUCCESS == status) |
| 7642 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7643 | if (pTdlsPeer->is_responder == 0) |
| 7644 | { |
| 7645 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7646 | |
| 7647 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7648 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7649 | WAIT_TIME_TDLS_INITIATOR); |
| 7650 | /* suspend initiator TX until it receives direct packet from the |
| 7651 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7652 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7653 | &staId, NULL); |
| 7654 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7655 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7656 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7657 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7658 | |
| 7659 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
| 7660 | if ( TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta && |
| 7661 | pHddCtx->cfg_ini->fTDLSUapsdMask & HDD_AC_VO ) |
| 7662 | { |
| 7663 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7664 | pTdlsPeer->staId, |
| 7665 | WLANTL_AC_VO, |
| 7666 | 7, |
| 7667 | 7, |
| 7668 | 0, |
| 7669 | 0, |
| 7670 | WLANTL_BI_DIR ); |
| 7671 | |
| 7672 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status )); |
| 7673 | } |
| 7674 | |
| 7675 | if ( TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta && |
| 7676 | pHddCtx->cfg_ini->fTDLSUapsdMask & HDD_AC_VI ) |
| 7677 | { |
| 7678 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7679 | pTdlsPeer->staId, |
| 7680 | WLANTL_AC_VI, |
| 7681 | 5, |
| 7682 | 5, |
| 7683 | 0, |
| 7684 | 0, |
| 7685 | WLANTL_BI_DIR ); |
| 7686 | |
| 7687 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status )); |
| 7688 | } |
| 7689 | |
| 7690 | if ( TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta && |
| 7691 | pHddCtx->cfg_ini->fTDLSUapsdMask & HDD_AC_BK ) |
| 7692 | { |
| 7693 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7694 | pTdlsPeer->staId, |
| 7695 | WLANTL_AC_BK, |
| 7696 | 2, |
| 7697 | 2, |
| 7698 | 0, |
| 7699 | 0, |
| 7700 | WLANTL_BI_DIR ); |
| 7701 | |
| 7702 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status )); |
| 7703 | } |
| 7704 | |
| 7705 | if ( TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta && |
| 7706 | pHddCtx->cfg_ini->fTDLSUapsdMask & HDD_AC_BE ) |
| 7707 | { |
| 7708 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7709 | pTdlsPeer->staId, |
| 7710 | WLANTL_AC_BE, |
| 7711 | 3, |
| 7712 | 3, |
| 7713 | 0, |
| 7714 | 0, |
| 7715 | WLANTL_BI_DIR ); |
| 7716 | |
| 7717 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status )); |
| 7718 | } |
| 7719 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7720 | } |
| 7721 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7722 | } |
| 7723 | break; |
| 7724 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7725 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7726 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7727 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7728 | long status; |
| 7729 | |
| 7730 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7731 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7732 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7733 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7734 | |
| 7735 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7736 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7737 | if (status <= 0) |
| 7738 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7739 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7740 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7741 | "%s: Del station failed status %ld", |
| 7742 | __func__, status); |
| 7743 | return -EPERM; |
| 7744 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7745 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7746 | } |
| 7747 | else |
| 7748 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7749 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7750 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7751 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7752 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7753 | if (pHddTdlsCtx->defer_link_lost_indication) |
| 7754 | { |
| 7755 | if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) && |
| 7756 | (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0)) |
| 7757 | { |
| 7758 | status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7759 | if ( 0 != status) |
| 7760 | { |
| 7761 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7762 | "%s wlan_hdd_disconnect failure, returned %d \n", |
| 7763 | __func__, (int)status ); |
| 7764 | return -EINVAL; |
| 7765 | } |
| 7766 | } |
| 7767 | } |
| 7768 | #endif |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7769 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7770 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7771 | case NL80211_TDLS_TEARDOWN: |
| 7772 | case NL80211_TDLS_SETUP: |
| 7773 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7774 | /* We don't support in-driver setup/teardown/discovery */ |
| 7775 | return -ENOTSUPP; |
| 7776 | default: |
| 7777 | return -ENOTSUPP; |
| 7778 | } |
| 7779 | return 0; |
| 7780 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7781 | |
| 7782 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7783 | struct net_device *dev, u8 *peer) |
| 7784 | { |
| 7785 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7786 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7787 | |
| 7788 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7789 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7790 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7791 | #endif |
| 7792 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7793 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7794 | /* |
| 7795 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7796 | * Callback rountine called upon receiving response for |
| 7797 | * get offload info |
| 7798 | */ |
| 7799 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7800 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7801 | { |
| 7802 | |
| 7803 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7804 | tANI_U8 tempReplayCounter[8]; |
| 7805 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7806 | |
| 7807 | ENTER(); |
| 7808 | |
| 7809 | if (NULL == pAdapter) |
| 7810 | { |
| 7811 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7812 | "%s: HDD adapter is Null", __func__); |
| 7813 | return ; |
| 7814 | } |
| 7815 | |
| 7816 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7817 | { |
| 7818 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7819 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7820 | return ; |
| 7821 | } |
| 7822 | |
| 7823 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7824 | { |
| 7825 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7826 | "%s: wlan Failed to get replay counter value", |
| 7827 | __func__); |
| 7828 | return ; |
| 7829 | } |
| 7830 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7831 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7832 | /* Update replay counter */ |
| 7833 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 7834 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7835 | |
| 7836 | { |
| 7837 | /* changing from little to big endian since supplicant |
| 7838 | * works on big endian format |
| 7839 | */ |
| 7840 | int i; |
| 7841 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7842 | |
| 7843 | for (i = 0; i < 8; i++) |
| 7844 | { |
| 7845 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 7846 | } |
| 7847 | } |
| 7848 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7849 | /* Update replay counter to NL */ |
| 7850 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7851 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7852 | } |
| 7853 | |
| 7854 | /* |
| 7855 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 7856 | * This function is used to offload GTK rekeying job to the firmware. |
| 7857 | */ |
| 7858 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 7859 | struct cfg80211_gtk_rekey_data *data) |
| 7860 | { |
| 7861 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7862 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 7863 | hdd_station_ctx_t *pHddStaCtx; |
| 7864 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7865 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7866 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7867 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7868 | |
| 7869 | ENTER(); |
| 7870 | |
| 7871 | if (NULL == pAdapter) |
| 7872 | { |
| 7873 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7874 | "%s: HDD adapter is Null", __func__); |
| 7875 | return -ENODEV; |
| 7876 | } |
| 7877 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7878 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7879 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7880 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7881 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7882 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7883 | "%s: HDD context is not valid", __func__); |
| 7884 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7885 | } |
| 7886 | |
| 7887 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7888 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7889 | if (NULL == hHal) |
| 7890 | { |
| 7891 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7892 | "%s: HAL context is Null!!!", __func__); |
| 7893 | return -EAGAIN; |
| 7894 | } |
| 7895 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7896 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 7897 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 7898 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 7899 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7900 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7901 | { |
| 7902 | /* changing from big to little endian since driver |
| 7903 | * works on little endian format |
| 7904 | */ |
| 7905 | tANI_U8 *p = |
| 7906 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 7907 | int i; |
| 7908 | |
| 7909 | for (i = 0; i < 8; i++) |
| 7910 | { |
| 7911 | p[7-i] = data->replay_ctr[i]; |
| 7912 | } |
| 7913 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7914 | |
| 7915 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 7916 | { |
| 7917 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7918 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 7919 | sizeof (tSirGtkOffloadParams)); |
| 7920 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7921 | pAdapter->sessionId); |
| 7922 | |
| 7923 | if (eHAL_STATUS_SUCCESS != status) |
| 7924 | { |
| 7925 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7926 | "%s: sme_SetGTKOffload failed, returned %d", |
| 7927 | __func__, status); |
| 7928 | return status; |
| 7929 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7930 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7931 | "%s: sme_SetGTKOffload successfull", __func__); |
| 7932 | } |
| 7933 | else |
| 7934 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7935 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7936 | "%s: wlan not suspended GTKOffload request is stored", |
| 7937 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7938 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7939 | |
| 7940 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7941 | } |
| 7942 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 7943 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7944 | /* |
| 7945 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 7946 | * This function is used to set access control policy |
| 7947 | */ |
| 7948 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 7949 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 7950 | { |
| 7951 | int i; |
| 7952 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7953 | hdd_hostapd_state_t *pHostapdState; |
| 7954 | tsap_Config_t *pConfig; |
| 7955 | v_CONTEXT_t pVosContext = NULL; |
| 7956 | hdd_context_t *pHddCtx; |
| 7957 | int status; |
| 7958 | |
| 7959 | ENTER(); |
| 7960 | |
| 7961 | if (NULL == pAdapter) |
| 7962 | { |
| 7963 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7964 | "%s: HDD adapter is Null", __func__); |
| 7965 | return -ENODEV; |
| 7966 | } |
| 7967 | |
| 7968 | if (NULL == params) |
| 7969 | { |
| 7970 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7971 | "%s: params is Null", __func__); |
| 7972 | return -EINVAL; |
| 7973 | } |
| 7974 | |
| 7975 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7976 | status = wlan_hdd_validate_context(pHddCtx); |
| 7977 | |
| 7978 | if (0 != status) |
| 7979 | { |
| 7980 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7981 | "%s: HDD context is not valid", __func__); |
| 7982 | return status; |
| 7983 | } |
| 7984 | |
| 7985 | pVosContext = pHddCtx->pvosContext; |
| 7986 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7987 | |
| 7988 | if (NULL == pHostapdState) |
| 7989 | { |
| 7990 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7991 | "%s: pHostapdState is Null", __func__); |
| 7992 | return -EINVAL; |
| 7993 | } |
| 7994 | |
| 7995 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 7996 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 7997 | |
| 7998 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 7999 | { |
| 8000 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 8001 | |
| 8002 | /* default value */ |
| 8003 | pConfig->num_accept_mac = 0; |
| 8004 | pConfig->num_deny_mac = 0; |
| 8005 | |
| 8006 | /** |
| 8007 | * access control policy |
| 8008 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 8009 | * listed in hostapd.deny file. |
| 8010 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 8011 | * listed in hostapd.accept file. |
| 8012 | */ |
| 8013 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 8014 | { |
| 8015 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 8016 | } |
| 8017 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 8018 | { |
| 8019 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 8020 | } |
| 8021 | else |
| 8022 | { |
| 8023 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8024 | "%s:Acl Policy : %d is not supported", |
| 8025 | __func__, params->acl_policy); |
| 8026 | return -ENOTSUPP; |
| 8027 | } |
| 8028 | |
| 8029 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 8030 | { |
| 8031 | pConfig->num_accept_mac = params->n_acl_entries; |
| 8032 | for (i = 0; i < params->n_acl_entries; i++) |
| 8033 | { |
| 8034 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8035 | "** Add ACL MAC entry %i in WhiletList :" |
| 8036 | MAC_ADDRESS_STR, i, |
| 8037 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8038 | |
| 8039 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 8040 | sizeof(qcmacaddr)); |
| 8041 | } |
| 8042 | } |
| 8043 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 8044 | { |
| 8045 | pConfig->num_deny_mac = params->n_acl_entries; |
| 8046 | for (i = 0; i < params->n_acl_entries; i++) |
| 8047 | { |
| 8048 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8049 | "** Add ACL MAC entry %i in BlackList :" |
| 8050 | MAC_ADDRESS_STR, i, |
| 8051 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8052 | |
| 8053 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 8054 | sizeof(qcmacaddr)); |
| 8055 | } |
| 8056 | } |
| 8057 | |
| 8058 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 8059 | { |
| 8060 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8061 | "%s: SAP Set Mac Acl fail", __func__); |
| 8062 | return -EINVAL; |
| 8063 | } |
| 8064 | } |
| 8065 | else |
| 8066 | { |
| 8067 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8068 | "%s: Invalid device_mode = %d", |
| 8069 | __func__, pAdapter->device_mode); |
| 8070 | return -EINVAL; |
| 8071 | } |
| 8072 | |
| 8073 | return 0; |
| 8074 | } |
| 8075 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8076 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8077 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8078 | { |
| 8079 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 8080 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 8081 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 8082 | .change_station = wlan_hdd_change_station, |
| 8083 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 8084 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 8085 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 8086 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8087 | #else |
| 8088 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 8089 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 8090 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8091 | #endif |
| 8092 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 8093 | .add_key = wlan_hdd_cfg80211_add_key, |
| 8094 | .get_key = wlan_hdd_cfg80211_get_key, |
| 8095 | .del_key = wlan_hdd_cfg80211_del_key, |
| 8096 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8097 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8098 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8099 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8100 | .scan = wlan_hdd_cfg80211_scan, |
| 8101 | .connect = wlan_hdd_cfg80211_connect, |
| 8102 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 8103 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 8104 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 8105 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 8106 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 8107 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8108 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 8109 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 8110 | .mgmt_tx = wlan_hdd_action, |
| 8111 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 8112 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 8113 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 8114 | .set_txq_params = wlan_hdd_set_txq_params, |
| 8115 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8116 | .get_station = wlan_hdd_cfg80211_get_station, |
| 8117 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 8118 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8119 | .add_station = wlan_hdd_cfg80211_add_station, |
| 8120 | #ifdef FEATURE_WLAN_LFR |
| 8121 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 8122 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 8123 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 8124 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8125 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 8126 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 8127 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8128 | #ifdef FEATURE_WLAN_TDLS |
| 8129 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 8130 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 8131 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8132 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8133 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 8134 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8135 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8136 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 8137 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 8138 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8139 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8140 | }; |
| 8141 | |