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" |
| 86 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 87 | #include "wlan_nv.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 88 | |
| 89 | #define g_mode_rates_size (12) |
| 90 | #define a_mode_rates_size (8) |
| 91 | #define FREQ_BASE_80211G (2407) |
| 92 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 93 | #define MAX_SCAN_SSID 9 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 94 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 95 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 96 | |
| 97 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 98 | .band = IEEE80211_BAND_2GHZ, \ |
| 99 | .center_freq = (freq), \ |
| 100 | .hw_value = (chan),\ |
| 101 | .flags = (flag), \ |
| 102 | .max_antenna_gain = 0 ,\ |
| 103 | .max_power = 30, \ |
| 104 | } |
| 105 | |
| 106 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 107 | .band = IEEE80211_BAND_5GHZ, \ |
| 108 | .center_freq = (freq), \ |
| 109 | .hw_value = (chan),\ |
| 110 | .flags = (flag), \ |
| 111 | .max_antenna_gain = 0 ,\ |
| 112 | .max_power = 30, \ |
| 113 | } |
| 114 | |
| 115 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 116 | {\ |
| 117 | .bitrate = rate, \ |
| 118 | .hw_value = rate_id, \ |
| 119 | .flags = flag, \ |
| 120 | } |
| 121 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 122 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 123 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 124 | #else |
| 125 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 126 | #endif |
| 127 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 128 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 129 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 130 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 131 | #endif |
| 132 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 133 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 134 | { |
| 135 | WLAN_CIPHER_SUITE_WEP40, |
| 136 | WLAN_CIPHER_SUITE_WEP104, |
| 137 | WLAN_CIPHER_SUITE_TKIP, |
| 138 | #ifdef FEATURE_WLAN_CCX |
| 139 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 140 | WLAN_CIPHER_SUITE_KRK, |
| 141 | WLAN_CIPHER_SUITE_CCMP, |
| 142 | #else |
| 143 | WLAN_CIPHER_SUITE_CCMP, |
| 144 | #endif |
| 145 | #ifdef FEATURE_WLAN_WAPI |
| 146 | WLAN_CIPHER_SUITE_SMS4, |
| 147 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 148 | #ifdef WLAN_FEATURE_11W |
| 149 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 150 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 154 | { |
| 155 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 156 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 157 | } |
| 158 | |
| 159 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 160 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 161 | HDD2GHZCHAN(2412, 1, 0) , |
| 162 | HDD2GHZCHAN(2417, 2, 0) , |
| 163 | HDD2GHZCHAN(2422, 3, 0) , |
| 164 | HDD2GHZCHAN(2427, 4, 0) , |
| 165 | HDD2GHZCHAN(2432, 5, 0) , |
| 166 | HDD2GHZCHAN(2437, 6, 0) , |
| 167 | HDD2GHZCHAN(2442, 7, 0) , |
| 168 | HDD2GHZCHAN(2447, 8, 0) , |
| 169 | HDD2GHZCHAN(2452, 9, 0) , |
| 170 | HDD2GHZCHAN(2457, 10, 0) , |
| 171 | HDD2GHZCHAN(2462, 11, 0) , |
| 172 | HDD2GHZCHAN(2467, 12, 0) , |
| 173 | HDD2GHZCHAN(2472, 13, 0) , |
| 174 | HDD2GHZCHAN(2484, 14, 0) , |
| 175 | }; |
| 176 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 177 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 178 | { |
| 179 | HDD2GHZCHAN(2412, 1, 0) , |
| 180 | HDD2GHZCHAN(2437, 6, 0) , |
| 181 | HDD2GHZCHAN(2462, 11, 0) , |
| 182 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 183 | |
| 184 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 185 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 186 | HDD5GHZCHAN(4920, 240, 0) , |
| 187 | HDD5GHZCHAN(4940, 244, 0) , |
| 188 | HDD5GHZCHAN(4960, 248, 0) , |
| 189 | HDD5GHZCHAN(4980, 252, 0) , |
| 190 | HDD5GHZCHAN(5040, 208, 0) , |
| 191 | HDD5GHZCHAN(5060, 212, 0) , |
| 192 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 193 | HDD5GHZCHAN(5180, 36, 0) , |
| 194 | HDD5GHZCHAN(5200, 40, 0) , |
| 195 | HDD5GHZCHAN(5220, 44, 0) , |
| 196 | HDD5GHZCHAN(5240, 48, 0) , |
| 197 | HDD5GHZCHAN(5260, 52, 0) , |
| 198 | HDD5GHZCHAN(5280, 56, 0) , |
| 199 | HDD5GHZCHAN(5300, 60, 0) , |
| 200 | HDD5GHZCHAN(5320, 64, 0) , |
| 201 | HDD5GHZCHAN(5500,100, 0) , |
| 202 | HDD5GHZCHAN(5520,104, 0) , |
| 203 | HDD5GHZCHAN(5540,108, 0) , |
| 204 | HDD5GHZCHAN(5560,112, 0) , |
| 205 | HDD5GHZCHAN(5580,116, 0) , |
| 206 | HDD5GHZCHAN(5600,120, 0) , |
| 207 | HDD5GHZCHAN(5620,124, 0) , |
| 208 | HDD5GHZCHAN(5640,128, 0) , |
| 209 | HDD5GHZCHAN(5660,132, 0) , |
| 210 | HDD5GHZCHAN(5680,136, 0) , |
| 211 | HDD5GHZCHAN(5700,140, 0) , |
| 212 | HDD5GHZCHAN(5745,149, 0) , |
| 213 | HDD5GHZCHAN(5765,153, 0) , |
| 214 | HDD5GHZCHAN(5785,157, 0) , |
| 215 | HDD5GHZCHAN(5805,161, 0) , |
| 216 | HDD5GHZCHAN(5825,165, 0) , |
| 217 | }; |
| 218 | |
| 219 | static struct ieee80211_rate g_mode_rates[] = |
| 220 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 221 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 222 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 223 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 224 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 225 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 226 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 227 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 228 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 229 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 230 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 231 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 232 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 233 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 234 | |
| 235 | static struct ieee80211_rate a_mode_rates[] = |
| 236 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 237 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 238 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 239 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 240 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 241 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 242 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 243 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 244 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 245 | }; |
| 246 | |
| 247 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 248 | { |
| 249 | .channels = hdd_channels_2_4_GHZ, |
| 250 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 251 | .band = IEEE80211_BAND_2GHZ, |
| 252 | .bitrates = g_mode_rates, |
| 253 | .n_bitrates = g_mode_rates_size, |
| 254 | .ht_cap.ht_supported = 1, |
| 255 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 256 | | IEEE80211_HT_CAP_GRN_FLD |
| 257 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 258 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 259 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 260 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 261 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 262 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 263 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 264 | }; |
| 265 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 266 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 267 | { |
| 268 | .channels = hdd_social_channels_2_4_GHZ, |
| 269 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 270 | .band = IEEE80211_BAND_2GHZ, |
| 271 | .bitrates = g_mode_rates, |
| 272 | .n_bitrates = g_mode_rates_size, |
| 273 | .ht_cap.ht_supported = 1, |
| 274 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 275 | | IEEE80211_HT_CAP_GRN_FLD |
| 276 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 277 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 278 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 279 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 280 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 281 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 282 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 283 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 284 | |
| 285 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 286 | { |
| 287 | .channels = hdd_channels_5_GHZ, |
| 288 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 289 | .band = IEEE80211_BAND_5GHZ, |
| 290 | .bitrates = a_mode_rates, |
| 291 | .n_bitrates = a_mode_rates_size, |
| 292 | .ht_cap.ht_supported = 1, |
| 293 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 294 | | IEEE80211_HT_CAP_GRN_FLD |
| 295 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 296 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 297 | | IEEE80211_HT_CAP_SGI_40 |
| 298 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 299 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 300 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 301 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 302 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 303 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 304 | }; |
| 305 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 306 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 307 | TX/RX direction for each kind of interface */ |
| 308 | static const struct ieee80211_txrx_stypes |
| 309 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 310 | [NL80211_IFTYPE_STATION] = { |
| 311 | .tx = 0xffff, |
| 312 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 313 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 314 | }, |
| 315 | [NL80211_IFTYPE_AP] = { |
| 316 | .tx = 0xffff, |
| 317 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 318 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 319 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 320 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 321 | BIT(SIR_MAC_MGMT_AUTH) | |
| 322 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 323 | BIT(SIR_MAC_MGMT_ACTION), |
| 324 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 325 | [NL80211_IFTYPE_ADHOC] = { |
| 326 | .tx = 0xffff, |
| 327 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 328 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 329 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 330 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 331 | BIT(SIR_MAC_MGMT_AUTH) | |
| 332 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 333 | BIT(SIR_MAC_MGMT_ACTION), |
| 334 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 335 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 336 | .tx = 0xffff, |
| 337 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 338 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 339 | }, |
| 340 | [NL80211_IFTYPE_P2P_GO] = { |
| 341 | /* This is also same as for SoftAP */ |
| 342 | .tx = 0xffff, |
| 343 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 344 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 345 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 346 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 347 | BIT(SIR_MAC_MGMT_AUTH) | |
| 348 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 349 | BIT(SIR_MAC_MGMT_ACTION), |
| 350 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 351 | }; |
| 352 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 353 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 354 | static const struct ieee80211_iface_limit |
| 355 | wlan_hdd_iface_limit[] = { |
| 356 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 357 | /* max = 3 ; Our driver create two interfaces during driver init |
| 358 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 359 | * interface until a group is formed. In JB architecture, once the |
| 360 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 361 | * Client. |
| 362 | * When supplicant remove the group, it first issue a set interface |
| 363 | * cmd to change the mode back to Station. In JB this works fine as |
| 364 | * we advertize two station type interface during driver init. |
| 365 | * Some vendors create separate interface for P2P GO/Client, |
| 366 | * after group formation(Third one). But while group remove |
| 367 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 368 | * But as we advertized only two sta type interfaces nl80211 was |
| 369 | * returning error for the third one which was leading to failure in |
| 370 | * delete interface. Ideally while removing the group, supplicant |
| 371 | * should not try to change the 3rd interface mode to Station type. |
| 372 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 373 | * interface type to 3 |
| 374 | */ |
| 375 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 376 | .types = BIT(NL80211_IFTYPE_STATION), |
| 377 | }, |
| 378 | { |
| 379 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 380 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 381 | }, |
| 382 | { |
| 383 | .max = 1, |
| 384 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 385 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 386 | }, |
| 387 | }; |
| 388 | |
| 389 | /* By default, only single channel concurrency is allowed */ |
| 390 | static struct ieee80211_iface_combination |
| 391 | wlan_hdd_iface_combination = { |
| 392 | .limits = wlan_hdd_iface_limit, |
| 393 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 394 | /* |
| 395 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 396 | * and p2p0 interfaces during driver init |
| 397 | * Some vendors create separate interface for P2P operations. |
| 398 | * wlan0: STA interface |
| 399 | * p2p0: P2P Device interface, action frames goes |
| 400 | * through this interface. |
| 401 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 402 | * created for p2p operations(GO/CLIENT interface). |
| 403 | */ |
| 404 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 405 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 406 | .beacon_int_infra_match = false, |
| 407 | }; |
| 408 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 409 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 410 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 411 | |
| 412 | /* Data rate 100KBPS based on IE Index */ |
| 413 | struct index_data_rate_type |
| 414 | { |
| 415 | v_U8_t beacon_rate_index; |
| 416 | v_U16_t supported_rate[4]; |
| 417 | }; |
| 418 | |
| 419 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 420 | The IDX field is the rate index |
| 421 | The HI field is the rate when RSSI is strong or being ignored |
| 422 | (in this case we report actual rate) |
| 423 | The MID field is the rate when RSSI is moderate |
| 424 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 425 | The LO field is the rate when RSSI is low |
| 426 | (in this case we don't report rates, actual current rate used) |
| 427 | */ |
| 428 | static const struct |
| 429 | { |
| 430 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 431 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 432 | } supported_data_rate[] = |
| 433 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 434 | /* IDX HI HM LM LO (RSSI-based index */ |
| 435 | {2, { 10, 10, 10, 0}}, |
| 436 | {4, { 20, 20, 10, 0}}, |
| 437 | {11, { 55, 20, 10, 0}}, |
| 438 | {12, { 60, 55, 20, 0}}, |
| 439 | {18, { 90, 55, 20, 0}}, |
| 440 | {22, {110, 55, 20, 0}}, |
| 441 | {24, {120, 90, 60, 0}}, |
| 442 | {36, {180, 120, 60, 0}}, |
| 443 | {44, {220, 180, 60, 0}}, |
| 444 | {48, {240, 180, 90, 0}}, |
| 445 | {66, {330, 180, 90, 0}}, |
| 446 | {72, {360, 240, 90, 0}}, |
| 447 | {96, {480, 240, 120, 0}}, |
| 448 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 449 | }; |
| 450 | |
| 451 | /* MCS Based rate table */ |
| 452 | static struct index_data_rate_type supported_mcs_rate[] = |
| 453 | { |
| 454 | /* MCS L20 L40 S20 S40 */ |
| 455 | {0, {65, 135, 72, 150}}, |
| 456 | {1, {130, 270, 144, 300}}, |
| 457 | {2, {195, 405, 217, 450}}, |
| 458 | {3, {260, 540, 289, 600}}, |
| 459 | {4, {390, 810, 433, 900}}, |
| 460 | {5, {520, 1080, 578, 1200}}, |
| 461 | {6, {585, 1215, 650, 1350}}, |
| 462 | {7, {650, 1350, 722, 1500}} |
| 463 | }; |
| 464 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 465 | #ifdef WLAN_FEATURE_11AC |
| 466 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 467 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 468 | |
| 469 | struct index_vht_data_rate_type |
| 470 | { |
| 471 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 472 | v_U16_t supported_VHT80_rate[2]; |
| 473 | v_U16_t supported_VHT40_rate[2]; |
| 474 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 475 | }; |
| 476 | |
| 477 | typedef enum |
| 478 | { |
| 479 | DATA_RATE_11AC_MAX_MCS_7, |
| 480 | DATA_RATE_11AC_MAX_MCS_8, |
| 481 | DATA_RATE_11AC_MAX_MCS_9, |
| 482 | DATA_RATE_11AC_MAX_MCS_NA |
| 483 | } eDataRate11ACMaxMcs; |
| 484 | |
| 485 | /* MCS Based VHT rate table */ |
| 486 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 487 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 488 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 489 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 490 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 491 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 492 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 493 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 494 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 495 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 496 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 497 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 498 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 499 | }; |
| 500 | #endif /* WLAN_FEATURE_11AC */ |
| 501 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 502 | extern struct net_device_ops net_ops_struct; |
| 503 | |
| 504 | /* |
| 505 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 506 | * This function is called by hdd_wlan_startup() |
| 507 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 508 | * This function is used to initialize and register wiphy structure. |
| 509 | */ |
| 510 | struct wiphy *wlan_hdd_cfg80211_init(int priv_size) |
| 511 | { |
| 512 | struct wiphy *wiphy; |
| 513 | ENTER(); |
| 514 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 515 | /* |
| 516 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 517 | */ |
| 518 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 519 | |
| 520 | if (!wiphy) |
| 521 | { |
| 522 | /* Print error and jump into err label and free the memory */ |
| 523 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 524 | return NULL; |
| 525 | } |
| 526 | |
| 527 | return wiphy; |
| 528 | } |
| 529 | |
| 530 | /* |
| 531 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 532 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 533 | * private ioctl to change the band value |
| 534 | */ |
| 535 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 536 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 537 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 538 | switch(eBand) |
| 539 | { |
| 540 | case eCSR_BAND_24: |
| 541 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 542 | wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; |
| 543 | break; |
| 544 | case eCSR_BAND_5G: |
Madan Mohan Koyyalamudi | 6f6390c | 2012-09-24 13:57:46 -0700 | [diff] [blame] | 545 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_p2p_2_4_GHZ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 546 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 547 | break; |
| 548 | case eCSR_BAND_ALL: |
| 549 | default: |
| 550 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 551 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 552 | } |
| 553 | return 0; |
| 554 | } |
| 555 | /* |
| 556 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 557 | * This function is called by hdd_wlan_startup() |
| 558 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 559 | * This function is used to initialize and register wiphy structure. |
| 560 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 561 | int wlan_hdd_cfg80211_register(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 562 | struct wiphy *wiphy, |
| 563 | hdd_config_t *pCfg |
| 564 | ) |
| 565 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 566 | ENTER(); |
| 567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 568 | /* Now bind the underlying wlan device with wiphy */ |
| 569 | set_wiphy_dev(wiphy, dev); |
| 570 | |
| 571 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
| 572 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 573 | wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 574 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 575 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 576 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 577 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 578 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 579 | | WIPHY_FLAG_OFFCHAN_TX; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 580 | #endif |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 581 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 582 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 583 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 584 | || pCfg->isFastRoamIniFeatureEnabled |
| 585 | #endif |
| 586 | #ifdef FEATURE_WLAN_CCX |
| 587 | || pCfg->isCcxIniFeatureEnabled |
| 588 | #endif |
| 589 | ) |
| 590 | { |
| 591 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 592 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 593 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 594 | #ifdef FEATURE_WLAN_TDLS |
| 595 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 596 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 597 | #endif |
| 598 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 599 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 600 | driver can still register regulatory callback and |
| 601 | it will get CRDA setting in wiphy->band[], but |
| 602 | driver need to determine what to do with both |
| 603 | regulatory settings */ |
| 604 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 605 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 606 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 607 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 608 | wiphy->max_scan_ie_len = 200 ; //TODO: define a macro |
| 609 | |
| 610 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 611 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 612 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 613 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 614 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 615 | | BIT(NL80211_IFTYPE_AP); |
| 616 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 617 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 618 | if( pCfg->enableMCC ) |
| 619 | { |
| 620 | /* Currently, supports up to two channels */ |
| 621 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 622 | |
| 623 | if( !pCfg->allowMCCGODiffBI ) |
| 624 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 625 | |
| 626 | } |
| 627 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 628 | wiphy->n_iface_combinations = 1; |
| 629 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 630 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 631 | /* Before registering we need to update the ht capabilitied based |
| 632 | * on ini values*/ |
| 633 | if( !pCfg->ShortGI20MhzEnable ) |
| 634 | { |
| 635 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 636 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 637 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 638 | } |
| 639 | |
| 640 | if( !pCfg->ShortGI40MhzEnable ) |
| 641 | { |
| 642 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 643 | } |
| 644 | |
| 645 | if( !pCfg->nChannelBondingMode5GHz ) |
| 646 | { |
| 647 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 648 | } |
| 649 | |
| 650 | /*Initialize band capability*/ |
| 651 | switch(pCfg->nBandCapability) |
| 652 | { |
| 653 | case eCSR_BAND_24: |
| 654 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 655 | break; |
| 656 | case eCSR_BAND_5G: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 657 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_p2p_2_4_GHZ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 658 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 659 | break; |
| 660 | case eCSR_BAND_ALL: |
| 661 | default: |
| 662 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 663 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 664 | } |
| 665 | /*Initialise the supported cipher suite details*/ |
| 666 | wiphy->cipher_suites = hdd_cipher_suites; |
| 667 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 668 | |
| 669 | /*signal strength in mBm (100*dBm) */ |
| 670 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 671 | |
| 672 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 673 | wiphy->max_remain_on_channel_duration = 1000; |
| 674 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 675 | |
| 676 | /* Register our wiphy dev with cfg80211 */ |
| 677 | if (0 > wiphy_register(wiphy)) |
| 678 | { |
| 679 | /* print eror */ |
| 680 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 681 | return -EIO; |
| 682 | } |
| 683 | |
| 684 | EXIT(); |
| 685 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 686 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 687 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 688 | /* In this function we will try to get default country code from crda. |
| 689 | If the gCrdaDefaultCountryCode is configured in ini file, |
| 690 | we will try to call user space crda to get the regulatory settings for |
| 691 | that country. We will timeout if we can't get it from crda. |
| 692 | It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_register. |
| 693 | */ |
| 694 | int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg) |
| 695 | { |
| 696 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 697 | if (memcmp(pCfg->crdaDefaultCountryCode, |
| 698 | CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0) |
| 699 | { |
| 700 | init_completion(&pHddCtx->driver_crda_req); |
| 701 | regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode); |
| 702 | wait_for_completion_interruptible_timeout(&pHddCtx->driver_crda_req, |
| 703 | CRDA_WAIT_TIME); |
Yunsen Wang | e3ba1fb | 2013-04-05 15:04:43 -0700 | [diff] [blame] | 704 | /* if the country is not found from current regulatory.bin, |
| 705 | fall back to world domain */ |
| 706 | if (is_crda_regulatory_entry_valid() == VOS_FALSE) |
| 707 | crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 708 | } |
| 709 | return 0; |
| 710 | } |
| 711 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 712 | /* In this function we will do all post VOS start initialization. |
| 713 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 714 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 715 | */ |
| 716 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 717 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 718 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 719 | /* Register for all P2P action, public action etc frames */ |
| 720 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 721 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 722 | ENTER(); |
| 723 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 724 | /* Right now we are registering these frame when driver is getting |
| 725 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 726 | frame register ops, we will move this code as a part of that */ |
| 727 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 728 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 729 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 730 | |
| 731 | /* GAS Initial Response */ |
| 732 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 733 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 734 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 735 | /* GAS Comeback Request */ |
| 736 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 737 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 738 | |
| 739 | /* GAS Comeback Response */ |
| 740 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 741 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 742 | |
| 743 | /* P2P Public Action */ |
| 744 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 745 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 746 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 747 | |
| 748 | /* P2P Action */ |
| 749 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 750 | (v_U8_t*)P2P_ACTION_FRAME, |
| 751 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 752 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 753 | /* WNM BSS Transition Request frame */ |
| 754 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 755 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 756 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 757 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 758 | #ifdef WLAN_FEATURE_11W |
| 759 | /* SA Query Response Action Frame */ |
| 760 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 761 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 762 | SA_QUERY_FRAME_RSP_SIZE ); |
| 763 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 767 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 768 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 769 | /* Register for all P2P action, public action etc frames */ |
| 770 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 771 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 772 | ENTER(); |
| 773 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 774 | /* Right now we are registering these frame when driver is getting |
| 775 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 776 | frame register ops, we will move this code as a part of that */ |
| 777 | /* GAS Initial Request */ |
| 778 | |
| 779 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 780 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 781 | |
| 782 | /* GAS Initial Response */ |
| 783 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 784 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 785 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 786 | /* GAS Comeback Request */ |
| 787 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 788 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 789 | |
| 790 | /* GAS Comeback Response */ |
| 791 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 792 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 793 | |
| 794 | /* P2P Public Action */ |
| 795 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 796 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 797 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 798 | |
| 799 | /* P2P Action */ |
| 800 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 801 | (v_U8_t*)P2P_ACTION_FRAME, |
| 802 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 803 | |
| 804 | #ifdef WLAN_FEATURE_11W |
| 805 | /* SA Query Response Action Frame */ |
| 806 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 807 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 808 | SA_QUERY_FRAME_RSP_SIZE ); |
| 809 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | #ifdef FEATURE_WLAN_WAPI |
| 813 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 814 | const u8 *mac_addr, u8 *key , int key_Len) |
| 815 | { |
| 816 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 817 | tCsrRoamSetKey setKey; |
| 818 | v_BOOL_t isConnected = TRUE; |
| 819 | int status = 0; |
| 820 | v_U32_t roamId= 0xFF; |
| 821 | tANI_U8 *pKeyPtr = NULL; |
| 822 | int n = 0; |
| 823 | |
| 824 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 825 | __func__,pAdapter->device_mode); |
| 826 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 827 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 828 | setKey.keyId = key_index; // Store Key ID |
| 829 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 830 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 831 | setKey.paeRole = 0 ; // the PAE role |
| 832 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 833 | { |
| 834 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 835 | } |
| 836 | else |
| 837 | { |
| 838 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 839 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 840 | } |
| 841 | setKey.keyLength = key_Len; |
| 842 | pKeyPtr = setKey.Key; |
| 843 | memcpy( pKeyPtr, key, key_Len); |
| 844 | |
| 845 | hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x", |
| 846 | __func__, key_Len); |
| 847 | for (n = 0 ; n < key_Len; n++) |
| 848 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 849 | __func__,n,setKey.Key[n]); |
| 850 | |
| 851 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 852 | if ( isConnected ) |
| 853 | { |
| 854 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 855 | pAdapter->sessionId, &setKey, &roamId ); |
| 856 | } |
| 857 | if ( status != 0 ) |
| 858 | { |
| 859 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 860 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 861 | __LINE__, status ); |
| 862 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 863 | } |
| 864 | } |
| 865 | #endif /* FEATURE_WLAN_WAPI*/ |
| 866 | |
| 867 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 868 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 869 | beacon_data_t **ppBeacon, |
| 870 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 871 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 872 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 873 | beacon_data_t **ppBeacon, |
| 874 | struct cfg80211_beacon_data *params, |
| 875 | int dtim_period) |
| 876 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 877 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 878 | int size; |
| 879 | beacon_data_t *beacon = NULL; |
| 880 | beacon_data_t *old = NULL; |
| 881 | int head_len,tail_len; |
| 882 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 883 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 884 | if (params->head && !params->head_len) |
| 885 | return -EINVAL; |
| 886 | |
| 887 | old = pAdapter->sessionCtx.ap.beacon; |
| 888 | |
| 889 | if (!params->head && !old) |
| 890 | return -EINVAL; |
| 891 | |
| 892 | if (params->tail && !params->tail_len) |
| 893 | return -EINVAL; |
| 894 | |
| 895 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 896 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 897 | if (!params->dtim_period) |
| 898 | return -EINVAL; |
| 899 | #endif |
| 900 | |
| 901 | if(params->head) |
| 902 | head_len = params->head_len; |
| 903 | else |
| 904 | head_len = old->head_len; |
| 905 | |
| 906 | if(params->tail || !old) |
| 907 | tail_len = params->tail_len; |
| 908 | else |
| 909 | tail_len = old->tail_len; |
| 910 | |
| 911 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 912 | |
| 913 | beacon = kzalloc(size, GFP_KERNEL); |
| 914 | |
| 915 | if( beacon == NULL ) |
| 916 | return -ENOMEM; |
| 917 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 918 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 919 | if(params->dtim_period || !old ) |
| 920 | beacon->dtim_period = params->dtim_period; |
| 921 | else |
| 922 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 923 | #else |
| 924 | if(dtim_period || !old ) |
| 925 | beacon->dtim_period = dtim_period; |
| 926 | else |
| 927 | beacon->dtim_period = old->dtim_period; |
| 928 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 929 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 930 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 931 | beacon->tail = beacon->head + head_len; |
| 932 | beacon->head_len = head_len; |
| 933 | beacon->tail_len = tail_len; |
| 934 | |
| 935 | if(params->head) { |
| 936 | memcpy (beacon->head,params->head,beacon->head_len); |
| 937 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 938 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 939 | if(old) |
| 940 | memcpy (beacon->head,old->head,beacon->head_len); |
| 941 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 942 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 943 | if(params->tail) { |
| 944 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 945 | } |
| 946 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 947 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 948 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 949 | } |
| 950 | |
| 951 | *ppBeacon = beacon; |
| 952 | |
| 953 | kfree(old); |
| 954 | |
| 955 | return 0; |
| 956 | |
| 957 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 958 | |
| 959 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 960 | { |
| 961 | int left = length; |
| 962 | v_U8_t *ptr = pIes; |
| 963 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 964 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 965 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 966 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 967 | elem_id = ptr[0]; |
| 968 | elem_len = ptr[1]; |
| 969 | left -= 2; |
| 970 | if(elem_len > left) |
| 971 | { |
| 972 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 973 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 974 | eid,elem_len,left); |
| 975 | return NULL; |
| 976 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 977 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 978 | { |
| 979 | return ptr; |
| 980 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 981 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 982 | left -= elem_len; |
| 983 | ptr += (elem_len + 2); |
| 984 | } |
| 985 | return NULL; |
| 986 | } |
| 987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 988 | /* Check if rate is 11g rate or not */ |
| 989 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 990 | { |
| 991 | u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 104}; /* actual rate * 2 */ |
| 992 | u8 i; |
| 993 | for (i = 0; i < 8; i++) |
| 994 | { |
| 995 | if(rate == gRateArray[i]) |
| 996 | return TRUE; |
| 997 | } |
| 998 | return FALSE; |
| 999 | } |
| 1000 | |
| 1001 | /* Check for 11g rate and set proper 11g only mode */ |
| 1002 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1003 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1004 | { |
| 1005 | u8 i, num_rates = pIe[0]; |
| 1006 | |
| 1007 | pIe += 1; |
| 1008 | for ( i = 0; i < num_rates; i++) |
| 1009 | { |
| 1010 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1011 | { |
| 1012 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1013 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1014 | if (pIe[i] & BASIC_RATE_MASK) |
| 1015 | { |
| 1016 | /* If we have 11g rate as basic rate, it means mode |
| 1017 | is 11g only mode. |
| 1018 | */ |
| 1019 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1020 | *pCheckRatesfor11g = FALSE; |
| 1021 | } |
| 1022 | } |
| 1023 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1024 | { |
| 1025 | *require_ht = TRUE; |
| 1026 | } |
| 1027 | } |
| 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1032 | { |
| 1033 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1034 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1035 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1036 | u8 checkRatesfor11g = TRUE; |
| 1037 | u8 require_ht = FALSE; |
| 1038 | u8 *pIe=NULL; |
| 1039 | |
| 1040 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1041 | |
| 1042 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1043 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1044 | if (pIe != NULL) |
| 1045 | { |
| 1046 | pIe += 1; |
| 1047 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1048 | &pConfig->SapHw_mode); |
| 1049 | } |
| 1050 | |
| 1051 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1052 | WLAN_EID_EXT_SUPP_RATES); |
| 1053 | if (pIe != NULL) |
| 1054 | { |
| 1055 | |
| 1056 | pIe += 1; |
| 1057 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1058 | &pConfig->SapHw_mode); |
| 1059 | } |
| 1060 | |
| 1061 | if( pConfig->channel > 14 ) |
| 1062 | { |
| 1063 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1064 | } |
| 1065 | |
| 1066 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1067 | WLAN_EID_HT_CAPABILITY); |
| 1068 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1069 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1070 | { |
| 1071 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1072 | if(require_ht) |
| 1073 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1074 | } |
| 1075 | } |
| 1076 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1077 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1078 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1079 | { |
| 1080 | v_U8_t ielen = 0; |
| 1081 | v_U8_t *pIe = NULL; |
| 1082 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1083 | |
| 1084 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1085 | pBeacon->tail, pBeacon->tail_len); |
| 1086 | |
| 1087 | if (pIe) |
| 1088 | { |
| 1089 | ielen = pIe[1] + 2; |
| 1090 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1091 | { |
| 1092 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1093 | } |
| 1094 | else |
| 1095 | { |
| 1096 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1097 | return -EINVAL; |
| 1098 | } |
| 1099 | *total_ielen += ielen; |
| 1100 | } |
| 1101 | return 0; |
| 1102 | } |
| 1103 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1104 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1105 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1106 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1107 | #else |
| 1108 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1109 | struct cfg80211_beacon_data *params) |
| 1110 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1111 | { |
| 1112 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1113 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1114 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1115 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1116 | |
| 1117 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1118 | |
| 1119 | if(genie == NULL) { |
| 1120 | |
| 1121 | return -ENOMEM; |
| 1122 | } |
| 1123 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1124 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1125 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1126 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1127 | ret = -EINVAL; |
| 1128 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1132 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1133 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1134 | { |
| 1135 | ret = -EINVAL; |
| 1136 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1137 | } |
| 1138 | #endif |
| 1139 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1140 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1141 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1142 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1143 | ret = -EINVAL; |
| 1144 | goto done; |
| 1145 | } |
| 1146 | |
| 1147 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1148 | { |
| 1149 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1150 | &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1151 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1152 | ret = -EINVAL; |
| 1153 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1154 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1155 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1156 | |
| 1157 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1158 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1159 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1160 | { |
| 1161 | hddLog(LOGE, |
| 1162 | "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] | 1163 | ret = -EINVAL; |
| 1164 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1168 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1169 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1170 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1171 | ==eHAL_STATUS_FAILURE) |
| 1172 | { |
| 1173 | hddLog(LOGE, |
| 1174 | "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] | 1175 | ret = -EINVAL; |
| 1176 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | // Added for ProResp IE |
| 1180 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1181 | { |
| 1182 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1183 | u8 probe_rsp_ie_len[3] = {0}; |
| 1184 | u8 counter = 0; |
| 1185 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1186 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1187 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1188 | Store More then 255 bytes into One Variable. |
| 1189 | */ |
| 1190 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1191 | { |
| 1192 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1193 | { |
| 1194 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1195 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1196 | } |
| 1197 | else |
| 1198 | { |
| 1199 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1200 | rem_probe_resp_ie_len = 0; |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | rem_probe_resp_ie_len = 0; |
| 1205 | |
| 1206 | if (probe_rsp_ie_len[0] > 0) |
| 1207 | { |
| 1208 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1209 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1210 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1211 | probe_rsp_ie_len[0], NULL, |
| 1212 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1213 | { |
| 1214 | hddLog(LOGE, |
| 1215 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1216 | ret = -EINVAL; |
| 1217 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1218 | } |
| 1219 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1220 | } |
| 1221 | |
| 1222 | if (probe_rsp_ie_len[1] > 0) |
| 1223 | { |
| 1224 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1225 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1226 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1227 | probe_rsp_ie_len[1], NULL, |
| 1228 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1229 | { |
| 1230 | hddLog(LOGE, |
| 1231 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1232 | ret = -EINVAL; |
| 1233 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1234 | } |
| 1235 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1236 | } |
| 1237 | |
| 1238 | if (probe_rsp_ie_len[2] > 0) |
| 1239 | { |
| 1240 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1241 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1242 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1243 | probe_rsp_ie_len[2], NULL, |
| 1244 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1245 | { |
| 1246 | hddLog(LOGE, |
| 1247 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1248 | ret = -EINVAL; |
| 1249 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1250 | } |
| 1251 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1252 | } |
| 1253 | |
| 1254 | if (probe_rsp_ie_len[1] == 0 ) |
| 1255 | { |
| 1256 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1257 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1258 | eANI_BOOLEAN_FALSE) ) |
| 1259 | { |
| 1260 | hddLog(LOGE, |
| 1261 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n"); |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | if (probe_rsp_ie_len[2] == 0 ) |
| 1266 | { |
| 1267 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1268 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1269 | eANI_BOOLEAN_FALSE) ) |
| 1270 | { |
| 1271 | hddLog(LOGE, |
| 1272 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n"); |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1277 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1278 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1279 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1280 | == eHAL_STATUS_FAILURE) |
| 1281 | { |
| 1282 | hddLog(LOGE, |
| 1283 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG 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 | } |
| 1288 | else |
| 1289 | { |
| 1290 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1291 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1292 | |
| 1293 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1294 | "%s: No Probe Response IE received in set beacon", |
| 1295 | __func__); |
| 1296 | } |
| 1297 | |
| 1298 | // Added for AssocResp IE |
| 1299 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1300 | { |
| 1301 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1302 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1303 | params->assocresp_ies_len, NULL, |
| 1304 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1305 | { |
| 1306 | hddLog(LOGE, |
| 1307 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1308 | ret = -EINVAL; |
| 1309 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1313 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1314 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1315 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1316 | == eHAL_STATUS_FAILURE) |
| 1317 | { |
| 1318 | hddLog(LOGE, |
| 1319 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1320 | ret = -EINVAL; |
| 1321 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1322 | } |
| 1323 | } |
| 1324 | else |
| 1325 | { |
| 1326 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1327 | "%s: No Assoc Response IE received in set beacon", |
| 1328 | __func__); |
| 1329 | |
| 1330 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1331 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1332 | eANI_BOOLEAN_FALSE) ) |
| 1333 | { |
| 1334 | hddLog(LOGE, |
| 1335 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 1336 | } |
| 1337 | } |
| 1338 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1339 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1340 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1341 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1342 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1343 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1344 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1345 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1346 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1347 | * wlan_hdd_cfg80211_set_channel() |
| 1348 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1349 | * channel list. |
| 1350 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1351 | static VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel) |
| 1352 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1353 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1354 | v_U32_t num_ch = 0; |
| 1355 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1356 | u32 indx = 0; |
| 1357 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1358 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1359 | 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] | 1360 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1361 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1362 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1363 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1364 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1365 | /* Validate the channel */ |
| 1366 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1367 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1368 | if ( channel == rfChannels[count].channelNum ) |
| 1369 | { |
| 1370 | fValidChannel = TRUE; |
| 1371 | break; |
| 1372 | } |
| 1373 | } |
| 1374 | if (fValidChannel != TRUE) |
| 1375 | { |
| 1376 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1377 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1378 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1379 | } |
| 1380 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1381 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1382 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1383 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1384 | valid_ch, &num_ch)) |
| 1385 | { |
| 1386 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1387 | "%s: failed to get valid channel list", __func__); |
| 1388 | return VOS_STATUS_E_FAILURE; |
| 1389 | } |
| 1390 | for (indx = 0; indx < num_ch; indx++) |
| 1391 | { |
| 1392 | if (channel == valid_ch[indx]) |
| 1393 | { |
| 1394 | break; |
| 1395 | } |
| 1396 | } |
| 1397 | |
| 1398 | if (indx >= num_ch) |
| 1399 | { |
| 1400 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1401 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1402 | return VOS_STATUS_E_FAILURE; |
| 1403 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1404 | } |
| 1405 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1406 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | } |
| 1408 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1409 | /** |
| 1410 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1411 | * This function is used to set the channel number |
| 1412 | */ |
| 1413 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1414 | struct ieee80211_channel *chan, |
| 1415 | enum nl80211_channel_type channel_type |
| 1416 | ) |
| 1417 | { |
| 1418 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1419 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1420 | hdd_adapter_t *pAdapter = NULL; |
| 1421 | int freq = chan->center_freq; /* freq is in MHZ */ |
| 1422 | |
| 1423 | ENTER(); |
| 1424 | |
| 1425 | if( NULL == dev ) |
| 1426 | { |
| 1427 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1428 | "%s: Called with dev = NULL.\n", __func__); |
| 1429 | return -ENODEV; |
| 1430 | } |
| 1431 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1432 | |
| 1433 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1434 | "%s: device_mode = %d freq = %d \n",__func__, |
| 1435 | pAdapter->device_mode, chan->center_freq); |
| 1436 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 1437 | { |
| 1438 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1439 | return -EAGAIN; |
| 1440 | } |
| 1441 | |
| 1442 | /* |
| 1443 | * Do freq to chan conversion |
| 1444 | * TODO: for 11a |
| 1445 | */ |
| 1446 | |
| 1447 | channel = ieee80211_frequency_to_channel(freq); |
| 1448 | |
| 1449 | /* Check freq range */ |
| 1450 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1451 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1452 | { |
| 1453 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1454 | "%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1455 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1456 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1457 | return -EINVAL; |
| 1458 | } |
| 1459 | |
| 1460 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1461 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1462 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1463 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1464 | { |
| 1465 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1466 | { |
| 1467 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1468 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1469 | return -EINVAL; |
| 1470 | } |
| 1471 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1472 | "%s: set channel to [%d] for device mode =%d", |
| 1473 | __func__, channel,pAdapter->device_mode); |
| 1474 | } |
| 1475 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1476 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1477 | ) |
| 1478 | { |
| 1479 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1480 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1481 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1482 | |
| 1483 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1484 | { |
| 1485 | /* Link is up then return cant set channel*/ |
| 1486 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1487 | "%s: IBSS Associated, can't set the channel\n", __func__); |
| 1488 | return -EINVAL; |
| 1489 | } |
| 1490 | |
| 1491 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1492 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1493 | pRoamProfile->ChannelInfo.ChannelList = |
| 1494 | &pHddStaCtx->conn_info.operationChannel; |
| 1495 | } |
| 1496 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1497 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1498 | ) |
| 1499 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1500 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1501 | { |
| 1502 | if(VOS_STATUS_SUCCESS != |
| 1503 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1504 | { |
| 1505 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1506 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1507 | return -EINVAL; |
| 1508 | } |
| 1509 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1510 | } |
| 1511 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1512 | { |
| 1513 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1514 | |
| 1515 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1516 | channel set by supplicant |
| 1517 | */ |
| 1518 | if ( cfg_param->apAutoChannelSelection ) |
| 1519 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1520 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1521 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1522 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1523 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1524 | __func__, pAdapter->device_mode); |
| 1525 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1526 | else |
| 1527 | { |
| 1528 | if(VOS_STATUS_SUCCESS != |
| 1529 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1530 | { |
| 1531 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1532 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1533 | return -EINVAL; |
| 1534 | } |
| 1535 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1536 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1537 | } |
| 1538 | } |
| 1539 | else |
| 1540 | { |
| 1541 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1542 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1543 | return -EINVAL; |
| 1544 | } |
| 1545 | EXIT(); |
| 1546 | return 0; |
| 1547 | } |
| 1548 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1549 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1550 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1551 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1552 | #else |
| 1553 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1554 | struct cfg80211_beacon_data *params, |
| 1555 | const u8 *ssid, size_t ssid_len, |
| 1556 | enum nl80211_hidden_ssid hidden_ssid) |
| 1557 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1558 | { |
| 1559 | tsap_Config_t *pConfig; |
| 1560 | beacon_data_t *pBeacon = NULL; |
| 1561 | struct ieee80211_mgmt *pMgmt_frame; |
| 1562 | v_U8_t *pIe=NULL; |
| 1563 | v_U16_t capab_info; |
| 1564 | eCsrAuthType RSNAuthType; |
| 1565 | eCsrEncryptionType RSNEncryptType; |
| 1566 | eCsrEncryptionType mcRSNEncryptType; |
| 1567 | int status = VOS_STATUS_SUCCESS; |
| 1568 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1569 | hdd_hostapd_state_t *pHostapdState; |
| 1570 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1571 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1572 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1573 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1574 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1575 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1576 | |
| 1577 | ENTER(); |
| 1578 | |
| 1579 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1580 | |
| 1581 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1582 | |
| 1583 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1584 | |
| 1585 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1586 | |
| 1587 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1588 | |
| 1589 | //channel is already set in the set_channel Call back |
| 1590 | //pConfig->channel = pCommitConfig->channel; |
| 1591 | |
| 1592 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1593 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1594 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1595 | |
| 1596 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1597 | |
| 1598 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1599 | pConfig->dtim_period); |
| 1600 | |
| 1601 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1602 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1603 | { |
| 1604 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1605 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1606 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1607 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1608 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1609 | pConfig->ieee80211d = 1; |
| 1610 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1611 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1612 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1613 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1614 | else |
| 1615 | { |
| 1616 | pConfig->ieee80211d = 0; |
| 1617 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1618 | /* |
| 1619 | * If auto channel is configured i.e. channel is 0, |
| 1620 | * so skip channel validation. |
| 1621 | */ |
| 1622 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1623 | { |
| 1624 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1625 | { |
| 1626 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1627 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1628 | return -EINVAL; |
| 1629 | } |
| 1630 | } |
| 1631 | else |
| 1632 | { |
| 1633 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1634 | { |
| 1635 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1636 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1637 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1638 | } |
| 1639 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1640 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1641 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1642 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1643 | { |
| 1644 | pConfig->ieee80211d = 0; |
| 1645 | } |
| 1646 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1647 | |
| 1648 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1649 | |
| 1650 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1651 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1652 | |
| 1653 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1654 | |
| 1655 | /*Set wps station to configured*/ |
| 1656 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1657 | |
| 1658 | if(pIe) |
| 1659 | { |
| 1660 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1661 | { |
| 1662 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1663 | return -EINVAL; |
| 1664 | } |
| 1665 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1666 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1667 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1668 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1669 | * WPS state |
| 1670 | */ |
| 1671 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1672 | { |
| 1673 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1674 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1675 | { |
| 1676 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1677 | } |
| 1678 | } |
| 1679 | } |
| 1680 | else |
| 1681 | { |
| 1682 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1683 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1684 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1685 | |
| 1686 | pConfig->RSNWPAReqIELength = 0; |
| 1687 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1688 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1689 | WLAN_EID_RSN); |
| 1690 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1691 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1692 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1693 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1694 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1695 | /* The actual processing may eventually be more extensive than |
| 1696 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1697 | * by the app. |
| 1698 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1699 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1700 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1701 | &RSNEncryptType, |
| 1702 | &mcRSNEncryptType, |
| 1703 | &RSNAuthType, |
| 1704 | pConfig->pRSNWPAReqIE[1]+2, |
| 1705 | pConfig->pRSNWPAReqIE ); |
| 1706 | |
| 1707 | if( VOS_STATUS_SUCCESS == status ) |
| 1708 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1709 | /* Now copy over all the security attributes you have |
| 1710 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1711 | * */ |
| 1712 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1713 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1714 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1715 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1716 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1717 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1718 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1719 | } |
| 1720 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1721 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1722 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1723 | pBeacon->tail, pBeacon->tail_len); |
| 1724 | |
| 1725 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1726 | { |
| 1727 | if (pConfig->pRSNWPAReqIE) |
| 1728 | { |
| 1729 | /*Mixed mode WPA/WPA2*/ |
| 1730 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1731 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1732 | } |
| 1733 | else |
| 1734 | { |
| 1735 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1736 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1737 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1738 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1739 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1740 | &RSNEncryptType, |
| 1741 | &mcRSNEncryptType, |
| 1742 | &RSNAuthType, |
| 1743 | pConfig->pRSNWPAReqIE[1]+2, |
| 1744 | pConfig->pRSNWPAReqIE ); |
| 1745 | |
| 1746 | if( VOS_STATUS_SUCCESS == status ) |
| 1747 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1748 | /* Now copy over all the security attributes you have |
| 1749 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1750 | * */ |
| 1751 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1752 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1753 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1754 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1755 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1756 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1757 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1758 | } |
| 1759 | } |
| 1760 | } |
| 1761 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1762 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1763 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1764 | return -EINVAL; |
| 1765 | } |
| 1766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1767 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1768 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1769 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1770 | if (params->ssid != NULL) |
| 1771 | { |
| 1772 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1773 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1774 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1775 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1776 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1777 | #else |
| 1778 | if (ssid != NULL) |
| 1779 | { |
| 1780 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1781 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1782 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1783 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1784 | } |
| 1785 | #endif |
| 1786 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1787 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1788 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1789 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1790 | /* default value */ |
| 1791 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1792 | pConfig->num_accept_mac = 0; |
| 1793 | pConfig->num_deny_mac = 0; |
| 1794 | |
| 1795 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1796 | pBeacon->tail, pBeacon->tail_len); |
| 1797 | |
| 1798 | /* pIe for black list is following form: |
| 1799 | type : 1 byte |
| 1800 | length : 1 byte |
| 1801 | OUI : 4 bytes |
| 1802 | acl type : 1 byte |
| 1803 | no of mac addr in black list: 1 byte |
| 1804 | 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] | 1805 | */ |
| 1806 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1807 | { |
| 1808 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1809 | pConfig->num_deny_mac = pIe[7]; |
| 1810 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1811 | pIe[6], pIe[7]); |
| 1812 | if (pConfig->num_deny_mac > MAX_MAC_ADDRESS_DENIED) |
| 1813 | pConfig->num_deny_mac = MAX_MAC_ADDRESS_DENIED; |
| 1814 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1815 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1816 | { |
| 1817 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1818 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1819 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1820 | } |
| 1821 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1822 | pBeacon->tail, pBeacon->tail_len); |
| 1823 | |
| 1824 | /* pIe for white list is following form: |
| 1825 | type : 1 byte |
| 1826 | length : 1 byte |
| 1827 | OUI : 4 bytes |
| 1828 | acl type : 1 byte |
| 1829 | no of mac addr in white list: 1 byte |
| 1830 | 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] | 1831 | */ |
| 1832 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1833 | { |
| 1834 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1835 | pConfig->num_accept_mac = pIe[7]; |
| 1836 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 1837 | pIe[6], pIe[7]); |
| 1838 | if (pConfig->num_accept_mac > MAX_MAC_ADDRESS_ACCEPTED) |
| 1839 | pConfig->num_accept_mac = MAX_MAC_ADDRESS_ACCEPTED; |
| 1840 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1841 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 1842 | { |
| 1843 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1844 | acl_entry++; |
| 1845 | } |
| 1846 | } |
| 1847 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 1848 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1849 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 1850 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 1851 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 1852 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 1853 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 1854 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1855 | (((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] | 1856 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 1857 | ((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] | 1858 | { |
| 1859 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
| 1860 | } |
| 1861 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1862 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 1863 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1864 | { |
| 1865 | sme_SelectCBMode(hHal, |
| 1866 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 1867 | pConfig->channel); |
| 1868 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1869 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 1870 | pConfig->ht_capab = |
| 1871 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 1872 | |
| 1873 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 1874 | { |
| 1875 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 1876 | return -EINVAL; |
| 1877 | } |
| 1878 | |
| 1879 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1880 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1881 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 1882 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1883 | pConfig->obssProtEnabled = |
| 1884 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1885 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1886 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1887 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1888 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1889 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 1890 | (int)pConfig->channel); |
| 1891 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1892 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 1893 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1894 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1895 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1896 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 1897 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 1898 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1899 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1900 | { |
| 1901 | //Bss already started. just return. |
| 1902 | //TODO Probably it should update some beacon params. |
| 1903 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 1904 | EXIT(); |
| 1905 | return 0; |
| 1906 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1907 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1908 | pConfig->persona = pHostapdAdapter->device_mode; |
| 1909 | |
| 1910 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 1911 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 1912 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 1913 | { |
| 1914 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 1915 | return -EINVAL; |
| 1916 | } |
| 1917 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1918 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1919 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 1920 | |
| 1921 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1922 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1923 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1924 | { |
| 1925 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1926 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 1927 | VOS_ASSERT(0); |
| 1928 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1929 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1930 | //Succesfully started Bss update the state bit. |
| 1931 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 1932 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1933 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 1934 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 1935 | { |
| 1936 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 1937 | { |
| 1938 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 1939 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 1940 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1941 | } |
| 1942 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 1943 | { |
| 1944 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 1945 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 1946 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1947 | } |
| 1948 | } |
| 1949 | #endif |
| 1950 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1951 | pHostapdState->bCommit = TRUE; |
| 1952 | EXIT(); |
| 1953 | |
| 1954 | return 0; |
| 1955 | } |
| 1956 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1957 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1958 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 1959 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1960 | struct beacon_parameters *params) |
| 1961 | { |
| 1962 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1963 | int status=VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1964 | |
| 1965 | ENTER(); |
| 1966 | |
| 1967 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 1968 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1969 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 1970 | { |
| 1971 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1972 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 1973 | return -EAGAIN; |
| 1974 | } |
| 1975 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1976 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1977 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1978 | ) |
| 1979 | { |
| 1980 | beacon_data_t *old,*new; |
| 1981 | |
| 1982 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1983 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1984 | if (old) |
| 1985 | return -EALREADY; |
| 1986 | |
| 1987 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 1988 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1989 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1990 | { |
| 1991 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1992 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 1993 | return -EINVAL; |
| 1994 | } |
| 1995 | |
| 1996 | pAdapter->sessionCtx.ap.beacon = new; |
| 1997 | |
| 1998 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 1999 | } |
| 2000 | |
| 2001 | EXIT(); |
| 2002 | return status; |
| 2003 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2004 | |
| 2005 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2006 | struct net_device *dev, |
| 2007 | struct beacon_parameters *params) |
| 2008 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2009 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2010 | int status=VOS_STATUS_SUCCESS; |
| 2011 | |
| 2012 | ENTER(); |
| 2013 | |
| 2014 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2015 | __func__,pAdapter->device_mode); |
| 2016 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2017 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 2018 | { |
| 2019 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2020 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2021 | return -EAGAIN; |
| 2022 | } |
| 2023 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2024 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2025 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2026 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2027 | { |
| 2028 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2029 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2030 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2031 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2032 | if (!old) |
| 2033 | return -ENOENT; |
| 2034 | |
| 2035 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2036 | |
| 2037 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2038 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2039 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2040 | return -EINVAL; |
| 2041 | } |
| 2042 | |
| 2043 | pAdapter->sessionCtx.ap.beacon = new; |
| 2044 | |
| 2045 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2046 | } |
| 2047 | |
| 2048 | EXIT(); |
| 2049 | return status; |
| 2050 | } |
| 2051 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2052 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2053 | |
| 2054 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2055 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2056 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2057 | #else |
| 2058 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2059 | struct net_device *dev) |
| 2060 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2061 | { |
| 2062 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2063 | hdd_context_t *pHddCtx = NULL; |
| 2064 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2065 | hdd_adapter_t *staAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2066 | VOS_STATUS status = 0; |
| 2067 | |
| 2068 | ENTER(); |
| 2069 | |
| 2070 | if (NULL == pAdapter) |
| 2071 | { |
| 2072 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2073 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2074 | return -ENODEV; |
| 2075 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2076 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2077 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2078 | if (NULL == pHddCtx) |
| 2079 | { |
| 2080 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2081 | "%s: HDD context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2082 | return -ENODEV; |
| 2083 | } |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2084 | if (pHddCtx->isLogpInProgress) |
| 2085 | { |
| 2086 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2087 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2088 | return -EAGAIN; |
| 2089 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2090 | |
| 2091 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2092 | if (NULL == staAdapter) |
| 2093 | { |
| 2094 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2095 | if (NULL == staAdapter) |
| 2096 | { |
| 2097 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2098 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2099 | return -ENODEV; |
| 2100 | } |
| 2101 | } |
| 2102 | |
| 2103 | pScanInfo = &pHddCtx->scan_info; |
| 2104 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2105 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2106 | { |
| 2107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2108 | return -EAGAIN; |
| 2109 | } |
| 2110 | |
| 2111 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2112 | |
| 2113 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2114 | __func__,pAdapter->device_mode); |
| 2115 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2116 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2117 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2118 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2119 | hdd_abort_mac_scan(staAdapter->pHddCtx); |
| 2120 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2121 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2122 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2123 | if (!status) |
| 2124 | { |
| 2125 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2126 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2127 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2128 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2129 | return 0; |
| 2130 | } |
| 2131 | } |
| 2132 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2133 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2134 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2135 | ) |
| 2136 | { |
| 2137 | beacon_data_t *old; |
| 2138 | |
| 2139 | old = pAdapter->sessionCtx.ap.beacon; |
| 2140 | |
| 2141 | if (!old) |
| 2142 | return -ENOENT; |
| 2143 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2144 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2145 | |
| 2146 | mutex_lock(&pHddCtx->sap_lock); |
| 2147 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2148 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2149 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2150 | { |
| 2151 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2152 | |
| 2153 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2154 | |
| 2155 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2156 | { |
| 2157 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2158 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2159 | VOS_ASSERT(0); |
| 2160 | } |
| 2161 | } |
| 2162 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2163 | } |
| 2164 | mutex_unlock(&pHddCtx->sap_lock); |
| 2165 | |
| 2166 | if(status != VOS_STATUS_SUCCESS) |
| 2167 | { |
| 2168 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2169 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2170 | return -EINVAL; |
| 2171 | } |
| 2172 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2173 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2174 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2175 | ==eHAL_STATUS_FAILURE) |
| 2176 | { |
| 2177 | hddLog(LOGE, |
| 2178 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2179 | } |
| 2180 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2181 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2182 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2183 | eANI_BOOLEAN_FALSE) ) |
| 2184 | { |
| 2185 | hddLog(LOGE, |
| 2186 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2187 | } |
| 2188 | |
| 2189 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2190 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2191 | |
| 2192 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2193 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2194 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2195 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2196 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2197 | { |
| 2198 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2199 | "GO got removed"); |
| 2200 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2201 | } |
| 2202 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2203 | } |
| 2204 | EXIT(); |
| 2205 | return status; |
| 2206 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2207 | |
| 2208 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2209 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2210 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2211 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2212 | struct cfg80211_ap_settings *params) |
| 2213 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2214 | hdd_adapter_t *pAdapter; |
| 2215 | hdd_context_t *pHddCtx; |
| 2216 | int status = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2217 | |
| 2218 | ENTER(); |
| 2219 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2220 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2221 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2222 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2223 | "%s: Device is Null", __func__); |
| 2224 | return -ENODEV; |
| 2225 | } |
| 2226 | |
| 2227 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2228 | if (NULL == pAdapter) |
| 2229 | { |
| 2230 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2231 | "%s: HDD adapter is Null", __func__); |
| 2232 | return -ENODEV; |
| 2233 | } |
| 2234 | |
| 2235 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2236 | { |
| 2237 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2238 | "%s: HDD adapter magic is invalid", __func__); |
| 2239 | return -ENODEV; |
| 2240 | } |
| 2241 | |
| 2242 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2243 | if (NULL == pHddCtx) |
| 2244 | { |
| 2245 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2246 | "%s: HDD context is Null", __func__); |
| 2247 | return -ENODEV; |
| 2248 | } |
| 2249 | |
| 2250 | if (pHddCtx->isLogpInProgress) |
| 2251 | { |
| 2252 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2253 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2254 | return -EAGAIN; |
| 2255 | } |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2256 | |
| 2257 | if (pHddCtx->isLoadUnloadInProgress) |
| 2258 | { |
| 2259 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2260 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 2261 | return -EAGAIN; |
| 2262 | } |
| 2263 | |
| 2264 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2265 | __func__, pAdapter->device_mode); |
| 2266 | |
| 2267 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2268 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2269 | ) |
| 2270 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2271 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2272 | |
| 2273 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2274 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2275 | if (old) |
| 2276 | return -EALREADY; |
| 2277 | |
| 2278 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2279 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2280 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2281 | { |
| 2282 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2283 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2284 | return -EINVAL; |
| 2285 | } |
| 2286 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2287 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2288 | wlan_hdd_cfg80211_set_channel(wiphy, dev, params->channel, params->channel_type); |
| 2289 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2290 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2291 | params->ssid_len, params->hidden_ssid); |
| 2292 | } |
| 2293 | |
| 2294 | EXIT(); |
| 2295 | return status; |
| 2296 | } |
| 2297 | |
| 2298 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2299 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2300 | struct net_device *dev, |
| 2301 | struct cfg80211_beacon_data *params) |
| 2302 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2303 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2304 | int status=VOS_STATUS_SUCCESS; |
| 2305 | |
| 2306 | ENTER(); |
| 2307 | |
| 2308 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2309 | __func__, pAdapter->device_mode); |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2310 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2311 | { |
| 2312 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2313 | return -EAGAIN; |
| 2314 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2315 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2316 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2317 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2318 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2319 | { |
| 2320 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2321 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2322 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2323 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2324 | if (!old) |
| 2325 | return -ENOENT; |
| 2326 | |
| 2327 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2328 | |
| 2329 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2330 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2331 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2332 | return -EINVAL; |
| 2333 | } |
| 2334 | |
| 2335 | pAdapter->sessionCtx.ap.beacon = new; |
| 2336 | |
| 2337 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2338 | } |
| 2339 | |
| 2340 | EXIT(); |
| 2341 | return status; |
| 2342 | } |
| 2343 | |
| 2344 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2345 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2346 | |
| 2347 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2348 | struct net_device *dev, |
| 2349 | struct bss_parameters *params) |
| 2350 | { |
| 2351 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2352 | |
| 2353 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2354 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2355 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2356 | __func__,pAdapter->device_mode); |
| 2357 | |
| 2358 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2359 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2360 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2361 | { |
| 2362 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2363 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2364 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2365 | { |
| 2366 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2367 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2368 | } |
| 2369 | |
| 2370 | EXIT(); |
| 2371 | return 0; |
| 2372 | } |
| 2373 | |
| 2374 | /* |
| 2375 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2376 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2377 | */ |
| 2378 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2379 | struct net_device *ndev, |
| 2380 | enum nl80211_iftype type, |
| 2381 | u32 *flags, |
| 2382 | struct vif_params *params |
| 2383 | ) |
| 2384 | { |
| 2385 | struct wireless_dev *wdev; |
| 2386 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2387 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2388 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2389 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2390 | eCsrRoamBssType LastBSSType; |
| 2391 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 2392 | eMib_dot11DesiredBssType connectedBssType; |
| 2393 | VOS_STATUS status; |
| 2394 | |
| 2395 | ENTER(); |
| 2396 | |
| 2397 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2398 | { |
| 2399 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2400 | return -EAGAIN; |
| 2401 | } |
| 2402 | |
| 2403 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2404 | __func__, pAdapter->device_mode); |
| 2405 | |
| 2406 | wdev = ndev->ieee80211_ptr; |
| 2407 | |
| 2408 | #ifdef WLAN_BTAMP_FEATURE |
| 2409 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2410 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2411 | (NL80211_IFTYPE_AP == type)|| |
| 2412 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2413 | { |
| 2414 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2415 | // stop AMP traffic |
| 2416 | status = WLANBAP_StopAmp(); |
| 2417 | if(VOS_STATUS_SUCCESS != status ) |
| 2418 | { |
| 2419 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2420 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2421 | "%s: Failed to stop AMP", __func__); |
| 2422 | return -EINVAL; |
| 2423 | } |
| 2424 | } |
| 2425 | #endif //WLAN_BTAMP_FEATURE |
| 2426 | /* Reset the current device mode bit mask*/ |
| 2427 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2428 | |
| 2429 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2430 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2431 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2432 | ) |
| 2433 | { |
| 2434 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2435 | pRoamProfile = &pWextState->roamProfile; |
| 2436 | LastBSSType = pRoamProfile->BSSType; |
| 2437 | |
| 2438 | switch (type) |
| 2439 | { |
| 2440 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2441 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2442 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2443 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2444 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2445 | #ifdef WLAN_FEATURE_11AC |
| 2446 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2447 | { |
| 2448 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2449 | } |
| 2450 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2451 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2452 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2453 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2454 | //Check for sub-string p2p to confirm its a p2p interface |
| 2455 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2456 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2457 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2458 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2459 | } |
| 2460 | else |
| 2461 | { |
| 2462 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2463 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2464 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2465 | break; |
| 2466 | case NL80211_IFTYPE_ADHOC: |
| 2467 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2468 | "%s: setting interface Type to ADHOC", __func__); |
| 2469 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2470 | pRoamProfile->phyMode = |
| 2471 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2472 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2473 | wdev->iftype = type; |
| 2474 | break; |
| 2475 | |
| 2476 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2477 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2478 | { |
| 2479 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2480 | "%s: setting interface Type to %s", __func__, |
| 2481 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2482 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2483 | //Cancel any remain on channel for GO mode |
| 2484 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2485 | { |
| 2486 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2487 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2488 | if (NL80211_IFTYPE_AP == type) |
| 2489 | { |
| 2490 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2491 | * address. This will take one HW STA and the max number of clients |
| 2492 | * that can connect to softAP will be reduced by one. so while changing |
| 2493 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2494 | * interface as it is not required in SoftAP mode. |
| 2495 | */ |
| 2496 | |
| 2497 | // Get P2P Adapter |
| 2498 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2499 | |
| 2500 | if (pP2pAdapter) |
| 2501 | { |
| 2502 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2503 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2504 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2505 | } |
| 2506 | } |
| 2507 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2508 | //De-init the adapter. |
| 2509 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2510 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2511 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2512 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2513 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2514 | |
| 2515 | //Disable BMPS and IMPS if enabled |
| 2516 | //before starting Go |
| 2517 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2518 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2519 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2520 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2521 | { |
| 2522 | //Fail to Exit BMPS |
| 2523 | VOS_ASSERT(0); |
| 2524 | } |
| 2525 | } |
| 2526 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2527 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2528 | (pConfig->apRandomBssidEnabled)) |
| 2529 | { |
| 2530 | /* To meet Android requirements create a randomized |
| 2531 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2532 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2533 | ndev->dev_addr[0] = 0x02; |
| 2534 | ndev->dev_addr[1] = 0x1A; |
| 2535 | ndev->dev_addr[2] = 0x11; |
| 2536 | ndev->dev_addr[3] |= 0xF0; |
| 2537 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2538 | VOS_MAC_ADDR_SIZE); |
| 2539 | pr_info("wlan: Generated HotSpot BSSID " |
| 2540 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2541 | ndev->dev_addr[0], |
| 2542 | ndev->dev_addr[1], |
| 2543 | ndev->dev_addr[2], |
| 2544 | ndev->dev_addr[3], |
| 2545 | ndev->dev_addr[4], |
| 2546 | ndev->dev_addr[5]); |
| 2547 | } |
| 2548 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2549 | hdd_set_ap_ops( pAdapter->dev ); |
| 2550 | |
| 2551 | status = hdd_init_ap_mode(pAdapter); |
| 2552 | if(status != VOS_STATUS_SUCCESS) |
| 2553 | { |
| 2554 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2555 | "%s: Error initializing the ap mode", __func__); |
| 2556 | return -EINVAL; |
| 2557 | } |
| 2558 | hdd_set_conparam(1); |
| 2559 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2560 | /*interface type changed update in wiphy structure*/ |
| 2561 | if(wdev) |
| 2562 | { |
| 2563 | wdev->iftype = type; |
| 2564 | pHddCtx->change_iface = type; |
| 2565 | } |
| 2566 | else |
| 2567 | { |
| 2568 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2569 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2570 | return -EINVAL; |
| 2571 | } |
| 2572 | goto done; |
| 2573 | } |
| 2574 | |
| 2575 | default: |
| 2576 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2577 | __func__); |
| 2578 | return -EOPNOTSUPP; |
| 2579 | } |
| 2580 | } |
| 2581 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2582 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2583 | ) |
| 2584 | { |
| 2585 | switch(type) |
| 2586 | { |
| 2587 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2588 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2589 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2590 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2591 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2592 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2593 | //Check for sub-string p2p to confirm its a p2p interface |
| 2594 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2595 | { |
| 2596 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2597 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2598 | } |
| 2599 | else |
| 2600 | { |
| 2601 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2602 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2603 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2604 | hdd_set_conparam(0); |
| 2605 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2606 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2607 | hdd_set_station_ops( pAdapter->dev ); |
| 2608 | status = hdd_init_station_mode( pAdapter ); |
| 2609 | if( VOS_STATUS_SUCCESS != status ) |
| 2610 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2611 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2612 | * This is the right place to enable back bmps_imps() |
| 2613 | */ |
| 2614 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2615 | goto done; |
| 2616 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2617 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2618 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2619 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2620 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2621 | goto done; |
| 2622 | default: |
| 2623 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2624 | __func__); |
| 2625 | return -EOPNOTSUPP; |
| 2626 | |
| 2627 | } |
| 2628 | |
| 2629 | } |
| 2630 | else |
| 2631 | { |
| 2632 | return -EOPNOTSUPP; |
| 2633 | } |
| 2634 | |
| 2635 | |
| 2636 | if(pRoamProfile) |
| 2637 | { |
| 2638 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2639 | { |
| 2640 | /*interface type changed update in wiphy structure*/ |
| 2641 | wdev->iftype = type; |
| 2642 | |
| 2643 | /*the BSS mode changed, We need to issue disconnect |
| 2644 | if connected or in IBSS disconnect state*/ |
| 2645 | if ( hdd_connGetConnectedBssType( |
| 2646 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2647 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2648 | { |
| 2649 | /*need to issue a disconnect to CSR.*/ |
| 2650 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2651 | if( eHAL_STATUS_SUCCESS == |
| 2652 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2653 | pAdapter->sessionId, |
| 2654 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2655 | { |
| 2656 | wait_for_completion_interruptible_timeout( |
| 2657 | &pAdapter->disconnect_comp_var, |
| 2658 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2659 | } |
| 2660 | } |
| 2661 | } |
| 2662 | } |
| 2663 | |
| 2664 | done: |
| 2665 | /*set bitmask based on updated value*/ |
| 2666 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2667 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2668 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2669 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2670 | { |
| 2671 | //we are ok to do AMP |
| 2672 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2673 | } |
| 2674 | #endif //WLAN_BTAMP_FEATURE |
| 2675 | EXIT(); |
| 2676 | return 0; |
| 2677 | } |
| 2678 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2679 | #ifdef FEATURE_WLAN_TDLS |
| 2680 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2681 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2682 | { |
| 2683 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2684 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2685 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2686 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2687 | |
| 2688 | ENTER(); |
| 2689 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2690 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2691 | { |
| 2692 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2693 | "Invalid arguments"); |
| 2694 | return -EINVAL; |
| 2695 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2696 | |
| 2697 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2698 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2699 | { |
| 2700 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2701 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2702 | MAC_ADDRESS_STR " Request declined.", |
| 2703 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2704 | return -ENOTSUPP; |
| 2705 | } |
| 2706 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2707 | if (pHddCtx->isLogpInProgress) |
| 2708 | { |
| 2709 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2710 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2711 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2712 | return -EBUSY; |
| 2713 | } |
| 2714 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2715 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2716 | |
| 2717 | if ( NULL == pTdlsPeer ) { |
| 2718 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2719 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2720 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2721 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2722 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2723 | |
| 2724 | /* in add station, we accept existing valid staId if there is */ |
| 2725 | if ((0 == update) && |
| 2726 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2727 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2728 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2729 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2730 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2731 | " link_status %d. staId %d. add station ignored.", |
| 2732 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2733 | return 0; |
| 2734 | } |
| 2735 | /* in change station, we accept only when staId is valid */ |
| 2736 | if ((1 == update) && |
| 2737 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2738 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2739 | { |
| 2740 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2741 | "%s: " MAC_ADDRESS_STR |
| 2742 | " link status %d. staId %d. change station %s.", |
| 2743 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2744 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2745 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2746 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2747 | |
| 2748 | /* 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] | 2749 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2750 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2751 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2752 | "%s: " MAC_ADDRESS_STR |
| 2753 | " TDLS setup is ongoing. Request declined.", |
| 2754 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2755 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2756 | } |
| 2757 | |
| 2758 | /* first to check if we reached to maximum supported TDLS peer. |
| 2759 | TODO: for now, return -EPERM looks working fine, |
| 2760 | but need to check if any other errno fit into this category.*/ |
| 2761 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2762 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2763 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2764 | "%s: " MAC_ADDRESS_STR |
| 2765 | " TDLS Max peer already connected. Request declined.", |
| 2766 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2767 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2768 | } |
| 2769 | else |
| 2770 | { |
| 2771 | hddTdlsPeer_t *pTdlsPeer; |
| 2772 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2773 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2774 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2775 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2776 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2777 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2778 | return -EPERM; |
| 2779 | } |
| 2780 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2781 | if (0 == update) |
| 2782 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2783 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2784 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2785 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2786 | { |
| 2787 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2788 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2789 | if(StaParams->htcap_present) |
| 2790 | { |
| 2791 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2792 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 2793 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2794 | "ht_capa->extended_capabilities: %0x", |
| 2795 | StaParams->HTCap.extendedHtCapInfo); |
| 2796 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2797 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2798 | "params->capability: %0x",StaParams->capability); |
| 2799 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2800 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2801 | if(StaParams->vhtcap_present) |
| 2802 | { |
| 2803 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2804 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 2805 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 2806 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 2807 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2808 | { |
| 2809 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2810 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2811 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 2812 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2813 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 2814 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2815 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2816 | else if ((1 == update) && (NULL == StaParams)) |
| 2817 | { |
| 2818 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2819 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 2820 | return -EPERM; |
| 2821 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2822 | |
| 2823 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 2824 | |
| 2825 | if (!update) |
| 2826 | { |
| 2827 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2828 | pAdapter->sessionId, mac); |
| 2829 | } |
| 2830 | else |
| 2831 | { |
| 2832 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2833 | pAdapter->sessionId, mac, StaParams); |
| 2834 | } |
| 2835 | |
| 2836 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 2837 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 2838 | |
| 2839 | if (!status) |
| 2840 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2841 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2842 | "%s: timeout waiting for tdls add station indication", |
| 2843 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2844 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2845 | } |
| 2846 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 2847 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2848 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2849 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2850 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2851 | } |
| 2852 | |
| 2853 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2854 | |
| 2855 | error: |
| 2856 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 2857 | return -EPERM; |
| 2858 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2859 | } |
| 2860 | #endif |
| 2861 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2862 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 2863 | struct net_device *dev, |
| 2864 | u8 *mac, |
| 2865 | struct station_parameters *params) |
| 2866 | { |
| 2867 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2868 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2869 | hdd_context_t *pHddCtx; |
| 2870 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2871 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2872 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2873 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2874 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2875 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2876 | ENTER(); |
| 2877 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2878 | if ((NULL == pAdapter)) |
| 2879 | { |
| 2880 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2881 | "invalid adapter "); |
| 2882 | return -EINVAL; |
| 2883 | } |
| 2884 | |
| 2885 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2886 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2887 | |
| 2888 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 2889 | { |
| 2890 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2891 | "invalid HDD state or HDD station context"); |
| 2892 | return -EINVAL; |
| 2893 | } |
| 2894 | |
| 2895 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2896 | { |
| 2897 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2898 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2899 | return -EAGAIN; |
| 2900 | } |
| 2901 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2902 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 2903 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2904 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 2905 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2906 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2907 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2908 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2909 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2910 | WLANTL_STA_AUTHENTICATED); |
| 2911 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2912 | if (status != VOS_STATUS_SUCCESS) |
| 2913 | { |
| 2914 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2915 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 2916 | return -EINVAL; |
| 2917 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2918 | } |
| 2919 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2920 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 2921 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2922 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2923 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 2924 | StaParams.capability = params->capability; |
| 2925 | StaParams.uapsd_queues = params->uapsd_queues; |
| 2926 | StaParams.max_sp = params->max_sp; |
| 2927 | |
| 2928 | if (0 != params->ext_capab_len) |
| 2929 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 2930 | sizeof(StaParams.extn_capability)); |
| 2931 | |
| 2932 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2933 | { |
| 2934 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2935 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2936 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2937 | |
| 2938 | StaParams.supported_rates_len = params->supported_rates_len; |
| 2939 | |
| 2940 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 2941 | * The supported_rates array , for all the structures propogating till Add Sta |
| 2942 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 2943 | * modified to send more rates. |
| 2944 | */ |
| 2945 | |
| 2946 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 2947 | */ |
| 2948 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 2949 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 2950 | |
| 2951 | if (0 != StaParams.supported_rates_len) { |
| 2952 | int i = 0; |
| 2953 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 2954 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2955 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2956 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 2957 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2958 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2959 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 2960 | } |
| 2961 | |
| 2962 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2963 | { |
| 2964 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2965 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2966 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2967 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2968 | if (0 != params->ext_capab_len ) { |
| 2969 | /*Define A Macro : TODO Sunil*/ |
| 2970 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 2971 | isBufSta = 1; |
| 2972 | } |
| 2973 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2974 | //status = wlan_hdd_tdls_set_peer_caps( mac, params->uapsd_queues, |
| 2975 | // params->max_sp, isBufSta); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2976 | //if (VOS_STATUS_SUCCESS != status) { |
| 2977 | // VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2978 | // "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 2979 | // return -EINVAL; |
| 2980 | //} |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2981 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 2982 | |
| 2983 | if (VOS_STATUS_SUCCESS != status) { |
| 2984 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2985 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 2986 | return -EINVAL; |
| 2987 | } |
| 2988 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2989 | #endif |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2990 | if(params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
| 2991 | { |
| 2992 | status = WLANTL_ChangeSTAState(pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ], |
| 2993 | WLANTL_STA_AUTHENTICATED); |
| 2994 | if (status != VOS_STATUS_SUCCESS) |
| 2995 | { |
| 2996 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2997 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 2998 | return -EINVAL; |
| 2999 | } |
| 3000 | pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE; |
| 3001 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3002 | "%s: TL Moving to Authenticated state", __func__); |
| 3003 | } |
| 3004 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3005 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3006 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3007 | return status; |
| 3008 | } |
| 3009 | |
| 3010 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3011 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3012 | * This function is used to initialize the key information |
| 3013 | */ |
| 3014 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3015 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3016 | struct net_device *ndev, |
| 3017 | u8 key_index, bool pairwise, |
| 3018 | const u8 *mac_addr, |
| 3019 | struct key_params *params |
| 3020 | ) |
| 3021 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3022 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3023 | struct net_device *ndev, |
| 3024 | u8 key_index, const u8 *mac_addr, |
| 3025 | struct key_params *params |
| 3026 | ) |
| 3027 | #endif |
| 3028 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3029 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3030 | tCsrRoamSetKey setKey; |
| 3031 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3032 | int status = 0; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3033 | v_U32_t roamId= 0xFF; |
| 3034 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3035 | hdd_hostapd_state_t *pHostapdState; |
| 3036 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3037 | eHalStatus halStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3038 | |
| 3039 | ENTER(); |
| 3040 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3041 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 3042 | { |
| 3043 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3044 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3045 | return -EAGAIN; |
| 3046 | } |
| 3047 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3048 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3049 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3050 | |
| 3051 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3052 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3053 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3054 | key_index); |
| 3055 | |
| 3056 | return -EINVAL; |
| 3057 | } |
| 3058 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3059 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3060 | { |
| 3061 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3062 | params->key_len); |
| 3063 | |
| 3064 | return -EINVAL; |
| 3065 | } |
| 3066 | |
| 3067 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3068 | "%s: called with key index = %d & key length %d", |
| 3069 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3070 | |
| 3071 | /*extract key idx, key len and key*/ |
| 3072 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3073 | setKey.keyId = key_index; |
| 3074 | setKey.keyLength = params->key_len; |
| 3075 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3076 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3077 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3078 | { |
| 3079 | case WLAN_CIPHER_SUITE_WEP40: |
| 3080 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3081 | break; |
| 3082 | |
| 3083 | case WLAN_CIPHER_SUITE_WEP104: |
| 3084 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3085 | break; |
| 3086 | |
| 3087 | case WLAN_CIPHER_SUITE_TKIP: |
| 3088 | { |
| 3089 | u8 *pKey = &setKey.Key[0]; |
| 3090 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3091 | |
| 3092 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3093 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3094 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3095 | |
| 3096 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3097 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3098 | |--------------|----------|----------| |
| 3099 | <---16bytes---><--8bytes--><--8bytes--> |
| 3100 | |
| 3101 | */ |
| 3102 | /*Sme expects the 32 bytes key to be in the below order |
| 3103 | |
| 3104 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3105 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3106 | |--------------|----------|----------| |
| 3107 | <---16bytes---><--8bytes--><--8bytes--> |
| 3108 | */ |
| 3109 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3110 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3111 | |
| 3112 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3113 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3114 | |
| 3115 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3116 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3117 | |
| 3118 | |
| 3119 | break; |
| 3120 | } |
| 3121 | |
| 3122 | case WLAN_CIPHER_SUITE_CCMP: |
| 3123 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3124 | break; |
| 3125 | |
| 3126 | #ifdef FEATURE_WLAN_WAPI |
| 3127 | case WLAN_CIPHER_SUITE_SMS4: |
| 3128 | { |
| 3129 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3130 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3131 | params->key, params->key_len); |
| 3132 | return 0; |
| 3133 | } |
| 3134 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3136 | #ifdef FEATURE_WLAN_CCX |
| 3137 | case WLAN_CIPHER_SUITE_KRK: |
| 3138 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3139 | break; |
| 3140 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3141 | |
| 3142 | #ifdef WLAN_FEATURE_11W |
| 3143 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3144 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3145 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3146 | #endif |
| 3147 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3148 | default: |
| 3149 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3150 | __func__, params->cipher); |
| 3151 | return -EOPNOTSUPP; |
| 3152 | } |
| 3153 | |
| 3154 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3155 | __func__, setKey.encType); |
| 3156 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3157 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3158 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3159 | (!pairwise) |
| 3160 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3161 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3162 | #endif |
| 3163 | ) |
| 3164 | { |
| 3165 | /* set group key*/ |
| 3166 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 3167 | "%s- %d: setting Broadcast key", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3168 | __func__, __LINE__); |
| 3169 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3170 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3171 | } |
| 3172 | else |
| 3173 | { |
| 3174 | /* set pairwise key*/ |
| 3175 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3176 | "%s- %d: setting pairwise key", |
| 3177 | __func__, __LINE__); |
| 3178 | setKey.keyDirection = eSIR_TX_RX; |
| 3179 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3180 | } |
| 3181 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3182 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3183 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3184 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3185 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3186 | if( pHostapdState->bssState == BSS_START ) |
| 3187 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3188 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3189 | |
| 3190 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3191 | { |
| 3192 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3193 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3194 | __LINE__, status ); |
| 3195 | } |
| 3196 | } |
| 3197 | |
| 3198 | /* Saving WEP keys */ |
| 3199 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3200 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3201 | { |
| 3202 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3203 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3204 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3205 | } |
| 3206 | else |
| 3207 | { |
| 3208 | //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] | 3209 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3210 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3211 | } |
| 3212 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3213 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3214 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3215 | { |
| 3216 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3217 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3218 | |
| 3219 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3220 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3221 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3222 | |
| 3223 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3224 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3225 | params->key, params->key_len); |
| 3226 | |
| 3227 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3228 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3229 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3230 | "%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] | 3231 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3232 | setKey.peerMac[2], setKey.peerMac[3], |
| 3233 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3234 | setKey.keyDirection); |
| 3235 | |
| 3236 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3237 | |
| 3238 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3239 | { |
| 3240 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3241 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3242 | __LINE__, vos_status ); |
| 3243 | |
| 3244 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3245 | |
| 3246 | return -EINVAL; |
| 3247 | |
| 3248 | } |
| 3249 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3250 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3251 | /* The supplicant may attempt to set the PTK once pre-authentication is done. |
| 3252 | Save the key in the UMAC and include it in the ADD BSS request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3253 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3254 | if( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_WAIT ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3255 | { |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3256 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3257 | } |
| 3258 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3259 | |
| 3260 | /* issue set key request to SME*/ |
| 3261 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3262 | pAdapter->sessionId, &setKey, &roamId ); |
| 3263 | |
| 3264 | if ( 0 != status ) |
| 3265 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3266 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3267 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3268 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3269 | return -EINVAL; |
| 3270 | } |
| 3271 | |
| 3272 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3273 | /* in case of IBSS as there was no information available about WEP keys during |
| 3274 | * 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] | 3275 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3276 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3277 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3278 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3279 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3280 | ) |
| 3281 | && |
| 3282 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3283 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3284 | ) |
| 3285 | ) |
| 3286 | { |
| 3287 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3288 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3289 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3290 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3291 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3292 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3293 | setKey.peerMac[2], setKey.peerMac[3], |
| 3294 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3295 | setKey.keyDirection); |
| 3296 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3297 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3298 | pAdapter->sessionId, &setKey, &roamId ); |
| 3299 | |
| 3300 | if ( 0 != status ) |
| 3301 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3302 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3303 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3304 | __func__, status); |
| 3305 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3306 | return -EINVAL; |
| 3307 | } |
| 3308 | } |
| 3309 | } |
| 3310 | |
| 3311 | return 0; |
| 3312 | } |
| 3313 | |
| 3314 | /* |
| 3315 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3316 | * This function is used to get the key information |
| 3317 | */ |
| 3318 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3319 | static int wlan_hdd_cfg80211_get_key( |
| 3320 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3321 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3322 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3323 | const u8 *mac_addr, void *cookie, |
| 3324 | void (*callback)(void *cookie, struct key_params*) |
| 3325 | ) |
| 3326 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3327 | static int wlan_hdd_cfg80211_get_key( |
| 3328 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3329 | struct net_device *ndev, |
| 3330 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3331 | void (*callback)(void *cookie, struct key_params*) |
| 3332 | ) |
| 3333 | #endif |
| 3334 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3335 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3336 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3337 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3338 | struct key_params params; |
| 3339 | |
| 3340 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3341 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3342 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3343 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3344 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3345 | memset(¶ms, 0, sizeof(params)); |
| 3346 | |
| 3347 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3348 | { |
| 3349 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3350 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3351 | |
| 3352 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3353 | { |
| 3354 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3355 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3356 | break; |
| 3357 | |
| 3358 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3359 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3360 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3361 | break; |
| 3362 | |
| 3363 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3364 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3365 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3366 | break; |
| 3367 | |
| 3368 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3369 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3370 | break; |
| 3371 | |
| 3372 | case eCSR_ENCRYPT_TYPE_AES: |
| 3373 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3374 | break; |
| 3375 | |
| 3376 | default: |
| 3377 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3378 | break; |
| 3379 | } |
| 3380 | |
| 3381 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3382 | params.seq_len = 0; |
| 3383 | params.seq = NULL; |
| 3384 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3385 | callback(cookie, ¶ms); |
| 3386 | return 0; |
| 3387 | } |
| 3388 | |
| 3389 | /* |
| 3390 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3391 | * This function is used to delete the key information |
| 3392 | */ |
| 3393 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3394 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3395 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3396 | u8 key_index, |
| 3397 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3398 | const u8 *mac_addr |
| 3399 | ) |
| 3400 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3401 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3402 | struct net_device *ndev, |
| 3403 | u8 key_index, |
| 3404 | const u8 *mac_addr |
| 3405 | ) |
| 3406 | #endif |
| 3407 | { |
| 3408 | int status = 0; |
| 3409 | |
| 3410 | //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] | 3411 | //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] | 3412 | //it is observed that this is invalidating peer |
| 3413 | //key index whenever re-key is done. This is affecting data link. |
| 3414 | //It should be ok to ignore del_key. |
| 3415 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3416 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3417 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3418 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3419 | tCsrRoamSetKey setKey; |
| 3420 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3422 | ENTER(); |
| 3423 | |
| 3424 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3425 | __func__,pAdapter->device_mode); |
| 3426 | |
| 3427 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3428 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3429 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3430 | key_index); |
| 3431 | |
| 3432 | return -EINVAL; |
| 3433 | } |
| 3434 | |
| 3435 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3436 | setKey.keyId = key_index; |
| 3437 | |
| 3438 | if (mac_addr) |
| 3439 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3440 | else |
| 3441 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3442 | |
| 3443 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3444 | |
| 3445 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3446 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3447 | ) |
| 3448 | { |
| 3449 | |
| 3450 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3451 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3452 | if( pHostapdState->bssState == BSS_START) |
| 3453 | { |
| 3454 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3455 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3456 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3457 | { |
| 3458 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3459 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3460 | __LINE__, status ); |
| 3461 | } |
| 3462 | } |
| 3463 | } |
| 3464 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3465 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3466 | ) |
| 3467 | { |
| 3468 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3469 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3470 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3471 | |
| 3472 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3473 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3474 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3475 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3476 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3477 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3478 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3479 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3480 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3481 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3482 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3483 | if ( 0 != status ) |
| 3484 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3485 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3486 | "%s: sme_RoamSetKey failure, returned %d", |
| 3487 | __func__, status); |
| 3488 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3489 | return -EINVAL; |
| 3490 | } |
| 3491 | } |
| 3492 | } |
| 3493 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3494 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3495 | return status; |
| 3496 | } |
| 3497 | |
| 3498 | /* |
| 3499 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3500 | * This function is used to set the default tx key index |
| 3501 | */ |
| 3502 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3503 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3504 | struct net_device *ndev, |
| 3505 | u8 key_index, |
| 3506 | bool unicast, bool multicast) |
| 3507 | #else |
| 3508 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3509 | struct net_device *ndev, |
| 3510 | u8 key_index) |
| 3511 | #endif |
| 3512 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3513 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3514 | int status = 0; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3515 | hdd_wext_state_t *pWextState; |
| 3516 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3517 | |
| 3518 | ENTER(); |
| 3519 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3520 | if ((NULL == pAdapter)) |
| 3521 | { |
| 3522 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3523 | "invalid adapter"); |
| 3524 | return -EINVAL; |
| 3525 | } |
| 3526 | |
| 3527 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3528 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3529 | |
| 3530 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3531 | { |
| 3532 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3533 | "invalid Wext state or HDD context"); |
| 3534 | return -EINVAL; |
| 3535 | } |
| 3536 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3537 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3538 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3539 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3540 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3541 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3542 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3543 | key_index); |
| 3544 | |
| 3545 | return -EINVAL; |
| 3546 | } |
| 3547 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3548 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 3549 | { |
| 3550 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3551 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3552 | return -EAGAIN; |
| 3553 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3554 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3555 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3556 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3557 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3558 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3559 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3560 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3561 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3562 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3563 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3564 | { |
| 3565 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3566 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3568 | tCsrRoamSetKey setKey; |
| 3569 | v_U32_t roamId= 0xFF; |
| 3570 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3571 | |
| 3572 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3573 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3574 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3575 | Keys->defaultIndex = (u8)key_index; |
| 3576 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3577 | setKey.keyId = key_index; |
| 3578 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3579 | |
| 3580 | vos_mem_copy(&setKey.Key[0], |
| 3581 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3582 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3583 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3584 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3585 | |
| 3586 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3587 | &pHddStaCtx->conn_info.bssId[0], |
| 3588 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3589 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3590 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3591 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3592 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3593 | { |
| 3594 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3595 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3596 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3597 | type(104) and switching encryption type to 40*/ |
| 3598 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3599 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3600 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3601 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3602 | } |
| 3603 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3604 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3605 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3606 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3607 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3608 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3609 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3611 | if ( 0 != status ) |
| 3612 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3613 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3614 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3615 | status); |
| 3616 | return -EINVAL; |
| 3617 | } |
| 3618 | } |
| 3619 | } |
| 3620 | |
| 3621 | /* In SoftAp mode setting key direction for default mode */ |
| 3622 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3623 | { |
| 3624 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3625 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3626 | (eCSR_ENCRYPT_TYPE_AES != |
| 3627 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3628 | ) |
| 3629 | { |
| 3630 | /* Saving key direction for default key index to TX default */ |
| 3631 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3632 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3633 | } |
| 3634 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3635 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3636 | return status; |
| 3637 | } |
| 3638 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3639 | /* |
| 3640 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3641 | * This function is used to inform the BSS details to nl80211 interface. |
| 3642 | */ |
| 3643 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3644 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3645 | { |
| 3646 | struct net_device *dev = pAdapter->dev; |
| 3647 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3648 | struct wiphy *wiphy = wdev->wiphy; |
| 3649 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3650 | int chan_no; |
| 3651 | int ie_length; |
| 3652 | const char *ie; |
| 3653 | unsigned int freq; |
| 3654 | struct ieee80211_channel *chan; |
| 3655 | int rssi = 0; |
| 3656 | struct cfg80211_bss *bss = NULL; |
| 3657 | |
| 3658 | ENTER(); |
| 3659 | |
| 3660 | if( NULL == pBssDesc ) |
| 3661 | { |
| 3662 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3663 | return bss; |
| 3664 | } |
| 3665 | |
| 3666 | chan_no = pBssDesc->channelId; |
| 3667 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3668 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3669 | |
| 3670 | if( NULL == ie ) |
| 3671 | { |
| 3672 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3673 | return bss; |
| 3674 | } |
| 3675 | |
| 3676 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3677 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3678 | { |
| 3679 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3680 | } |
| 3681 | else |
| 3682 | { |
| 3683 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3684 | } |
| 3685 | #else |
| 3686 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3687 | #endif |
| 3688 | |
| 3689 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3690 | |
| 3691 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3692 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3693 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3694 | if (bss == NULL) |
| 3695 | { |
| 3696 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3697 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3698 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3699 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3700 | pBssDesc->capabilityInfo, |
| 3701 | pBssDesc->beaconInterval, ie, ie_length, |
| 3702 | rssi, GFP_KERNEL )); |
| 3703 | } |
| 3704 | else |
| 3705 | { |
| 3706 | return bss; |
| 3707 | } |
| 3708 | } |
| 3709 | |
| 3710 | |
| 3711 | |
| 3712 | /* |
| 3713 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3714 | * This function is used to inform the BSS details to nl80211 interface. |
| 3715 | */ |
| 3716 | struct cfg80211_bss* |
| 3717 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3718 | tSirBssDescription *bss_desc |
| 3719 | ) |
| 3720 | { |
| 3721 | /* |
| 3722 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3723 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3724 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3725 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3726 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3727 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3728 | cfg80211_inform_bss_frame. |
| 3729 | */ |
| 3730 | struct net_device *dev = pAdapter->dev; |
| 3731 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3732 | struct wiphy *wiphy = wdev->wiphy; |
| 3733 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3734 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3735 | qcom_ie_age *qie_age = NULL; |
| 3736 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3737 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3738 | 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] | 3739 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3740 | const char *ie = |
| 3741 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3742 | unsigned int freq; |
| 3743 | struct ieee80211_channel *chan; |
| 3744 | struct ieee80211_mgmt *mgmt = |
| 3745 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 3746 | struct cfg80211_bss *bss_status = NULL; |
| 3747 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 3748 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3749 | #ifdef WLAN_OPEN_SOURCE |
| 3750 | struct timespec ts; |
| 3751 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3752 | |
| 3753 | ENTER(); |
| 3754 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 3755 | if (!mgmt) |
| 3756 | return NULL; |
| 3757 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3758 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3759 | |
| 3760 | #ifdef WLAN_OPEN_SOURCE |
| 3761 | /* Android does not want the timestamp from the frame. |
| 3762 | Instead it wants a monotonic increasing value */ |
| 3763 | get_monotonic_boottime(&ts); |
| 3764 | mgmt->u.probe_resp.timestamp = |
| 3765 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 3766 | #else |
| 3767 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3768 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 3769 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3770 | |
| 3771 | #endif |
| 3772 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3773 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 3774 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3775 | |
| 3776 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3777 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 3778 | /* Assuming this is the last IE, copy at the end */ |
| 3779 | ie_length -=sizeof(qcom_ie_age); |
| 3780 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 3781 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 3782 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 3783 | qie_age->oui_1 = QCOM_OUI1; |
| 3784 | qie_age->oui_2 = QCOM_OUI2; |
| 3785 | qie_age->oui_3 = QCOM_OUI3; |
| 3786 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 3787 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 3788 | #endif |
| 3789 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3790 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
| 3791 | |
| 3792 | mgmt->frame_control |= |
| 3793 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 3794 | |
| 3795 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3796 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3797 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 3798 | { |
| 3799 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3800 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3801 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3802 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 3803 | |
| 3804 | { |
| 3805 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3806 | } |
| 3807 | else |
| 3808 | { |
| 3809 | kfree(mgmt); |
| 3810 | return NULL; |
| 3811 | } |
| 3812 | #else |
| 3813 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3814 | #endif |
| 3815 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3816 | /*when the band is changed on the fly using the GUI, three things are done |
| 3817 | * 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) |
| 3818 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 3819 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 3820 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 3821 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 3822 | * 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 |
| 3823 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 3824 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 3825 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 3826 | * So drop the bss and continue to next bss. |
| 3827 | */ |
| 3828 | if(chan == NULL) |
| 3829 | { |
| 3830 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 3831 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3832 | return NULL; |
| 3833 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3834 | /*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] | 3835 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3836 | * */ |
| 3837 | if (( eConnectionState_Associated == |
| 3838 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 3839 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 3840 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 3841 | WNI_CFG_BSSID_LEN))) |
| 3842 | { |
| 3843 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 3844 | rssi = (pAdapter->rssi * 100); |
| 3845 | } |
| 3846 | else |
| 3847 | { |
| 3848 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 3849 | } |
| 3850 | |
| 3851 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 3852 | frame_len, rssi, GFP_KERNEL); |
| 3853 | kfree(mgmt); |
| 3854 | return bss_status; |
| 3855 | } |
| 3856 | |
| 3857 | /* |
| 3858 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 3859 | * This function is used to update the BSS data base of CFG8011 |
| 3860 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3861 | 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] | 3862 | tCsrRoamInfo *pRoamInfo |
| 3863 | ) |
| 3864 | { |
| 3865 | tCsrRoamConnectedProfile roamProfile; |
| 3866 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3867 | struct cfg80211_bss *bss = NULL; |
| 3868 | |
| 3869 | ENTER(); |
| 3870 | |
| 3871 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 3872 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 3873 | |
| 3874 | if (NULL != roamProfile.pBssDesc) |
| 3875 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3876 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3877 | &roamProfile); |
| 3878 | |
| 3879 | if (NULL == bss) |
| 3880 | { |
| 3881 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 3882 | __func__); |
| 3883 | } |
| 3884 | |
| 3885 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 3886 | } |
| 3887 | else |
| 3888 | { |
| 3889 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 3890 | __func__); |
| 3891 | } |
| 3892 | return bss; |
| 3893 | } |
| 3894 | |
| 3895 | /* |
| 3896 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 3897 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3898 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 3899 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3900 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3901 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3902 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3903 | tCsrScanResultInfo *pScanResult; |
| 3904 | eHalStatus status = 0; |
| 3905 | tScanResultHandle pResult; |
| 3906 | struct cfg80211_bss *bss_status = NULL; |
| 3907 | |
| 3908 | ENTER(); |
| 3909 | |
| 3910 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 3911 | { |
| 3912 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 3913 | return -EAGAIN; |
| 3914 | } |
| 3915 | |
| 3916 | /* |
| 3917 | * start getting scan results and populate cgf80211 BSS database |
| 3918 | */ |
| 3919 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 3920 | |
| 3921 | /* no scan results */ |
| 3922 | if (NULL == pResult) |
| 3923 | { |
| 3924 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 3925 | return status; |
| 3926 | } |
| 3927 | |
| 3928 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 3929 | |
| 3930 | while (pScanResult) |
| 3931 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3932 | /* |
| 3933 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 3934 | * entry already exists in bss data base of cfg80211 for that |
| 3935 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 3936 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 3937 | * mgmt packet as input. As of now there is no possibility to get |
| 3938 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3939 | * ieee80211_mgmt(probe response) and passing to c |
| 3940 | * fg80211_inform_bss_frame. |
| 3941 | * */ |
| 3942 | |
| 3943 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 3944 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3945 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3946 | |
| 3947 | if (NULL == bss_status) |
| 3948 | { |
| 3949 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3950 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 3951 | } |
| 3952 | else |
| 3953 | { |
| 3954 | cfg80211_put_bss(bss_status); |
| 3955 | } |
| 3956 | |
| 3957 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 3958 | } |
| 3959 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3960 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3961 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3962 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3963 | } |
| 3964 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3965 | void |
| 3966 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 3967 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3968 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 3969 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 3970 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 3971 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3972 | } /****** end hddPrintMacAddr() ******/ |
| 3973 | |
| 3974 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 3975 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3976 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3977 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 3978 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 3979 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 3980 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 3981 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3982 | } /****** end hddPrintPmkId() ******/ |
| 3983 | |
| 3984 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 3985 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 3986 | |
| 3987 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 3988 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 3989 | |
| 3990 | #define dump_bssid(bssid) \ |
| 3991 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3992 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 3993 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 3994 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3995 | } |
| 3996 | |
| 3997 | #define dump_pmkid(pMac, pmkid) \ |
| 3998 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3999 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4000 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4001 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4002 | } |
| 4003 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4004 | #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] | 4005 | /* |
| 4006 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4007 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4008 | */ |
| 4009 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4010 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4011 | int index, bool preauth ) |
| 4012 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4013 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4014 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4015 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4016 | |
| 4017 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4018 | 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] | 4019 | |
| 4020 | if( NULL == pRoamInfo ) |
| 4021 | { |
| 4022 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4023 | return -EINVAL; |
| 4024 | } |
| 4025 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4026 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4027 | { |
| 4028 | dump_bssid(pRoamInfo->bssid); |
| 4029 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4030 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4031 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4032 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4033 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4034 | } |
| 4035 | #endif //FEATURE_WLAN_LFR |
| 4036 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4037 | /* |
| 4038 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4039 | * scanning callback function, called after finishing scan |
| 4040 | * |
| 4041 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4042 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4043 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4044 | { |
| 4045 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4046 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4047 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4048 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4049 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4050 | struct cfg80211_scan_request *req = NULL; |
| 4051 | int ret = 0; |
| 4052 | |
| 4053 | ENTER(); |
| 4054 | |
| 4055 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4056 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4057 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4058 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4059 | |
| 4060 | //Block on scan req completion variable. Can't wait forever though. |
| 4061 | ret = wait_for_completion_interruptible_timeout( |
| 4062 | &pScanInfo->scan_req_completion_event, |
| 4063 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4064 | if (!ret) |
| 4065 | { |
| 4066 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4067 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4068 | } |
| 4069 | |
| 4070 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4071 | { |
| 4072 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4073 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4074 | } |
| 4075 | |
| 4076 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4077 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4078 | { |
| 4079 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4080 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4081 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4082 | (int) scanId); |
| 4083 | } |
| 4084 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4085 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4086 | pAdapter); |
| 4087 | |
| 4088 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4089 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4090 | |
| 4091 | |
| 4092 | /* If any client wait scan result through WEXT |
| 4093 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4094 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4095 | { |
| 4096 | /* The other scan request waiting for current scan finish |
| 4097 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4098 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4099 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4100 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4101 | } |
| 4102 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4103 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4104 | { |
| 4105 | struct net_device *dev = pAdapter->dev; |
| 4106 | union iwreq_data wrqu; |
| 4107 | int we_event; |
| 4108 | char *msg; |
| 4109 | |
| 4110 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4111 | we_event = SIOCGIWSCAN; |
| 4112 | msg = NULL; |
| 4113 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4114 | } |
| 4115 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4116 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4117 | |
| 4118 | /* Get the Scan Req */ |
| 4119 | req = pAdapter->request; |
| 4120 | |
| 4121 | if (!req) |
| 4122 | { |
| 4123 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4124 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4125 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | /* |
| 4129 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4130 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4131 | req->n_ssids = 0; |
| 4132 | req->n_channels = 0; |
| 4133 | req->ie = 0; |
| 4134 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4135 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4136 | /* Scan is no longer pending */ |
| 4137 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4138 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4139 | /* |
| 4140 | * cfg80211_scan_done informing NL80211 about completion |
| 4141 | * of scanning |
| 4142 | */ |
| 4143 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4144 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4145 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4146 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4147 | /* release the wake lock at the end of the scan*/ |
| 4148 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4149 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4150 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4151 | * immediatly after the driver gets connect request(i.e after scan) |
| 4152 | * from supplicant, this result in app's is suspending and not able |
| 4153 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4154 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4155 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4156 | #ifdef FEATURE_WLAN_TDLS |
| 4157 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4158 | #endif |
| 4159 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4160 | EXIT(); |
| 4161 | return 0; |
| 4162 | } |
| 4163 | |
| 4164 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4165 | * FUNCTION: hdd_isScanAllowed |
| 4166 | * Go through each adapter and check if scan allowed |
| 4167 | * |
| 4168 | */ |
| 4169 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4170 | { |
| 4171 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4172 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4173 | hdd_adapter_t *pAdapter = NULL; |
| 4174 | VOS_STATUS status = 0; |
| 4175 | v_U8_t staId = 0; |
| 4176 | v_U8_t *staMac = NULL; |
| 4177 | |
| 4178 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4179 | |
| 4180 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4181 | { |
| 4182 | pAdapter = pAdapterNode->pAdapter; |
| 4183 | |
| 4184 | if( pAdapter ) |
| 4185 | { |
| 4186 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4187 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4188 | __func__, pAdapter->device_mode); |
| 4189 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4190 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4191 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4192 | { |
| 4193 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4194 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4195 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4196 | { |
| 4197 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4198 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4199 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4200 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4201 | staMac[0], staMac[1], staMac[2], |
| 4202 | staMac[3], staMac[4], staMac[5]); |
| 4203 | return VOS_FALSE; |
| 4204 | } |
| 4205 | } |
| 4206 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4207 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4208 | { |
| 4209 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4210 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4211 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4212 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4213 | { |
| 4214 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4215 | |
| 4216 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4217 | "%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] | 4218 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4219 | staMac[0], staMac[1], staMac[2], |
| 4220 | staMac[3], staMac[4], staMac[5]); |
| 4221 | return VOS_FALSE; |
| 4222 | } |
| 4223 | } |
| 4224 | } |
| 4225 | } |
| 4226 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4227 | pAdapterNode = pNext; |
| 4228 | } |
| 4229 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4230 | "%s: Scan allowed", __func__); |
| 4231 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4232 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4233 | |
| 4234 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4235 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4236 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4237 | * later, scan dump command can be used to recieve scan results |
| 4238 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4239 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4240 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4241 | struct net_device *dev, |
| 4242 | #endif |
| 4243 | struct cfg80211_scan_request *request) |
| 4244 | { |
| 4245 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4246 | struct net_device *dev = request->wdev->netdev; |
| 4247 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4248 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4249 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4250 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4251 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 4252 | tCsrScanRequest scanRequest; |
| 4253 | tANI_U8 *channelList = NULL, i; |
| 4254 | v_U32_t scanId = 0; |
| 4255 | int status = 0; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4256 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4257 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4258 | |
| 4259 | ENTER(); |
| 4260 | |
| 4261 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4262 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4263 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4264 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4265 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4266 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4267 | { |
| 4268 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4269 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4270 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4271 | return -EBUSY; |
| 4272 | } |
| 4273 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4274 | #ifdef WLAN_BTAMP_FEATURE |
| 4275 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4276 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4277 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4278 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4279 | "%s: No scanning when AMP is on", __func__); |
| 4280 | return -EOPNOTSUPP; |
| 4281 | } |
| 4282 | #endif |
| 4283 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4284 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4285 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4286 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4287 | "%s: Not scanning on device_mode = %d", |
| 4288 | __func__, pAdapter->device_mode); |
| 4289 | return -EOPNOTSUPP; |
| 4290 | } |
| 4291 | |
| 4292 | if (TRUE == pScanInfo->mScanPending) |
| 4293 | { |
| 4294 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4295 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4296 | } |
| 4297 | |
| 4298 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4299 | { |
| 4300 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4301 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 4302 | return -EAGAIN; |
| 4303 | } |
| 4304 | |
Mohit Khanna | 6c52bbf | 2012-09-11 15:10:12 -0700 | [diff] [blame] | 4305 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLoadUnloadInProgress) |
| 4306 | { |
| 4307 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4308 | "%s:Unloading/Loading in Progress. Ignore!!!", __func__); |
| 4309 | return -EAGAIN; |
| 4310 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4311 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4312 | //Channel and action frame is pending |
| 4313 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4314 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4315 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4316 | { |
| 4317 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4318 | return -EBUSY; |
| 4319 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4320 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4321 | /* if tdls disagree scan right now, return immediately. |
| 4322 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4323 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4324 | */ |
| 4325 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4326 | wiphy, |
| 4327 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4328 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4329 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4330 | request); |
| 4331 | if(status <= 0) |
| 4332 | { |
| 4333 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4334 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4335 | } |
| 4336 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4338 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4339 | { |
| 4340 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4341 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4342 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4343 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4344 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4345 | { |
| 4346 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4347 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4348 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4349 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4350 | } |
| 4351 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4352 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4353 | /* Check if scan is allowed at this point of time. |
| 4354 | */ |
| 4355 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4356 | { |
| 4357 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4358 | return -EBUSY; |
| 4359 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4360 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4361 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4362 | |
| 4363 | if (NULL != request) |
| 4364 | { |
| 4365 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4366 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4367 | |
| 4368 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4369 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4370 | * is not aging out the scan results. |
| 4371 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4372 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4373 | { |
| 4374 | request->n_ssids = 0; |
| 4375 | } |
| 4376 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4377 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4378 | { |
| 4379 | tCsrSSIDInfo *SsidInfo; |
| 4380 | int j; |
| 4381 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4382 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4383 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4384 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4385 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4386 | |
| 4387 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4388 | { |
| 4389 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4390 | "memory alloc failed SSIDInfo buffer"); |
| 4391 | return -ENOMEM; |
| 4392 | } |
| 4393 | |
| 4394 | /* copy all the ssid's and their length */ |
| 4395 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4396 | { |
| 4397 | /* get the ssid length */ |
| 4398 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4399 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4400 | SsidInfo->SSID.length); |
| 4401 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4402 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4403 | j, SsidInfo->SSID.ssId); |
| 4404 | } |
| 4405 | /* set the scan type to active */ |
| 4406 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4407 | } |
| 4408 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4409 | { |
| 4410 | /* set the scan type to active */ |
| 4411 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4412 | } |
| 4413 | else |
| 4414 | { |
| 4415 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4416 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4417 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4418 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4419 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4420 | } |
| 4421 | else |
| 4422 | { |
| 4423 | /* set the scan type to active */ |
| 4424 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4425 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4426 | |
| 4427 | /* set min and max channel time to zero */ |
| 4428 | scanRequest.minChnTime = 0; |
| 4429 | scanRequest.maxChnTime = 0; |
| 4430 | } |
| 4431 | |
| 4432 | /* set BSSType to default type */ |
| 4433 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4434 | |
| 4435 | /*TODO: scan the requested channels only*/ |
| 4436 | |
| 4437 | /*Right now scanning all the channels */ |
| 4438 | if( request ) |
| 4439 | { |
| 4440 | if( request->n_channels ) |
| 4441 | { |
| 4442 | channelList = vos_mem_malloc( request->n_channels ); |
| 4443 | if( NULL == channelList ) |
| 4444 | { |
| 4445 | status = -ENOMEM; |
| 4446 | goto free_mem; |
| 4447 | } |
| 4448 | |
| 4449 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4450 | channelList[i] = request->channels[i]->hw_value; |
| 4451 | } |
| 4452 | |
| 4453 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4454 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4455 | |
| 4456 | /* set requestType to full scan */ |
| 4457 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4458 | |
| 4459 | /* 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] | 4460 | * 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] | 4461 | * 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] | 4462 | */ |
| 4463 | |
| 4464 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4465 | * and in that case driver shoudnt flush scan results. If |
| 4466 | * driver flushes the scan results here and unfortunately if |
| 4467 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4468 | * fails which is not desired |
| 4469 | */ |
| 4470 | |
| 4471 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4472 | { |
| 4473 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4474 | pAdapter->sessionId ); |
| 4475 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4476 | |
| 4477 | if( request->ie_len ) |
| 4478 | { |
| 4479 | /* save this for future association (join requires this) */ |
| 4480 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4481 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4482 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4483 | |
| 4484 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4485 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4486 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4487 | ) |
| 4488 | { |
| 4489 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4490 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4491 | } |
| 4492 | |
| 4493 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4494 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4495 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4496 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4497 | request->ie_len); |
| 4498 | if (pP2pIe != NULL) |
| 4499 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4500 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4501 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4502 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4503 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4504 | { |
| 4505 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4506 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4507 | "Go nego completed to Connection is started"); |
| 4508 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4509 | "for 8way Handshake"); |
| 4510 | } |
| 4511 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4512 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4513 | { |
| 4514 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4515 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4516 | "Disconnected state to Connection is started"); |
| 4517 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4518 | "for 4way Handshake"); |
| 4519 | } |
| 4520 | #endif |
| 4521 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4522 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4523 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4524 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4525 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4526 | "%s: This is a P2P Search", __func__); |
| 4527 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4528 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4529 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4530 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4531 | /* set requestType to P2P Discovery */ |
| 4532 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4533 | } |
| 4534 | |
| 4535 | /* |
| 4536 | Skip Dfs Channel in case of P2P Search |
| 4537 | if it is set in ini file |
| 4538 | */ |
| 4539 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4540 | { |
| 4541 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4542 | } |
| 4543 | else |
| 4544 | { |
| 4545 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4546 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4547 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4548 | } |
| 4549 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4550 | } |
| 4551 | } |
| 4552 | |
| 4553 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4554 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4555 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4556 | * address the following issues. |
| 4557 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4558 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4559 | * for long time, this result in apps running at full power for long time. |
| 4560 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4561 | * be stuck in full power because of resume BMPS |
| 4562 | */ |
| 4563 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4564 | |
| 4565 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4566 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4567 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4568 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4569 | if (eHAL_STATUS_SUCCESS != status) |
| 4570 | { |
| 4571 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4572 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4573 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4574 | if(eHAL_STATUS_RESOURCES == status) |
| 4575 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4576 | 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] | 4577 | status = -EBUSY; |
| 4578 | } else { |
| 4579 | status = -EIO; |
| 4580 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4581 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4582 | goto free_mem; |
| 4583 | } |
| 4584 | |
| 4585 | pScanInfo->mScanPending = TRUE; |
| 4586 | pAdapter->request = request; |
| 4587 | pScanInfo->scanId = scanId; |
| 4588 | |
| 4589 | complete(&pScanInfo->scan_req_completion_event); |
| 4590 | |
| 4591 | free_mem: |
| 4592 | if( scanRequest.SSIDs.SSIDList ) |
| 4593 | { |
| 4594 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4595 | } |
| 4596 | |
| 4597 | if( channelList ) |
| 4598 | vos_mem_free( channelList ); |
| 4599 | |
| 4600 | EXIT(); |
| 4601 | |
| 4602 | return status; |
| 4603 | } |
| 4604 | |
| 4605 | /* |
| 4606 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4607 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4608 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4609 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4610 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4611 | { |
| 4612 | int status = 0; |
| 4613 | hdd_wext_state_t *pWextState; |
| 4614 | v_U32_t roamId; |
| 4615 | tCsrRoamProfile *pRoamProfile; |
| 4616 | eMib_dot11DesiredBssType connectedBssType; |
| 4617 | eCsrAuthType RSNAuthType; |
| 4618 | |
| 4619 | ENTER(); |
| 4620 | |
| 4621 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4622 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4623 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4624 | { |
| 4625 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4626 | return -EINVAL; |
| 4627 | } |
| 4628 | |
| 4629 | pRoamProfile = &pWextState->roamProfile; |
| 4630 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4631 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4632 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4633 | int ret = 0; |
| 4634 | hdd_station_ctx_t *pHddStaCtx; |
| 4635 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4636 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4637 | |
| 4638 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4639 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4640 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4641 | { |
| 4642 | /* Issue disconnect to CSR */ |
| 4643 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4644 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4645 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4646 | pAdapter->sessionId, |
| 4647 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4648 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4649 | ret = wait_for_completion_interruptible_timeout( |
| 4650 | &pAdapter->disconnect_comp_var, |
| 4651 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4652 | if (0 == ret) |
| 4653 | { |
| 4654 | VOS_ASSERT(0); |
| 4655 | } |
| 4656 | } |
| 4657 | } |
| 4658 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4659 | { |
| 4660 | ret = wait_for_completion_interruptible_timeout( |
| 4661 | &pAdapter->disconnect_comp_var, |
| 4662 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4663 | if (0 == ret) |
| 4664 | { |
| 4665 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4666 | } |
| 4667 | } |
| 4668 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4669 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4670 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4671 | { |
| 4672 | /*QoS not enabled in cfg file*/ |
| 4673 | pRoamProfile->uapsd_mask = 0; |
| 4674 | } |
| 4675 | else |
| 4676 | { |
| 4677 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4678 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4679 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4680 | } |
| 4681 | |
| 4682 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4683 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4684 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4685 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4686 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4687 | ssid, ssid_len); |
| 4688 | |
| 4689 | if (bssid) |
| 4690 | { |
| 4691 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4692 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4693 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4694 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4695 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4696 | case of join failure we should send valid BSSID to supplicant |
| 4697 | */ |
| 4698 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4699 | WNI_CFG_BSSID_LEN); |
| 4700 | } |
| 4701 | |
| 4702 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 4703 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4704 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4705 | /*set gen ie*/ |
| 4706 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 4707 | /*set auth*/ |
| 4708 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 4709 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4710 | #ifdef FEATURE_WLAN_WAPI |
| 4711 | if (pAdapter->wapi_info.nWapiMode) |
| 4712 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4713 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4714 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 4715 | { |
| 4716 | case WAPI_AUTH_MODE_PSK: |
| 4717 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4718 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4719 | pAdapter->wapi_info.wapiAuthMode); |
| 4720 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 4721 | break; |
| 4722 | } |
| 4723 | case WAPI_AUTH_MODE_CERT: |
| 4724 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4725 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4726 | pAdapter->wapi_info.wapiAuthMode); |
| 4727 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 4728 | break; |
| 4729 | } |
| 4730 | } // End of switch |
| 4731 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 4732 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 4733 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4734 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4735 | pRoamProfile->AuthType.numEntries = 1; |
| 4736 | pRoamProfile->EncryptionType.numEntries = 1; |
| 4737 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4738 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 4739 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4740 | } |
| 4741 | } |
| 4742 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 4743 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 4744 | /* Initializing gtkOffloadRequestParams */ |
| 4745 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4746 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4747 | { |
| 4748 | pHddStaCtx->gtkOffloadRequestParams.requested = FALSE; |
| 4749 | memset(&pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams, |
| 4750 | 0, sizeof (tSirGtkOffloadParams)); |
| 4751 | } |
| 4752 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4753 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 4754 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4755 | if( operatingChannel ) |
| 4756 | { |
| 4757 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 4758 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 4759 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 4760 | else |
| 4761 | { |
| 4762 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4763 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4764 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4765 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4766 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 4767 | * 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] | 4768 | * 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] | 4769 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4770 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 4771 | */ |
| 4772 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 4773 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 4774 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4775 | |
| 4776 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4777 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 4778 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4779 | if( (eHAL_STATUS_SUCCESS != status) && |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4780 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 4781 | |
| 4782 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4783 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 4784 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 4785 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4786 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4787 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4788 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4789 | |
| 4790 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4791 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4792 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4793 | } |
| 4794 | else |
| 4795 | { |
| 4796 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 4797 | return -EINVAL; |
| 4798 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4799 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4800 | return status; |
| 4801 | } |
| 4802 | |
| 4803 | /* |
| 4804 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 4805 | * This function is used to set the authentication type (OPEN/SHARED). |
| 4806 | * |
| 4807 | */ |
| 4808 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 4809 | enum nl80211_auth_type auth_type) |
| 4810 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4811 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4812 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4813 | |
| 4814 | ENTER(); |
| 4815 | |
| 4816 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4817 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4818 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4819 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4820 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4821 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 4822 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 4823 | break; |
| 4824 | |
| 4825 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 4826 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4827 | case NL80211_AUTHTYPE_FT: |
| 4828 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4829 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4830 | "%s: set authentication type to OPEN", __func__); |
| 4831 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 4832 | break; |
| 4833 | |
| 4834 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4835 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4836 | "%s: set authentication type to SHARED", __func__); |
| 4837 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 4838 | break; |
| 4839 | #ifdef FEATURE_WLAN_CCX |
| 4840 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4841 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4842 | "%s: set authentication type to CCKM WPA", __func__); |
| 4843 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 4844 | break; |
| 4845 | #endif |
| 4846 | |
| 4847 | |
| 4848 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4849 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4850 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4851 | auth_type); |
| 4852 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 4853 | return -EINVAL; |
| 4854 | } |
| 4855 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4856 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4857 | pHddStaCtx->conn_info.authType; |
| 4858 | return 0; |
| 4859 | } |
| 4860 | |
| 4861 | /* |
| 4862 | * FUNCTION: wlan_hdd_set_akm_suite |
| 4863 | * This function is used to set the key mgmt type(PSK/8021x). |
| 4864 | * |
| 4865 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4866 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4867 | u32 key_mgmt |
| 4868 | ) |
| 4869 | { |
| 4870 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4871 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4872 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4873 | /*set key mgmt type*/ |
| 4874 | switch(key_mgmt) |
| 4875 | { |
| 4876 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 4877 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4878 | case WLAN_AKM_SUITE_FT_PSK: |
| 4879 | #endif |
| 4880 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4881 | __func__); |
| 4882 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 4883 | break; |
| 4884 | |
| 4885 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 4886 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4887 | case WLAN_AKM_SUITE_FT_8021X: |
| 4888 | #endif |
| 4889 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4890 | __func__); |
| 4891 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 4892 | break; |
| 4893 | #ifdef FEATURE_WLAN_CCX |
| 4894 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 4895 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 4896 | case WLAN_AKM_SUITE_CCKM: |
| 4897 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 4898 | __func__); |
| 4899 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 4900 | break; |
| 4901 | #endif |
| 4902 | |
| 4903 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4904 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4905 | __func__, key_mgmt); |
| 4906 | return -EINVAL; |
| 4907 | |
| 4908 | } |
| 4909 | return 0; |
| 4910 | } |
| 4911 | |
| 4912 | /* |
| 4913 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4914 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4915 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 4916 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4917 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 4918 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4919 | bool ucast |
| 4920 | ) |
| 4921 | { |
| 4922 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4923 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4924 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4925 | |
| 4926 | ENTER(); |
| 4927 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4928 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4929 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4930 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4931 | __func__, cipher); |
| 4932 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 4933 | } |
| 4934 | else |
| 4935 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4936 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4937 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4938 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4939 | { |
| 4940 | case IW_AUTH_CIPHER_NONE: |
| 4941 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 4942 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4943 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4944 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4945 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4946 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4947 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4948 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4949 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4950 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4951 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4952 | case WLAN_CIPHER_SUITE_TKIP: |
| 4953 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 4954 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4955 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4956 | case WLAN_CIPHER_SUITE_CCMP: |
| 4957 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 4958 | break; |
| 4959 | #ifdef FEATURE_WLAN_WAPI |
| 4960 | case WLAN_CIPHER_SUITE_SMS4: |
| 4961 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 4962 | break; |
| 4963 | #endif |
| 4964 | |
| 4965 | #ifdef FEATURE_WLAN_CCX |
| 4966 | case WLAN_CIPHER_SUITE_KRK: |
| 4967 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 4968 | break; |
| 4969 | #endif |
| 4970 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4971 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4972 | __func__, cipher); |
| 4973 | return -EOPNOTSUPP; |
| 4974 | } |
| 4975 | } |
| 4976 | |
| 4977 | if (ucast) |
| 4978 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4979 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4980 | __func__, encryptionType); |
| 4981 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 4982 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4983 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4984 | encryptionType; |
| 4985 | } |
| 4986 | else |
| 4987 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4988 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4989 | __func__, encryptionType); |
| 4990 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 4991 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 4992 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 4993 | } |
| 4994 | |
| 4995 | return 0; |
| 4996 | } |
| 4997 | |
| 4998 | |
| 4999 | /* |
| 5000 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5001 | * This function is used to parse WPA/RSN IE's. |
| 5002 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5003 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5004 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5005 | size_t ie_len |
| 5006 | ) |
| 5007 | { |
| 5008 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5009 | u8 *genie = ie; |
| 5010 | v_U16_t remLen = ie_len; |
| 5011 | #ifdef FEATURE_WLAN_WAPI |
| 5012 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5013 | u16 *tmp; |
| 5014 | v_U16_t akmsuiteCount; |
| 5015 | int *akmlist; |
| 5016 | #endif |
| 5017 | ENTER(); |
| 5018 | |
| 5019 | /* clear previous assocAddIE */ |
| 5020 | pWextState->assocAddIE.length = 0; |
| 5021 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5022 | |
| 5023 | while (remLen >= 2) |
| 5024 | { |
| 5025 | v_U16_t eLen = 0; |
| 5026 | v_U8_t elementId; |
| 5027 | elementId = *genie++; |
| 5028 | eLen = *genie++; |
| 5029 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5030 | |
| 5031 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5032 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5033 | |
| 5034 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5035 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5036 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5037 | 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] | 5038 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5039 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5040 | "%s: Invalid WPA IE", __func__); |
| 5041 | return -EINVAL; |
| 5042 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5043 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5044 | { |
| 5045 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5046 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5047 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5048 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5049 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5050 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5051 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5052 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5053 | VOS_ASSERT(0); |
| 5054 | return -ENOMEM; |
| 5055 | } |
| 5056 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5057 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5058 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5059 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5060 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5061 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5062 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5063 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5064 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5065 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5066 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5067 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5068 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5069 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5070 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5071 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5072 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5073 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5074 | /*Consider P2P IE, only for P2P Client */ |
| 5075 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5076 | { |
| 5077 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5078 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5079 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5080 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5081 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5082 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5083 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5084 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5085 | VOS_ASSERT(0); |
| 5086 | return -ENOMEM; |
| 5087 | } |
| 5088 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5089 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5090 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5091 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5092 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5093 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5094 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5095 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5096 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5097 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5098 | /*Consider WFD IE, only for P2P Client */ |
| 5099 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5100 | { |
| 5101 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5102 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5103 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5104 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5105 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5106 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5107 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5108 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | VOS_ASSERT(0); |
| 5110 | return -ENOMEM; |
| 5111 | } |
| 5112 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5113 | // WPS IE + P2P IE + WFD IE |
| 5114 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5115 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5116 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5117 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5118 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5119 | } |
| 5120 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5121 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5122 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5123 | HS20_OUI_TYPE_SIZE)) ) |
| 5124 | { |
| 5125 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5126 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5127 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5128 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5129 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5130 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5131 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5132 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5133 | VOS_ASSERT(0); |
| 5134 | return -ENOMEM; |
| 5135 | } |
| 5136 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5137 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5138 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5139 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5140 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5141 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5142 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5143 | break; |
| 5144 | case DOT11F_EID_RSN: |
| 5145 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5146 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5147 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5148 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5149 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5150 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5151 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5152 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5153 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5154 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5155 | 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] | 5156 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5157 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5158 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5159 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5160 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5161 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5162 | VOS_ASSERT(0); |
| 5163 | return -ENOMEM; |
| 5164 | } |
| 5165 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5166 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5167 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5168 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5169 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5170 | break; |
| 5171 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5172 | #ifdef FEATURE_WLAN_WAPI |
| 5173 | case WLAN_EID_WAPI: |
| 5174 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5175 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5176 | pAdapter->wapi_info.nWapiMode); |
| 5177 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5178 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5179 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5180 | tmp = tmp + 1; |
| 5181 | akmlist = (int *)(tmp); |
| 5182 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5183 | { |
| 5184 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5185 | } |
| 5186 | else |
| 5187 | { |
| 5188 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5189 | VOS_ASSERT(0); |
| 5190 | return -EINVAL; |
| 5191 | } |
| 5192 | |
| 5193 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5194 | { |
| 5195 | 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] | 5196 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5197 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5198 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5199 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5200 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5201 | 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] | 5202 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5203 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5204 | } |
| 5205 | break; |
| 5206 | #endif |
| 5207 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5208 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5209 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5210 | /* when Unknown IE is received we should break and continue |
| 5211 | * to the next IE in the buffer instead we were returning |
| 5212 | * so changing this to break */ |
| 5213 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5214 | } |
| 5215 | genie += eLen; |
| 5216 | remLen -= eLen; |
| 5217 | } |
| 5218 | EXIT(); |
| 5219 | return 0; |
| 5220 | } |
| 5221 | |
| 5222 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5223 | * FUNCTION: hdd_isWPAIEPresent |
| 5224 | * Parse the received IE to find the WPA IE |
| 5225 | * |
| 5226 | */ |
| 5227 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5228 | { |
| 5229 | v_U8_t eLen = 0; |
| 5230 | v_U16_t remLen = ie_len; |
| 5231 | v_U8_t elementId = 0; |
| 5232 | |
| 5233 | while (remLen >= 2) |
| 5234 | { |
| 5235 | elementId = *ie++; |
| 5236 | eLen = *ie++; |
| 5237 | remLen -= 2; |
| 5238 | if (eLen > remLen) |
| 5239 | { |
| 5240 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5241 | "%s: IE length is wrong %d", __func__, eLen); |
| 5242 | return FALSE; |
| 5243 | } |
| 5244 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5245 | { |
| 5246 | /* OUI - 0x00 0X50 0XF2 |
| 5247 | WPA Information Element - 0x01 |
| 5248 | WPA version - 0x01*/ |
| 5249 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5250 | return TRUE; |
| 5251 | } |
| 5252 | ie += eLen; |
| 5253 | remLen -= eLen; |
| 5254 | } |
| 5255 | return FALSE; |
| 5256 | } |
| 5257 | |
| 5258 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5259 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5260 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5261 | * parameters during connect operation. |
| 5262 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5263 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5264 | struct cfg80211_connect_params *req |
| 5265 | ) |
| 5266 | { |
| 5267 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5268 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5269 | ENTER(); |
| 5270 | |
| 5271 | /*set wpa version*/ |
| 5272 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5273 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5274 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5275 | { |
| 5276 | if ( (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5277 | && ( (req->ie_len) |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5278 | && (hdd_isWPAIEPresent(req->ie, req->ie_len) ) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5279 | // Make sure that it is including a WPA IE. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5280 | /* Currently NL is putting WPA version 1 even for open, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5281 | * since p2p ie is also put in same buffer. |
| 5282 | * */ |
| 5283 | { |
| 5284 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5285 | } |
| 5286 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5287 | { |
| 5288 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5289 | } |
| 5290 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5291 | |
| 5292 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5293 | pWextState->wpaVersion); |
| 5294 | |
| 5295 | /*set authentication type*/ |
| 5296 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5297 | |
| 5298 | if (0 > status) |
| 5299 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5300 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5301 | "%s: failed to set authentication type ", __func__); |
| 5302 | return status; |
| 5303 | } |
| 5304 | |
| 5305 | /*set key mgmt type*/ |
| 5306 | if (req->crypto.n_akm_suites) |
| 5307 | { |
| 5308 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5309 | if (0 > status) |
| 5310 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5311 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5312 | __func__); |
| 5313 | return status; |
| 5314 | } |
| 5315 | } |
| 5316 | |
| 5317 | /*set pairwise cipher type*/ |
| 5318 | if (req->crypto.n_ciphers_pairwise) |
| 5319 | { |
| 5320 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5321 | req->crypto.ciphers_pairwise[0], true); |
| 5322 | if (0 > status) |
| 5323 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5324 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5325 | "%s: failed to set unicast cipher type", __func__); |
| 5326 | return status; |
| 5327 | } |
| 5328 | } |
| 5329 | else |
| 5330 | { |
| 5331 | /*Reset previous cipher suite to none*/ |
| 5332 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5333 | if (0 > status) |
| 5334 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5335 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5336 | "%s: failed to set unicast cipher type", __func__); |
| 5337 | return status; |
| 5338 | } |
| 5339 | } |
| 5340 | |
| 5341 | /*set group cipher type*/ |
| 5342 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5343 | false); |
| 5344 | |
| 5345 | if (0 > status) |
| 5346 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5347 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5348 | __func__); |
| 5349 | return status; |
| 5350 | } |
| 5351 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5352 | #ifdef WLAN_FEATURE_11W |
| 5353 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5354 | #endif |
| 5355 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5356 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5357 | if (req->ie_len) |
| 5358 | { |
| 5359 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5360 | if ( 0 > status) |
| 5361 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5362 | 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] | 5363 | __func__); |
| 5364 | return status; |
| 5365 | } |
| 5366 | } |
| 5367 | |
| 5368 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5369 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5370 | { |
| 5371 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5372 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5373 | ) |
| 5374 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5375 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5376 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5377 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5378 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5379 | __func__); |
| 5380 | return -EOPNOTSUPP; |
| 5381 | } |
| 5382 | else |
| 5383 | { |
| 5384 | u8 key_len = req->key_len; |
| 5385 | u8 key_idx = req->key_idx; |
| 5386 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5387 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5388 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5389 | ) |
| 5390 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5391 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5392 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5393 | __func__, key_idx, key_len); |
| 5394 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5395 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5396 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5397 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5398 | (u8)key_len; |
| 5399 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5400 | } |
| 5401 | } |
| 5402 | } |
| 5403 | } |
| 5404 | |
| 5405 | return status; |
| 5406 | } |
| 5407 | |
| 5408 | /* |
| 5409 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5410 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5411 | * parameters during connect operation. |
| 5412 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5413 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5414 | struct net_device *ndev, |
| 5415 | struct cfg80211_connect_params *req |
| 5416 | ) |
| 5417 | { |
| 5418 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5419 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5420 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5421 | hdd_context_t *pHddCtx = NULL; |
| 5422 | |
| 5423 | ENTER(); |
| 5424 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5425 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5426 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5427 | |
| 5428 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5429 | { |
| 5430 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5431 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5432 | return -EAGAIN; |
| 5433 | } |
| 5434 | |
| 5435 | #ifdef WLAN_BTAMP_FEATURE |
| 5436 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5437 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5438 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5439 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5440 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5441 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5442 | } |
| 5443 | #endif |
| 5444 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5445 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5446 | |
| 5447 | if ( 0 > status) |
| 5448 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5449 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5450 | __func__); |
| 5451 | return status; |
| 5452 | } |
| 5453 | |
| 5454 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5455 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5456 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5457 | (vos_concurrent_sessions_running())) |
| 5458 | { |
| 5459 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 5460 | |
| 5461 | if (NULL != pVosContext) |
| 5462 | { |
| 5463 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 5464 | if(NULL != pHddCtx) |
| 5465 | { |
| 5466 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 5467 | } |
| 5468 | } |
| 5469 | } |
| 5470 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5471 | if ( req->channel ) |
| 5472 | { |
| 5473 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5474 | req->ssid_len, req->bssid, |
| 5475 | req->channel->hw_value); |
| 5476 | } |
| 5477 | else |
| 5478 | { |
| 5479 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5480 | req->ssid_len, req->bssid, |
| 5481 | 0); |
| 5482 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5483 | |
| 5484 | if (0 > status) |
| 5485 | { |
| 5486 | //ReEnable BMPS if disabled |
| 5487 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5488 | (NULL != pHddCtx)) |
| 5489 | { |
| 5490 | //ReEnable Bmps and Imps back |
| 5491 | hdd_enable_bmps_imps(pHddCtx); |
| 5492 | } |
| 5493 | |
| 5494 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5495 | return status; |
| 5496 | } |
| 5497 | (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE; |
| 5498 | EXIT(); |
| 5499 | return status; |
| 5500 | } |
| 5501 | |
| 5502 | |
| 5503 | /* |
| 5504 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5505 | * This function is used to issue a disconnect request to SME |
| 5506 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5507 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5508 | struct net_device *dev, |
| 5509 | u16 reason |
| 5510 | ) |
| 5511 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5512 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5513 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5514 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
| 5515 | int status = 0; |
| 5516 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5517 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5518 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5519 | tANI_U8 staIdx; |
| 5520 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5522 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5523 | |
| 5524 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5525 | __func__,pAdapter->device_mode); |
| 5526 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5527 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5528 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5529 | |
| 5530 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 5531 | { |
| 5532 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5533 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 5534 | return -EAGAIN; |
| 5535 | } |
| 5536 | if (NULL != pRoamProfile) |
| 5537 | { |
| 5538 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5539 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5540 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5541 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5542 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5543 | switch(reason) |
| 5544 | { |
| 5545 | case WLAN_REASON_MIC_FAILURE: |
| 5546 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5547 | break; |
| 5548 | |
| 5549 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5550 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5551 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5552 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5553 | break; |
| 5554 | |
| 5555 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5556 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5557 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5558 | break; |
| 5559 | |
| 5560 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5561 | default: |
| 5562 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5563 | break; |
| 5564 | } |
| 5565 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5566 | (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_TRUE; |
| 5567 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5568 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5569 | #ifdef FEATURE_WLAN_TDLS |
| 5570 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5571 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5572 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5573 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5574 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5575 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5576 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5577 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5578 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5579 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5580 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5581 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5582 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5583 | pAdapter->sessionId, |
| 5584 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5585 | } |
| 5586 | } |
| 5587 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5588 | /*issue disconnect*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5589 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5590 | pAdapter->sessionId, reasonCode); |
| 5591 | |
| 5592 | if ( 0 != status) |
| 5593 | { |
| 5594 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5595 | "%s csrRoamDisconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5596 | __func__, (int)status ); |
| 5597 | return -EINVAL; |
| 5598 | } |
| 5599 | |
| 5600 | wait_for_completion_interruptible_timeout( |
| 5601 | &pAdapter->disconnect_comp_var, |
| 5602 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5603 | |
| 5604 | |
| 5605 | /*stop tx queues*/ |
| 5606 | netif_tx_disable(dev); |
| 5607 | netif_carrier_off(dev); |
| 5608 | } |
| 5609 | } |
| 5610 | else |
| 5611 | { |
| 5612 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5613 | } |
| 5614 | |
| 5615 | return status; |
| 5616 | } |
| 5617 | |
| 5618 | /* |
| 5619 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5620 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5621 | * settings in IBSS mode. |
| 5622 | */ |
| 5623 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5624 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5625 | struct cfg80211_ibss_params *params |
| 5626 | ) |
| 5627 | { |
| 5628 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5629 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5630 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5631 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5632 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5633 | ENTER(); |
| 5634 | |
| 5635 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5636 | |
| 5637 | if (params->ie_len && ( NULL != params->ie) ) |
| 5638 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5639 | if (WLAN_EID_RSN == params->ie[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5640 | { |
| 5641 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5642 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5643 | } |
| 5644 | else |
| 5645 | { |
| 5646 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5647 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5648 | } |
| 5649 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 5650 | |
| 5651 | if (0 > status) |
| 5652 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5653 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5654 | __func__); |
| 5655 | return status; |
| 5656 | } |
| 5657 | } |
| 5658 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5659 | pWextState->roamProfile.AuthType.authType[0] = |
| 5660 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5661 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5662 | |
| 5663 | if (params->privacy) |
| 5664 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5665 | /* Security enabled IBSS, At this time there is no information available |
| 5666 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5667 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5668 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5669 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5670 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5671 | *enable privacy bit in beacons */ |
| 5672 | |
| 5673 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5674 | } |
| 5675 | |
| 5676 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5677 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 5678 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
| 5679 | |
| 5680 | return status; |
| 5681 | } |
| 5682 | |
| 5683 | /* |
| 5684 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5685 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5686 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5687 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5688 | struct net_device *dev, |
| 5689 | struct cfg80211_ibss_params *params |
| 5690 | ) |
| 5691 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5692 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5693 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5694 | tCsrRoamProfile *pRoamProfile; |
| 5695 | int status; |
| 5696 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5697 | |
| 5698 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5699 | |
| 5700 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5701 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5702 | |
| 5703 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5704 | { |
| 5705 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5706 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5707 | return -EAGAIN; |
| 5708 | } |
| 5709 | |
| 5710 | if (NULL == pWextState) |
| 5711 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5712 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5713 | __func__); |
| 5714 | return -EIO; |
| 5715 | } |
| 5716 | |
| 5717 | pRoamProfile = &pWextState->roamProfile; |
| 5718 | |
| 5719 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 5720 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5721 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5722 | "%s Interface type is not set to IBSS \n", __func__); |
| 5723 | return -EINVAL; |
| 5724 | } |
| 5725 | |
| 5726 | /* Set Channel */ |
| 5727 | if (NULL != params->channel) |
| 5728 | { |
| 5729 | u8 channelNum; |
| 5730 | if (IEEE80211_BAND_5GHZ == params->channel->band) |
| 5731 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5732 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5733 | "%s: IBSS join is called with unsupported band %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5734 | __func__, params->channel->band); |
| 5735 | return -EOPNOTSUPP; |
| 5736 | } |
| 5737 | |
| 5738 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5739 | channelNum = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5740 | ieee80211_frequency_to_channel(params->channel->center_freq); |
| 5741 | |
| 5742 | /*TODO: use macro*/ |
| 5743 | if (14 >= channelNum) |
| 5744 | { |
| 5745 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 5746 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5747 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5748 | int indx; |
| 5749 | |
| 5750 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 5751 | validChan, &numChans)) |
| 5752 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5753 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5754 | __func__); |
| 5755 | return -EOPNOTSUPP; |
| 5756 | } |
| 5757 | |
| 5758 | for (indx = 0; indx < numChans; indx++) |
| 5759 | { |
| 5760 | if (channelNum == validChan[indx]) |
| 5761 | { |
| 5762 | break; |
| 5763 | } |
| 5764 | } |
| 5765 | if (indx >= numChans) |
| 5766 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5767 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5768 | __func__, channelNum); |
| 5769 | return -EINVAL; |
| 5770 | } |
| 5771 | /* Set the Operational Channel */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5772 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5773 | channelNum); |
| 5774 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5775 | pHddStaCtx->conn_info.operationChannel = channelNum; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5776 | pRoamProfile->ChannelInfo.ChannelList = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5777 | &pHddStaCtx->conn_info.operationChannel; |
| 5778 | } |
| 5779 | else |
| 5780 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5781 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5782 | __func__, channelNum); |
| 5783 | return -EINVAL; |
| 5784 | } |
| 5785 | } |
| 5786 | |
| 5787 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5788 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5789 | if (status < 0) |
| 5790 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5791 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5792 | __func__); |
| 5793 | return status; |
| 5794 | } |
| 5795 | |
| 5796 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5797 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5798 | params->ssid_len, params->bssid, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5799 | |
| 5800 | if (0 > status) |
| 5801 | { |
| 5802 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5803 | return status; |
| 5804 | } |
| 5805 | |
| 5806 | return 0; |
| 5807 | } |
| 5808 | |
| 5809 | /* |
| 5810 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5811 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5812 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5813 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5814 | struct net_device *dev |
| 5815 | ) |
| 5816 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5817 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5818 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5819 | tCsrRoamProfile *pRoamProfile; |
| 5820 | |
| 5821 | ENTER(); |
| 5822 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5823 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5824 | { |
| 5825 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5826 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5827 | return -EAGAIN; |
| 5828 | } |
| 5829 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5830 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5831 | if (NULL == pWextState) |
| 5832 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5833 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5834 | __func__); |
| 5835 | return -EIO; |
| 5836 | } |
| 5837 | |
| 5838 | pRoamProfile = &pWextState->roamProfile; |
| 5839 | |
| 5840 | /* Issue disconnect only if interface type is set to IBSS */ |
| 5841 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 5842 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5843 | 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] | 5844 | __func__); |
| 5845 | return -EINVAL; |
| 5846 | } |
| 5847 | |
| 5848 | /* Issue Disconnect request */ |
| 5849 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5850 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 5851 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 5852 | |
| 5853 | return 0; |
| 5854 | } |
| 5855 | |
| 5856 | /* |
| 5857 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 5858 | * This function is used to set the phy parameters |
| 5859 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 5860 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5861 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5862 | u32 changed) |
| 5863 | { |
| 5864 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 5865 | tHalHandle hHal = pHddCtx->hHal; |
| 5866 | |
| 5867 | ENTER(); |
| 5868 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5869 | if ( pHddCtx->isLogpInProgress ) |
| 5870 | { |
| 5871 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5872 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5873 | return -EAGAIN; |
| 5874 | } |
| 5875 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5876 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 5877 | { |
| 5878 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 5879 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 5880 | wiphy->rts_threshold; |
| 5881 | |
| 5882 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5883 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5884 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5885 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5886 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5887 | __func__, rts_threshold); |
| 5888 | return -EINVAL; |
| 5889 | } |
| 5890 | |
| 5891 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 5892 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5893 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5894 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5895 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5896 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5897 | __func__, rts_threshold); |
| 5898 | return -EIO; |
| 5899 | } |
| 5900 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5901 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5902 | rts_threshold); |
| 5903 | } |
| 5904 | |
| 5905 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 5906 | { |
| 5907 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 5908 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 5909 | wiphy->frag_threshold; |
| 5910 | |
| 5911 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5912 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5913 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5914 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5915 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5916 | frag_threshold); |
| 5917 | return -EINVAL; |
| 5918 | } |
| 5919 | |
| 5920 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 5921 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5922 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5923 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5924 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5925 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5926 | __func__, frag_threshold); |
| 5927 | return -EIO; |
| 5928 | } |
| 5929 | |
| 5930 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 5931 | frag_threshold); |
| 5932 | } |
| 5933 | |
| 5934 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 5935 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 5936 | { |
| 5937 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 5938 | wiphy->retry_short : |
| 5939 | wiphy->retry_long; |
| 5940 | |
| 5941 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 5942 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 5943 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5944 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5945 | __func__, retry_value); |
| 5946 | return -EINVAL; |
| 5947 | } |
| 5948 | |
| 5949 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 5950 | { |
| 5951 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 5952 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5953 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5954 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5955 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5956 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5957 | __func__, retry_value); |
| 5958 | return -EIO; |
| 5959 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5960 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5961 | __func__, retry_value); |
| 5962 | } |
| 5963 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 5964 | { |
| 5965 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 5966 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5967 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5968 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5969 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5970 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5971 | __func__, retry_value); |
| 5972 | return -EIO; |
| 5973 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5974 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5975 | __func__, retry_value); |
| 5976 | } |
| 5977 | } |
| 5978 | |
| 5979 | return 0; |
| 5980 | } |
| 5981 | |
| 5982 | /* |
| 5983 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 5984 | * This function is used to set the txpower |
| 5985 | */ |
| 5986 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 5987 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5988 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5989 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5990 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5991 | #endif |
| 5992 | int dbm) |
| 5993 | { |
| 5994 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 5995 | tHalHandle hHal = pHddCtx->hHal; |
| 5996 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5997 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5998 | |
| 5999 | ENTER(); |
| 6000 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6001 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6002 | dbm, ccmCfgSetCallback, |
| 6003 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6004 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6005 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6006 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6007 | return -EIO; |
| 6008 | } |
| 6009 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6010 | if ( pHddCtx->isLogpInProgress ) |
| 6011 | { |
| 6012 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6013 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6014 | return -EAGAIN; |
| 6015 | } |
| 6016 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6017 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6018 | dbm); |
| 6019 | |
| 6020 | switch(type) |
| 6021 | { |
| 6022 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6023 | /* Fall through */ |
| 6024 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6025 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6026 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6027 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6028 | __func__); |
| 6029 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6030 | } |
| 6031 | break; |
| 6032 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6033 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6034 | __func__); |
| 6035 | return -EOPNOTSUPP; |
| 6036 | break; |
| 6037 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6038 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6039 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6040 | return -EIO; |
| 6041 | } |
| 6042 | |
| 6043 | return 0; |
| 6044 | } |
| 6045 | |
| 6046 | /* |
| 6047 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6048 | * This function is used to read the txpower |
| 6049 | */ |
| 6050 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) |
| 6051 | { |
| 6052 | |
| 6053 | hdd_adapter_t *pAdapter; |
| 6054 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6055 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6056 | ENTER(); |
| 6057 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6058 | if (NULL == pHddCtx) |
| 6059 | { |
| 6060 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 6061 | *dbm = 0; |
| 6062 | return -ENOENT; |
| 6063 | } |
| 6064 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6065 | if ( pHddCtx->isLogpInProgress ) |
| 6066 | { |
| 6067 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6068 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6069 | return -EAGAIN; |
| 6070 | } |
| 6071 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6072 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6073 | if (NULL == pAdapter) |
| 6074 | { |
| 6075 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6076 | return -ENOENT; |
| 6077 | } |
| 6078 | |
| 6079 | wlan_hdd_get_classAstats(pAdapter); |
| 6080 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6081 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6082 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6083 | return 0; |
| 6084 | } |
| 6085 | |
| 6086 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6087 | u8* mac, struct station_info *sinfo) |
| 6088 | { |
| 6089 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6090 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6091 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6092 | tANI_U8 rate_flags; |
| 6093 | |
| 6094 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6095 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6096 | |
| 6097 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6098 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6099 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6100 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6101 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6102 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6103 | tANI_U16 maxRate = 0; |
| 6104 | tANI_U16 myRate; |
| 6105 | tANI_U16 currentRate = 0; |
| 6106 | tANI_U8 maxSpeedMCS = 0; |
| 6107 | tANI_U8 maxMCSIdx = 0; |
| 6108 | tANI_U8 rateFlag = 1; |
| 6109 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6110 | tANI_U16 temp; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6111 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6112 | #ifdef WLAN_FEATURE_11AC |
| 6113 | tANI_U32 vht_mcs_map; |
| 6114 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6115 | #endif /* WLAN_FEATURE_11AC */ |
| 6116 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6117 | ENTER(); |
| 6118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6119 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6120 | (0 == ssidlen)) |
| 6121 | { |
| 6122 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6123 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6124 | /*To keep GUI happy*/ |
| 6125 | return 0; |
| 6126 | } |
| 6127 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6128 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6129 | { |
| 6130 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6131 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6132 | return -EAGAIN; |
| 6133 | } |
| 6134 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6135 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6136 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6137 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6138 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6139 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6140 | |
| 6141 | //convert to the UI units of 100kbps |
| 6142 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6143 | |
| 6144 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6145 | 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] | 6146 | sinfo->signal, |
| 6147 | pCfg->reportMaxLinkSpeed, |
| 6148 | myRate, |
| 6149 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6150 | (int) pCfg->linkSpeedRssiMid, |
| 6151 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6152 | (int) rate_flags, |
| 6153 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6154 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6155 | |
| 6156 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6157 | { |
| 6158 | // we do not want to necessarily report the current speed |
| 6159 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6160 | { |
| 6161 | // report the max possible speed |
| 6162 | rssidx = 0; |
| 6163 | } |
| 6164 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6165 | { |
| 6166 | // report the max possible speed with RSSI scaling |
| 6167 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6168 | { |
| 6169 | // report the max possible speed |
| 6170 | rssidx = 0; |
| 6171 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6172 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6173 | { |
| 6174 | // report middle speed |
| 6175 | rssidx = 1; |
| 6176 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6177 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6178 | { |
| 6179 | // report middle speed |
| 6180 | rssidx = 2; |
| 6181 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6182 | else |
| 6183 | { |
| 6184 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6185 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6186 | } |
| 6187 | } |
| 6188 | else |
| 6189 | { |
| 6190 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6191 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6192 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6193 | __func__, pCfg->reportMaxLinkSpeed); |
| 6194 | rssidx = 0; |
| 6195 | } |
| 6196 | |
| 6197 | maxRate = 0; |
| 6198 | |
| 6199 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6200 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6201 | OperationalRates, &ORLeng)) |
| 6202 | { |
| 6203 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6204 | /*To keep GUI happy*/ |
| 6205 | return 0; |
| 6206 | } |
| 6207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6208 | for (i = 0; i < ORLeng; i++) |
| 6209 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6210 | 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] | 6211 | { |
| 6212 | /* Validate Rate Set */ |
| 6213 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6214 | { |
| 6215 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6216 | break; |
| 6217 | } |
| 6218 | } |
| 6219 | /* Update MAX rate */ |
| 6220 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6221 | } |
| 6222 | |
| 6223 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6224 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6225 | ExtendedRates, &ERLeng)) |
| 6226 | { |
| 6227 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6228 | /*To keep GUI happy*/ |
| 6229 | return 0; |
| 6230 | } |
| 6231 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6232 | for (i = 0; i < ERLeng; i++) |
| 6233 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6234 | 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] | 6235 | { |
| 6236 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6237 | { |
| 6238 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6239 | break; |
| 6240 | } |
| 6241 | } |
| 6242 | /* Update MAX rate */ |
| 6243 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6244 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6245 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6246 | rates or if we are always reporting max speed or if we have |
| 6247 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6248 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6249 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6250 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6251 | MCSRates, &MCSLeng)) |
| 6252 | { |
| 6253 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6254 | /*To keep GUI happy*/ |
| 6255 | return 0; |
| 6256 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6257 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6258 | #ifdef WLAN_FEATURE_11AC |
| 6259 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6260 | 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] | 6261 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6262 | 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] | 6263 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6264 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6265 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6266 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6267 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6268 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6269 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6270 | maxMCSIdx = 7; |
| 6271 | } |
| 6272 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6273 | { |
| 6274 | maxMCSIdx = 8; |
| 6275 | } |
| 6276 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6277 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6278 | //VHT20 is supporting 0~8 |
| 6279 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6280 | maxMCSIdx = 8; |
| 6281 | else |
| 6282 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6283 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6284 | |
| 6285 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6286 | { |
| 6287 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6288 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6289 | } |
| 6290 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6291 | { |
| 6292 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6293 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6294 | } |
| 6295 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6296 | { |
| 6297 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6298 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6299 | } |
| 6300 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6301 | maxSpeedMCS = 1; |
| 6302 | if (currentRate > maxRate) |
| 6303 | { |
| 6304 | maxRate = currentRate; |
| 6305 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6306 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6307 | } |
| 6308 | else |
| 6309 | #endif /* WLAN_FEATURE_11AC */ |
| 6310 | { |
| 6311 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6312 | { |
| 6313 | rateFlag |= 1; |
| 6314 | } |
| 6315 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6316 | { |
| 6317 | rateFlag |= 2; |
| 6318 | } |
| 6319 | |
| 6320 | for (i = 0; i < MCSLeng; i++) |
| 6321 | { |
| 6322 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6323 | for (j = 0; j < temp; j++) |
| 6324 | { |
| 6325 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6326 | { |
| 6327 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6328 | break; |
| 6329 | } |
| 6330 | } |
| 6331 | if ((j < temp) && (currentRate > maxRate)) |
| 6332 | { |
| 6333 | maxRate = currentRate; |
| 6334 | maxSpeedMCS = 1; |
| 6335 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6336 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6337 | } |
| 6338 | } |
| 6339 | } |
| 6340 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6341 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6342 | { |
| 6343 | maxRate = myRate; |
| 6344 | maxSpeedMCS = 1; |
| 6345 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6346 | } |
| 6347 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6348 | // 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] | 6349 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6350 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6351 | { |
| 6352 | maxRate = myRate; |
| 6353 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6354 | { |
| 6355 | maxSpeedMCS = 0; |
| 6356 | } |
| 6357 | else |
| 6358 | { |
| 6359 | maxSpeedMCS = 1; |
| 6360 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6361 | } |
| 6362 | } |
| 6363 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6364 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6365 | { |
| 6366 | sinfo->txrate.legacy = maxRate; |
| 6367 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6368 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6369 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6370 | } |
| 6371 | else |
| 6372 | { |
| 6373 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6374 | #ifdef WLAN_FEATURE_11AC |
| 6375 | sinfo->txrate.nss = 1; |
| 6376 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6377 | { |
| 6378 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6379 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6380 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6381 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6382 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6383 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6384 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6385 | } |
| 6386 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6387 | { |
| 6388 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6389 | } |
| 6390 | #endif /* WLAN_FEATURE_11AC */ |
| 6391 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6392 | { |
| 6393 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6394 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6395 | { |
| 6396 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6397 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6398 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6399 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6400 | { |
| 6401 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6402 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6403 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6404 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6405 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6406 | sinfo->txrate.mcs, |
| 6407 | sinfo->txrate.flags ); |
| 6408 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6409 | } |
| 6410 | } |
| 6411 | else |
| 6412 | { |
| 6413 | // report current rate instead of max rate |
| 6414 | |
| 6415 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6416 | { |
| 6417 | //provide to the UI in units of 100kbps |
| 6418 | sinfo->txrate.legacy = myRate; |
| 6419 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6420 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6421 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6422 | } |
| 6423 | else |
| 6424 | { |
| 6425 | //must be MCS |
| 6426 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6427 | #ifdef WLAN_FEATURE_11AC |
| 6428 | sinfo->txrate.nss = 1; |
| 6429 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6430 | { |
| 6431 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6432 | } |
| 6433 | else |
| 6434 | #endif /* WLAN_FEATURE_11AC */ |
| 6435 | { |
| 6436 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6437 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6438 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6439 | { |
| 6440 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6441 | } |
| 6442 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6443 | { |
| 6444 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6445 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6446 | #ifdef WLAN_FEATURE_11AC |
| 6447 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6448 | { |
| 6449 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6450 | } |
| 6451 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6452 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6453 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6454 | sinfo->txrate.mcs, |
| 6455 | sinfo->txrate.flags ); |
| 6456 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6457 | } |
| 6458 | } |
| 6459 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6460 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6461 | sinfo->tx_packets = |
| 6462 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6463 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6464 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6465 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6466 | |
| 6467 | sinfo->tx_retries = |
| 6468 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6469 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6470 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6471 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6472 | |
| 6473 | sinfo->tx_failed = |
| 6474 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6475 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6476 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6477 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6478 | |
| 6479 | sinfo->filled |= |
| 6480 | STATION_INFO_TX_PACKETS | |
| 6481 | STATION_INFO_TX_RETRIES | |
| 6482 | STATION_INFO_TX_FAILED; |
| 6483 | |
| 6484 | EXIT(); |
| 6485 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6486 | } |
| 6487 | |
| 6488 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 6489 | struct net_device *dev, bool mode, v_SINT_t timeout) |
| 6490 | { |
| 6491 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6492 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6493 | VOS_STATUS vos_status; |
| 6494 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6495 | ENTER(); |
| 6496 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6497 | if (NULL == pAdapter) |
| 6498 | { |
| 6499 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6500 | return -ENODEV; |
| 6501 | } |
| 6502 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6503 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6504 | if (NULL == pHddCtx) |
| 6505 | { |
| 6506 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is NULL\n", __func__); |
| 6507 | return -ENODEV; |
| 6508 | } |
| 6509 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6510 | if ( pHddCtx->isLogpInProgress ) |
| 6511 | { |
| 6512 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6513 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6514 | return -EAGAIN; |
| 6515 | } |
| 6516 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6517 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6518 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6519 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6520 | (eConnectionState_Associated == |
| 6521 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6522 | { |
| 6523 | vos_status = hdd_conf_hostarpoffload(pAdapter, TRUE); |
| 6524 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6525 | { |
| 6526 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6527 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6528 | __func__, vos_status); |
| 6529 | } |
| 6530 | } |
| 6531 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6532 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6533 | *on successful execution of the function call |
| 6534 | *we are oppositely mapped w.r.t mode in the driver |
| 6535 | **/ |
| 6536 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6537 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6538 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6539 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6540 | { |
| 6541 | return -EINVAL; |
| 6542 | } |
| 6543 | return 0; |
| 6544 | } |
| 6545 | |
| 6546 | |
| 6547 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6548 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6549 | struct net_device *netdev, |
| 6550 | u8 key_index) |
| 6551 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6552 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6553 | return 0; |
| 6554 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6555 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6556 | |
| 6557 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6558 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6559 | struct net_device *dev, |
| 6560 | struct ieee80211_txq_params *params) |
| 6561 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6562 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6563 | return 0; |
| 6564 | } |
| 6565 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6566 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6567 | struct ieee80211_txq_params *params) |
| 6568 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6569 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6570 | return 0; |
| 6571 | } |
| 6572 | #endif //LINUX_VERSION_CODE |
| 6573 | |
| 6574 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6575 | struct net_device *dev, u8 *mac) |
| 6576 | { |
| 6577 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6578 | VOS_STATUS vos_status; |
| 6579 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6580 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6581 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6582 | if ( NULL == pAdapter || NULL == pAdapter->pHddCtx) |
| 6583 | { |
| 6584 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__); |
| 6585 | return -EINVAL; |
| 6586 | } |
| 6587 | |
| 6588 | if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress) |
| 6589 | { |
| 6590 | hddLog( LOGE, |
| 6591 | "%s: Wlan Load/Unload is in progress", __func__); |
| 6592 | return -EBUSY; |
| 6593 | } |
| 6594 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6595 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6596 | { |
| 6597 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6598 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6599 | return -EAGAIN; |
| 6600 | } |
| 6601 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6602 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6603 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6604 | ) |
| 6605 | { |
| 6606 | if( NULL == mac ) |
| 6607 | { |
| 6608 | v_U16_t i; |
| 6609 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6610 | { |
| 6611 | if(pAdapter->aStaInfo[i].isUsed) |
| 6612 | { |
| 6613 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6614 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6615 | "%s: Delete STA with MAC::" |
| 6616 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6617 | __func__, |
| 6618 | macAddr[0], macAddr[1], macAddr[2], |
| 6619 | macAddr[3], macAddr[4], macAddr[5]); |
| 6620 | hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6621 | } |
| 6622 | } |
| 6623 | } |
| 6624 | else |
| 6625 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6626 | |
| 6627 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6628 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6629 | { |
| 6630 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6631 | "%s: Skip this DEL STA as this is not used::" |
| 6632 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6633 | __func__, |
| 6634 | mac[0], mac[1], mac[2], |
| 6635 | mac[3], mac[4], mac[5]); |
| 6636 | return -ENOENT; |
| 6637 | } |
| 6638 | |
| 6639 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 6640 | { |
| 6641 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6642 | "%s: Skip this DEL STA as deauth is in progress::" |
| 6643 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6644 | __func__, |
| 6645 | mac[0], mac[1], mac[2], |
| 6646 | mac[3], mac[4], mac[5]); |
| 6647 | return -ENOENT; |
| 6648 | } |
| 6649 | |
| 6650 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 6651 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6652 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6653 | "%s: Delete STA with MAC::" |
| 6654 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6655 | __func__, |
| 6656 | mac[0], mac[1], mac[2], |
| 6657 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6658 | |
| 6659 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 6660 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6661 | { |
| 6662 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 6663 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6664 | "%s: STA removal failed for ::" |
| 6665 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6666 | __func__, |
| 6667 | mac[0], mac[1], mac[2], |
| 6668 | mac[3], mac[4], mac[5]); |
| 6669 | return -ENOENT; |
| 6670 | } |
| 6671 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6672 | } |
| 6673 | } |
| 6674 | |
| 6675 | EXIT(); |
| 6676 | |
| 6677 | return 0; |
| 6678 | } |
| 6679 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6680 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 6681 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 6682 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6683 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6684 | #ifdef FEATURE_WLAN_TDLS |
| 6685 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6686 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6687 | mask = params->sta_flags_mask; |
| 6688 | |
| 6689 | set = params->sta_flags_set; |
| 6690 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6691 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 6692 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6693 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 6694 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 6695 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6696 | |
| 6697 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 6698 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6699 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6700 | } |
| 6701 | } |
| 6702 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6703 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6704 | } |
| 6705 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6706 | |
| 6707 | #ifdef FEATURE_WLAN_LFR |
| 6708 | 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] | 6709 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6710 | { |
| 6711 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 6712 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6713 | static tANI_U32 i; // HDD Local Cache index |
| 6714 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6715 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6716 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6717 | eHalStatus result; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6718 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6719 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6720 | ENTER(); |
| 6721 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6722 | // Validate pAdapter |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6723 | if ( NULL == pAdapter || NULL == pAdapter->pHddCtx) |
| 6724 | { |
| 6725 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__); |
| 6726 | return -EINVAL; |
| 6727 | } |
| 6728 | |
| 6729 | if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress) |
| 6730 | { |
| 6731 | hddLog( LOGE, |
| 6732 | "%s: Wlan Load/Unload is in progress", __func__); |
| 6733 | return -EBUSY; |
| 6734 | } |
| 6735 | |
| 6736 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6737 | { |
| 6738 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6739 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6740 | return -EAGAIN; |
| 6741 | } |
| 6742 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6743 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6744 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6745 | |
| 6746 | for (j = 0; j < i; j++) |
| 6747 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6748 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6749 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 6750 | { |
| 6751 | /* BSSID matched previous entry. Overwrite it. */ |
| 6752 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6753 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6754 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6755 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 6756 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6757 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6758 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6759 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6760 | dump_bssid(pmksa->bssid); |
| 6761 | dump_pmkid(halHandle, pmksa->pmkid); |
| 6762 | break; |
| 6763 | } |
| 6764 | } |
| 6765 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 6766 | /* Check we compared all entries,if then take the first slot now */ |
| 6767 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 6768 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6769 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6770 | { |
| 6771 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 6772 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 6773 | pmksa->bssid, ETHER_ADDR_LEN); |
| 6774 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 6775 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6776 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6777 | 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] | 6778 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6779 | dump_bssid(pmksa->bssid); |
| 6780 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6781 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6782 | // 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] | 6783 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6784 | } |
| 6785 | |
| 6786 | |
| 6787 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6788 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6789 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6790 | 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] | 6791 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6792 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6793 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 6794 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6795 | i ); |
| 6796 | return 0; |
| 6797 | } |
| 6798 | |
| 6799 | |
| 6800 | 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] | 6801 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6802 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6803 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6804 | // TODO: Implement this later. |
| 6805 | return 0; |
| 6806 | } |
| 6807 | |
| 6808 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 6809 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6810 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6811 | // TODO: Implement this later. |
| 6812 | return 0; |
| 6813 | } |
| 6814 | #endif |
| 6815 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6816 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6817 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6818 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 6819 | { |
| 6820 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6821 | hdd_station_ctx_t *pHddStaCtx; |
| 6822 | |
| 6823 | if (NULL == pAdapter) |
| 6824 | { |
| 6825 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6826 | return -ENODEV; |
| 6827 | } |
| 6828 | |
| 6829 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6830 | |
| 6831 | // Added for debug on reception of Re-assoc Req. |
| 6832 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6833 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6834 | 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] | 6835 | ftie->ie_len); |
| 6836 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 6837 | } |
| 6838 | |
| 6839 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6840 | 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] | 6841 | ftie->ie_len); |
| 6842 | #endif |
| 6843 | |
| 6844 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 6845 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6846 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6847 | ftie->ie_len); |
| 6848 | return 0; |
| 6849 | } |
| 6850 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6851 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6852 | #ifdef FEATURE_WLAN_TDLS |
| 6853 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 6854 | u8 *peer, u8 action_code, u8 dialog_token, |
| 6855 | u16 status_code, const u8 *buf, size_t len) |
| 6856 | { |
| 6857 | |
| 6858 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6859 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6860 | u8 peerMac[6]; |
| 6861 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 6862 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 6863 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 6864 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6865 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6866 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6867 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6868 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6869 | "Invalid arguments"); |
| 6870 | return -EINVAL; |
| 6871 | } |
| 6872 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 6873 | if (pHddCtx->isLogpInProgress) |
| 6874 | { |
| 6875 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6876 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 6877 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 6878 | return -EBUSY; |
| 6879 | } |
| 6880 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 6881 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6882 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 6883 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 6884 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 6885 | MAC_ADDRESS_STR " action %d declined.", |
| 6886 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6887 | return -ENOTSUPP; |
| 6888 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6889 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 6890 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 6891 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 6892 | { |
| 6893 | /* if tdls_mode is disabled to respond to peer's request */ |
| 6894 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 6895 | { |
| 6896 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 6897 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 6898 | " TDLS mode is disabled. action %d declined.", |
| 6899 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 6900 | |
| 6901 | return -ENOTSUPP; |
| 6902 | } |
| 6903 | } |
| 6904 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6905 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 6906 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 6907 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6908 | { |
| 6909 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6910 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 6911 | " TDLS setup is ongoing. action %d declined.", |
| 6912 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 6913 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6914 | } |
| 6915 | } |
| 6916 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6917 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 6918 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6919 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6920 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6921 | { |
| 6922 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 6923 | we return error code at 'add_station()'. Hence we have this |
| 6924 | check again in addtion to add_station(). |
| 6925 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6926 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6927 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6928 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6929 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 6930 | " TDLS Max peer already connected. action %d declined.", |
| 6931 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 6932 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6933 | } |
| 6934 | else |
| 6935 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6936 | /* maximum reached. tweak to send error code to peer and return |
| 6937 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6938 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6939 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6940 | "%s: " MAC_ADDRESS_STR |
| 6941 | " TDLS Max peer already connected send response status %d", |
| 6942 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 6943 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6944 | /* fall through to send setup resp with failure status |
| 6945 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6946 | } |
| 6947 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6948 | else |
| 6949 | { |
| 6950 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6951 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 6952 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6953 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6954 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 6955 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 6956 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6957 | return -EPERM; |
| 6958 | } |
| 6959 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 6960 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6961 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6962 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 6963 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 6964 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6965 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 6966 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 6967 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 6968 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6969 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 6970 | /*Except teardown responder will not be used so just make 0*/ |
| 6971 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6972 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 6973 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 6974 | |
| 6975 | hddTdlsPeer_t *pTdlsPeer; |
| 6976 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 6977 | |
| 6978 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 6979 | responder = pTdlsPeer->is_responder; |
| 6980 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 6981 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 6982 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6983 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 6984 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 6985 | dialog_token, status_code, len); |
| 6986 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 6987 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6988 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6989 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 6990 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
| 6991 | (SIR_MAC_TDLS_DIS_RSP == action_code)) |
| 6992 | { |
| 6993 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 6994 | { |
| 6995 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 6996 | "%s: Sending Disc/Setup Rsp Frame.Disable BMPS", __func__); |
| 6997 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6998 | } |
| 6999 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
| 7000 | } |
| 7001 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7002 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7003 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7004 | { |
| 7005 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7006 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7007 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7008 | return -EBUSY; |
| 7009 | } |
| 7010 | |
| 7011 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7012 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7013 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7014 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7015 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7016 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7017 | if (VOS_STATUS_SUCCESS != status) |
| 7018 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7019 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7020 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7021 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7022 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7023 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7024 | } |
| 7025 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7026 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7027 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7028 | |
| 7029 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7030 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7031 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7032 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7033 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7034 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7035 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7036 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7037 | } |
| 7038 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7039 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7040 | { |
| 7041 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7042 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7043 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7044 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7045 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7046 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7047 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7048 | } |
| 7049 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7050 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7051 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7052 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7053 | |
| 7054 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7055 | error: |
| 7056 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7057 | because we already know that this transaction will be failed, |
| 7058 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7059 | to be safe, do not change the state mahine. |
| 7060 | */ |
| 7061 | if(max_sta_failed == 0 && |
| 7062 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7063 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7064 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7065 | } |
| 7066 | |
| 7067 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7068 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7069 | { |
| 7070 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7071 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7072 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7073 | const char *tdls_oper_str[]= { |
| 7074 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7075 | "NL80211_TDLS_SETUP", |
| 7076 | "NL80211_TDLS_TEARDOWN", |
| 7077 | "NL80211_TDLS_ENABLE_LINK", |
| 7078 | "NL80211_TDLS_DISABLE_LINK", |
| 7079 | "NL80211_TDLS_UNKONW_OPER"}; |
| 7080 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7081 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7082 | |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7083 | if ( NULL == pHddCtx || NULL == pHddCtx->cfg_ini || NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7084 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7086 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7087 | return -EINVAL; |
| 7088 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7089 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7090 | if (pHddCtx->isLogpInProgress) |
| 7091 | { |
| 7092 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7093 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 7094 | return -EBUSY; |
| 7095 | } |
| 7096 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7097 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7098 | |
| 7099 | if ( NULL == pTdlsPeer ) { |
| 7100 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7101 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7102 | return -EINVAL; |
| 7103 | } |
| 7104 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7105 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7106 | if((int)oper > 4) |
| 7107 | oper = 5; |
| 7108 | |
| 7109 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7110 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7111 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7112 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7113 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7114 | |
| 7115 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7116 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7117 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7118 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7119 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7120 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7121 | return -ENOTSUPP; |
| 7122 | } |
| 7123 | |
| 7124 | switch (oper) { |
| 7125 | case NL80211_TDLS_ENABLE_LINK: |
| 7126 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7127 | VOS_STATUS status; |
| 7128 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7129 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7130 | { |
| 7131 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7132 | MAC_ADDRESS_STR " failed", |
| 7133 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7134 | return -EINVAL; |
| 7135 | } |
| 7136 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7137 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7138 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7139 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7140 | /* start TDLS client registration with TL */ |
| 7141 | status = hdd_roamRegisterTDLSSTA( pAdapter, peer, pTdlsPeer->staId, pTdlsPeer->signature); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7142 | if (VOS_STATUS_SUCCESS == status) |
| 7143 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7144 | if (pTdlsPeer->is_responder == 0) |
| 7145 | { |
| 7146 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7147 | |
| 7148 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7149 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7150 | WAIT_TIME_TDLS_INITIATOR); |
| 7151 | /* suspend initiator TX until it receives direct packet from the |
| 7152 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7153 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7154 | &staId, NULL); |
| 7155 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7156 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7157 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7158 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7159 | } |
| 7160 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7161 | } |
| 7162 | break; |
| 7163 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7164 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7165 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7166 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7167 | long status; |
| 7168 | |
| 7169 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7170 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7171 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7172 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7173 | |
| 7174 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7175 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7176 | if (status <= 0) |
| 7177 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7178 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7179 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7180 | "%s: Del station failed status %ld", |
| 7181 | __func__, status); |
| 7182 | return -EPERM; |
| 7183 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7184 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7185 | } |
| 7186 | else |
| 7187 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7188 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7189 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7190 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7191 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7192 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7193 | case NL80211_TDLS_TEARDOWN: |
| 7194 | case NL80211_TDLS_SETUP: |
| 7195 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7196 | /* We don't support in-driver setup/teardown/discovery */ |
| 7197 | return -ENOTSUPP; |
| 7198 | default: |
| 7199 | return -ENOTSUPP; |
| 7200 | } |
| 7201 | return 0; |
| 7202 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7203 | |
| 7204 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7205 | struct net_device *dev, u8 *peer) |
| 7206 | { |
| 7207 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7208 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7209 | |
| 7210 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7211 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7212 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7213 | #endif |
| 7214 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7215 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7216 | /* |
| 7217 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7218 | * Callback rountine called upon receiving response for |
| 7219 | * get offload info |
| 7220 | */ |
| 7221 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7222 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7223 | { |
| 7224 | |
| 7225 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
| 7226 | |
| 7227 | ENTER(); |
| 7228 | |
| 7229 | if (NULL == pAdapter) |
| 7230 | { |
| 7231 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7232 | "%s: HDD adapter is Null", __func__); |
| 7233 | return ; |
| 7234 | } |
| 7235 | |
| 7236 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7237 | { |
| 7238 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7239 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7240 | return ; |
| 7241 | } |
| 7242 | |
| 7243 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7244 | { |
| 7245 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7246 | "%s: wlan Failed to get replay counter value", |
| 7247 | __func__); |
| 7248 | return ; |
| 7249 | } |
| 7250 | |
| 7251 | /* Update replay counter to NL */ |
| 7252 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
| 7253 | (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter, GFP_KERNEL); |
| 7254 | } |
| 7255 | |
| 7256 | /* |
| 7257 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 7258 | * This function is used to offload GTK rekeying job to the firmware. |
| 7259 | */ |
| 7260 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 7261 | struct cfg80211_gtk_rekey_data *data) |
| 7262 | { |
| 7263 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7264 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 7265 | hdd_station_ctx_t *pHddStaCtx; |
| 7266 | tHalHandle hHal; |
| 7267 | tpSirGtkOffloadParams pGtkOffloadReqParams; |
| 7268 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7269 | |
| 7270 | ENTER(); |
| 7271 | |
| 7272 | if (NULL == pAdapter) |
| 7273 | { |
| 7274 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7275 | "%s: HDD adapter is Null", __func__); |
| 7276 | return -ENODEV; |
| 7277 | } |
| 7278 | |
| 7279 | if (NULL == pHddCtx) |
| 7280 | { |
| 7281 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7282 | "%s: HDD context is Null!!!", __func__); |
| 7283 | return -ENODEV; |
| 7284 | } |
| 7285 | |
| 7286 | if (pHddCtx->isLogpInProgress) |
| 7287 | { |
| 7288 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7289 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7290 | return -EAGAIN; |
| 7291 | } |
| 7292 | |
| 7293 | if (pHddCtx->isLoadUnloadInProgress) |
| 7294 | { |
| 7295 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7296 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 7297 | return -EAGAIN; |
| 7298 | } |
| 7299 | |
| 7300 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7301 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7302 | if (NULL == hHal) |
| 7303 | { |
| 7304 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7305 | "%s: HAL context is Null!!!", __func__); |
| 7306 | return -EAGAIN; |
| 7307 | } |
| 7308 | |
| 7309 | pGtkOffloadReqParams = |
| 7310 | &pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams; |
| 7311 | |
| 7312 | pGtkOffloadReqParams->ulFlags = GTK_OFFLOAD_ENABLE; |
| 7313 | memcpy(pGtkOffloadReqParams->aKCK, data->kck, NL80211_KCK_LEN); |
| 7314 | memcpy(pGtkOffloadReqParams->aKEK, data->kek, NL80211_KEK_LEN); |
| 7315 | memcpy(pGtkOffloadReqParams->bssId, &pHddStaCtx->conn_info.bssId, |
| 7316 | WNI_CFG_BSSID_LEN); |
| 7317 | memcpy(&pGtkOffloadReqParams->ullKeyReplayCounter, &data->replay_ctr, |
| 7318 | sizeof (tANI_U64)); |
| 7319 | |
| 7320 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 7321 | { |
| 7322 | /* if wlan is suspended, enable GTK offload directly from here */ |
| 7323 | status = sme_SetGTKOffload(hHal, pGtkOffloadReqParams, |
| 7324 | pAdapter->sessionId); |
| 7325 | |
| 7326 | if (eHAL_STATUS_SUCCESS != status) |
| 7327 | { |
| 7328 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7329 | "%s: sme_SetGTKOffload failed, returned %d", |
| 7330 | __func__, status); |
| 7331 | return status; |
| 7332 | } |
| 7333 | pHddStaCtx->gtkOffloadRequestParams.requested = FALSE; |
| 7334 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7335 | "%s: sme_SetGTKOffload successfull", __func__); |
| 7336 | } |
| 7337 | else |
| 7338 | { |
| 7339 | pHddStaCtx->gtkOffloadRequestParams.requested = TRUE; |
| 7340 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7341 | "%s: wlan not suspended GTKOffload request is stored", |
| 7342 | __func__); |
| 7343 | return eHAL_STATUS_SUCCESS; |
| 7344 | } |
| 7345 | return status; |
| 7346 | } |
| 7347 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 7348 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7349 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7350 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7351 | { |
| 7352 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 7353 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 7354 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 7355 | .change_station = wlan_hdd_change_station, |
| 7356 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 7357 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 7358 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 7359 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7360 | #else |
| 7361 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 7362 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 7363 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7364 | #endif |
| 7365 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 7366 | .add_key = wlan_hdd_cfg80211_add_key, |
| 7367 | .get_key = wlan_hdd_cfg80211_get_key, |
| 7368 | .del_key = wlan_hdd_cfg80211_del_key, |
| 7369 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 7370 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7371 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 7372 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7373 | .scan = wlan_hdd_cfg80211_scan, |
| 7374 | .connect = wlan_hdd_cfg80211_connect, |
| 7375 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 7376 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 7377 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 7378 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 7379 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 7380 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7381 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 7382 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 7383 | .mgmt_tx = wlan_hdd_action, |
| 7384 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7385 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 7386 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 7387 | .set_txq_params = wlan_hdd_set_txq_params, |
| 7388 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7389 | .get_station = wlan_hdd_cfg80211_get_station, |
| 7390 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 7391 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7392 | .add_station = wlan_hdd_cfg80211_add_station, |
| 7393 | #ifdef FEATURE_WLAN_LFR |
| 7394 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 7395 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 7396 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 7397 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7398 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 7399 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 7400 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7401 | #ifdef FEATURE_WLAN_TDLS |
| 7402 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 7403 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 7404 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7405 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7406 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 7407 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7408 | }; |
| 7409 | |