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 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1549 | /* |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1550 | * FUNCTION: wlan_hdd_select_cbmode |
| 1551 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1552 | * This function selects the cbmode based on primary channel |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1553 | */ |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1554 | VOS_STATUS wlan_sap_select_cbmode(void *pAdapter,eSapPhyMode SapHw_mode, v_U8_t channel) |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1555 | { |
| 1556 | tSmeConfigParams smeConfig; |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1557 | hdd_context_t *pHddCtx = ( hdd_context_t *) pAdapter; |
| 1558 | hdd_config_t *pConfigIni = ((hdd_context_t *)(pAdapter))->cfg_ini; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1559 | |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1560 | if( |
| 1561 | #ifdef WLAN_FEATURE_11AC |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1562 | SapHw_mode != eSAP_DOT11_MODE_11ac && |
| 1563 | SapHw_mode != eSAP_DOT11_MODE_11ac_ONLY && |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1564 | #endif |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1565 | SapHw_mode != eSAP_DOT11_MODE_11n && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1566 | SapHw_mode != eSAP_DOT11_MODE_11n_ONLY |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1567 | ) |
| 1568 | { |
| 1569 | return VOS_STATUS_SUCCESS; |
| 1570 | } |
| 1571 | |
| 1572 | if (!pConfigIni->nChannelBondingMode5GHz) { |
| 1573 | return VOS_STATUS_SUCCESS; |
| 1574 | } |
| 1575 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1576 | //channel = pSapConfig->channel; |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1577 | vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams)); |
| 1578 | |
| 1579 | sme_GetConfigParam(pHddCtx->hHal, &smeConfig); |
| 1580 | |
| 1581 | #ifdef WLAN_FEATURE_11AC |
| 1582 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1583 | if ( SapHw_mode == eSAP_DOT11_MODE_11ac || |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1584 | SapHw_mode == eSAP_DOT11_MODE_11ac_ONLY ) |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1585 | { |
| 1586 | if ( channel== 36 || channel == 52 || channel == 100 || |
| 1587 | channel == 116 || channel == 149 ) |
| 1588 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1589 | smeConfig.csrConfig.channelBondingMode5GHz = |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1590 | PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1; |
| 1591 | } |
| 1592 | else if ( channel == 40 || channel == 56 || channel == 104 || |
| 1593 | channel == 120 || channel == 153 ) |
| 1594 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1595 | smeConfig.csrConfig.channelBondingMode5GHz = |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1596 | PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1; |
| 1597 | } |
| 1598 | else if ( channel == 44 || channel == 60 || channel == 108 || |
| 1599 | channel == 124 || channel == 157 ) |
| 1600 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1601 | smeConfig.csrConfig.channelBondingMode5GHz = |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1602 | PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1; |
| 1603 | } |
| 1604 | else if ( channel == 48 || channel == 64 || channel == 112 || |
| 1605 | channel == 128 || channel == 161 ) |
| 1606 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1607 | smeConfig.csrConfig.channelBondingMode5GHz = |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1608 | PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1; |
| 1609 | } |
Shailender Karmuchi | 84f11f0 | 2013-02-12 17:11:45 -0800 | [diff] [blame] | 1610 | else if ( channel == 165 ) |
| 1611 | { |
| 1612 | smeConfig.csrConfig.channelBondingMode5GHz = 0; |
| 1613 | } |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1614 | } |
| 1615 | #endif |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1616 | if ( SapHw_mode == eSAP_DOT11_MODE_11n || |
| 1617 | SapHw_mode == eSAP_DOT11_MODE_11n_ONLY ) |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1618 | { |
| 1619 | if ( channel== 40 || channel == 48 || channel == 56 || |
| 1620 | channel == 64 || channel == 104 || channel == 112 || |
| 1621 | channel == 120 || channel == 128 || channel == 136 || |
| 1622 | channel == 144 || channel == 153 || channel == 161 ) |
| 1623 | { |
| 1624 | smeConfig.csrConfig.channelBondingMode5GHz = 1; |
| 1625 | } |
| 1626 | else if ( channel== 36 || channel == 44 || channel == 52 || |
| 1627 | channel == 60 || channel == 100 || channel == 108 || |
| 1628 | channel == 116 || channel == 124 || channel == 132 || |
| 1629 | channel == 140 || channel == 149 || channel == 157 ) |
| 1630 | { |
| 1631 | smeConfig.csrConfig.channelBondingMode5GHz = 2; |
| 1632 | } |
Shailender Karmuchi | 84f11f0 | 2013-02-12 17:11:45 -0800 | [diff] [blame] | 1633 | else if ( channel == 165 ) |
| 1634 | { |
| 1635 | smeConfig.csrConfig.channelBondingMode5GHz = 0; |
| 1636 | } |
Madan Mohan Koyyalamudi | 5938162 | 2012-11-28 01:56:47 +0530 | [diff] [blame] | 1637 | } |
| 1638 | pr_info ("cbmode selected=%ld\n",smeConfig.csrConfig.channelBondingMode5GHz); |
| 1639 | |
| 1640 | sme_UpdateConfig (pHddCtx->hHal,&smeConfig); |
| 1641 | return VOS_STATUS_SUCCESS; |
| 1642 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1643 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1644 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1645 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1646 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1647 | #else |
| 1648 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1649 | struct cfg80211_beacon_data *params, |
| 1650 | const u8 *ssid, size_t ssid_len, |
| 1651 | enum nl80211_hidden_ssid hidden_ssid) |
| 1652 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1653 | { |
| 1654 | tsap_Config_t *pConfig; |
| 1655 | beacon_data_t *pBeacon = NULL; |
| 1656 | struct ieee80211_mgmt *pMgmt_frame; |
| 1657 | v_U8_t *pIe=NULL; |
| 1658 | v_U16_t capab_info; |
| 1659 | eCsrAuthType RSNAuthType; |
| 1660 | eCsrEncryptionType RSNEncryptType; |
| 1661 | eCsrEncryptionType mcRSNEncryptType; |
| 1662 | int status = VOS_STATUS_SUCCESS; |
| 1663 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1664 | hdd_hostapd_state_t *pHostapdState; |
| 1665 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1666 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1667 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1668 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1669 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1670 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1671 | |
| 1672 | ENTER(); |
| 1673 | |
| 1674 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1675 | |
| 1676 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1677 | |
| 1678 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1679 | |
| 1680 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1681 | |
| 1682 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1683 | |
| 1684 | //channel is already set in the set_channel Call back |
| 1685 | //pConfig->channel = pCommitConfig->channel; |
| 1686 | |
| 1687 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1688 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1689 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1690 | |
| 1691 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1692 | |
| 1693 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1694 | pConfig->dtim_period); |
| 1695 | |
| 1696 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1697 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1698 | { |
| 1699 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1700 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1701 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1702 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1703 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1704 | pConfig->ieee80211d = 1; |
| 1705 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1706 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1707 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1708 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1709 | else |
| 1710 | { |
| 1711 | pConfig->ieee80211d = 0; |
| 1712 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1713 | /* |
| 1714 | * If auto channel is configured i.e. channel is 0, |
| 1715 | * so skip channel validation. |
| 1716 | */ |
| 1717 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1718 | { |
| 1719 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1720 | { |
| 1721 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1722 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1723 | return -EINVAL; |
| 1724 | } |
| 1725 | } |
| 1726 | else |
| 1727 | { |
| 1728 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1729 | { |
| 1730 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1731 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1732 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1733 | } |
| 1734 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1735 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1736 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1737 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1738 | { |
| 1739 | pConfig->ieee80211d = 0; |
| 1740 | } |
| 1741 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1742 | |
| 1743 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1744 | |
| 1745 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1746 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1747 | |
| 1748 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1749 | |
| 1750 | /*Set wps station to configured*/ |
| 1751 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1752 | |
| 1753 | if(pIe) |
| 1754 | { |
| 1755 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1756 | { |
| 1757 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1758 | return -EINVAL; |
| 1759 | } |
| 1760 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1761 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1762 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1763 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1764 | * WPS state |
| 1765 | */ |
| 1766 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1767 | { |
| 1768 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1769 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1770 | { |
| 1771 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1772 | } |
| 1773 | } |
| 1774 | } |
| 1775 | else |
| 1776 | { |
| 1777 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1778 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1779 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1780 | |
| 1781 | pConfig->RSNWPAReqIELength = 0; |
| 1782 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1783 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1784 | WLAN_EID_RSN); |
| 1785 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1786 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1787 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1788 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1789 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1790 | /* The actual processing may eventually be more extensive than |
| 1791 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1792 | * by the app. |
| 1793 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1794 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1795 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1796 | &RSNEncryptType, |
| 1797 | &mcRSNEncryptType, |
| 1798 | &RSNAuthType, |
| 1799 | pConfig->pRSNWPAReqIE[1]+2, |
| 1800 | pConfig->pRSNWPAReqIE ); |
| 1801 | |
| 1802 | if( VOS_STATUS_SUCCESS == status ) |
| 1803 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1804 | /* Now copy over all the security attributes you have |
| 1805 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1806 | * */ |
| 1807 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1808 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1809 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1810 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1811 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1812 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1813 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1814 | } |
| 1815 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1816 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1817 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1818 | pBeacon->tail, pBeacon->tail_len); |
| 1819 | |
| 1820 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1821 | { |
| 1822 | if (pConfig->pRSNWPAReqIE) |
| 1823 | { |
| 1824 | /*Mixed mode WPA/WPA2*/ |
| 1825 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1826 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1827 | } |
| 1828 | else |
| 1829 | { |
| 1830 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1831 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1832 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1833 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1834 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1835 | &RSNEncryptType, |
| 1836 | &mcRSNEncryptType, |
| 1837 | &RSNAuthType, |
| 1838 | pConfig->pRSNWPAReqIE[1]+2, |
| 1839 | pConfig->pRSNWPAReqIE ); |
| 1840 | |
| 1841 | if( VOS_STATUS_SUCCESS == status ) |
| 1842 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1843 | /* Now copy over all the security attributes you have |
| 1844 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1845 | * */ |
| 1846 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1847 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1848 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1849 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1850 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1851 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1852 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1853 | } |
| 1854 | } |
| 1855 | } |
| 1856 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1857 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1858 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1859 | return -EINVAL; |
| 1860 | } |
| 1861 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1862 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1863 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1864 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1865 | if (params->ssid != NULL) |
| 1866 | { |
| 1867 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1868 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1869 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1870 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1871 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1872 | #else |
| 1873 | if (ssid != NULL) |
| 1874 | { |
| 1875 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1876 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1877 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1878 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1879 | } |
| 1880 | #endif |
| 1881 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1882 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1883 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1884 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1885 | /* default value */ |
| 1886 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1887 | pConfig->num_accept_mac = 0; |
| 1888 | pConfig->num_deny_mac = 0; |
| 1889 | |
| 1890 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1891 | pBeacon->tail, pBeacon->tail_len); |
| 1892 | |
| 1893 | /* pIe for black list is following form: |
| 1894 | type : 1 byte |
| 1895 | length : 1 byte |
| 1896 | OUI : 4 bytes |
| 1897 | acl type : 1 byte |
| 1898 | no of mac addr in black list: 1 byte |
| 1899 | 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] | 1900 | */ |
| 1901 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1902 | { |
| 1903 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1904 | pConfig->num_deny_mac = pIe[7]; |
| 1905 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1906 | pIe[6], pIe[7]); |
| 1907 | if (pConfig->num_deny_mac > MAX_MAC_ADDRESS_DENIED) |
| 1908 | pConfig->num_deny_mac = MAX_MAC_ADDRESS_DENIED; |
| 1909 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1910 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1911 | { |
| 1912 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1913 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1914 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1915 | } |
| 1916 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1917 | pBeacon->tail, pBeacon->tail_len); |
| 1918 | |
| 1919 | /* pIe for white list is following form: |
| 1920 | type : 1 byte |
| 1921 | length : 1 byte |
| 1922 | OUI : 4 bytes |
| 1923 | acl type : 1 byte |
| 1924 | no of mac addr in white list: 1 byte |
| 1925 | 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] | 1926 | */ |
| 1927 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1928 | { |
| 1929 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1930 | pConfig->num_accept_mac = pIe[7]; |
| 1931 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 1932 | pIe[6], pIe[7]); |
| 1933 | if (pConfig->num_accept_mac > MAX_MAC_ADDRESS_ACCEPTED) |
| 1934 | pConfig->num_accept_mac = MAX_MAC_ADDRESS_ACCEPTED; |
| 1935 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1936 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 1937 | { |
| 1938 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1939 | acl_entry++; |
| 1940 | } |
| 1941 | } |
| 1942 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 1943 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1944 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 1945 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 1946 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 1947 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 1948 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 1949 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1950 | (((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] | 1951 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 1952 | ((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] | 1953 | { |
| 1954 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
| 1955 | } |
| 1956 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1957 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1958 | if( AUTO_CHANNEL_SELECT != pConfig->channel) |
| 1959 | wlan_sap_select_cbmode((WLAN_HDD_GET_CTX(pHostapdAdapter)),pConfig->SapHw_mode,pConfig->channel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1960 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 1961 | pConfig->ht_capab = |
| 1962 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 1963 | |
| 1964 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 1965 | { |
| 1966 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 1967 | return -EINVAL; |
| 1968 | } |
| 1969 | |
| 1970 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1971 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1972 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 1973 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1974 | pConfig->obssProtEnabled = |
| 1975 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1976 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1977 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1978 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1979 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1980 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 1981 | (int)pConfig->channel); |
| 1982 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1983 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 1984 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1985 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1986 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1987 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 1988 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 1989 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1990 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1991 | { |
| 1992 | //Bss already started. just return. |
| 1993 | //TODO Probably it should update some beacon params. |
| 1994 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 1995 | EXIT(); |
| 1996 | return 0; |
| 1997 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1998 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1999 | pConfig->persona = pHostapdAdapter->device_mode; |
| 2000 | |
| 2001 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 2002 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 2003 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 2004 | { |
| 2005 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 2006 | return -EINVAL; |
| 2007 | } |
| 2008 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2009 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2010 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2011 | |
| 2012 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2013 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2014 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2015 | { |
| 2016 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2017 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2018 | VOS_ASSERT(0); |
| 2019 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2020 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2021 | //Succesfully started Bss update the state bit. |
| 2022 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2023 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2024 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2025 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2026 | { |
| 2027 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2028 | { |
| 2029 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2030 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2031 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2032 | } |
| 2033 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2034 | { |
| 2035 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2036 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2037 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2038 | } |
| 2039 | } |
| 2040 | #endif |
| 2041 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2042 | pHostapdState->bCommit = TRUE; |
| 2043 | EXIT(); |
| 2044 | |
| 2045 | return 0; |
| 2046 | } |
| 2047 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2048 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2049 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2050 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2051 | struct beacon_parameters *params) |
| 2052 | { |
| 2053 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2054 | int status=VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2055 | |
| 2056 | ENTER(); |
| 2057 | |
| 2058 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 2059 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2060 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 2061 | { |
| 2062 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2063 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2064 | return -EAGAIN; |
| 2065 | } |
| 2066 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2067 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2068 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2069 | ) |
| 2070 | { |
| 2071 | beacon_data_t *old,*new; |
| 2072 | |
| 2073 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2074 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2075 | if (old) |
| 2076 | return -EALREADY; |
| 2077 | |
| 2078 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2079 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2080 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2081 | { |
| 2082 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2083 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 2084 | return -EINVAL; |
| 2085 | } |
| 2086 | |
| 2087 | pAdapter->sessionCtx.ap.beacon = new; |
| 2088 | |
| 2089 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2090 | } |
| 2091 | |
| 2092 | EXIT(); |
| 2093 | return status; |
| 2094 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2095 | |
| 2096 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2097 | struct net_device *dev, |
| 2098 | struct beacon_parameters *params) |
| 2099 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2100 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2101 | int status=VOS_STATUS_SUCCESS; |
| 2102 | |
| 2103 | ENTER(); |
| 2104 | |
| 2105 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2106 | __func__,pAdapter->device_mode); |
| 2107 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2108 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 2109 | { |
| 2110 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2111 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2112 | return -EAGAIN; |
| 2113 | } |
| 2114 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2115 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2116 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2117 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2118 | { |
| 2119 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2121 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2122 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2123 | if (!old) |
| 2124 | return -ENOENT; |
| 2125 | |
| 2126 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2127 | |
| 2128 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2129 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2130 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2131 | return -EINVAL; |
| 2132 | } |
| 2133 | |
| 2134 | pAdapter->sessionCtx.ap.beacon = new; |
| 2135 | |
| 2136 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2137 | } |
| 2138 | |
| 2139 | EXIT(); |
| 2140 | return status; |
| 2141 | } |
| 2142 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2143 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2144 | |
| 2145 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2146 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2147 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2148 | #else |
| 2149 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2150 | struct net_device *dev) |
| 2151 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2152 | { |
| 2153 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2154 | hdd_context_t *pHddCtx = NULL; |
| 2155 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2156 | hdd_adapter_t *staAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2157 | VOS_STATUS status = 0; |
| 2158 | |
| 2159 | ENTER(); |
| 2160 | |
| 2161 | if (NULL == pAdapter) |
| 2162 | { |
| 2163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2164 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2165 | return -ENODEV; |
| 2166 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2167 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2168 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2169 | if (NULL == pHddCtx) |
| 2170 | { |
| 2171 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2172 | "%s: HDD context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2173 | return -ENODEV; |
| 2174 | } |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2175 | if (pHddCtx->isLogpInProgress) |
| 2176 | { |
| 2177 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2178 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2179 | return -EAGAIN; |
| 2180 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2181 | |
| 2182 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2183 | if (NULL == staAdapter) |
| 2184 | { |
| 2185 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2186 | if (NULL == staAdapter) |
| 2187 | { |
| 2188 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2189 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2190 | return -ENODEV; |
| 2191 | } |
| 2192 | } |
| 2193 | |
| 2194 | pScanInfo = &pHddCtx->scan_info; |
| 2195 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2196 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2197 | { |
| 2198 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2199 | return -EAGAIN; |
| 2200 | } |
| 2201 | |
| 2202 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2203 | |
| 2204 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2205 | __func__,pAdapter->device_mode); |
| 2206 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2207 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2208 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2209 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2210 | hdd_abort_mac_scan(staAdapter->pHddCtx); |
| 2211 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2212 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2213 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2214 | if (!status) |
| 2215 | { |
| 2216 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2217 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2218 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2219 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2220 | return 0; |
| 2221 | } |
| 2222 | } |
| 2223 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2224 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2225 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2226 | ) |
| 2227 | { |
| 2228 | beacon_data_t *old; |
| 2229 | |
| 2230 | old = pAdapter->sessionCtx.ap.beacon; |
| 2231 | |
| 2232 | if (!old) |
| 2233 | return -ENOENT; |
| 2234 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2235 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2236 | |
| 2237 | mutex_lock(&pHddCtx->sap_lock); |
| 2238 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2239 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2240 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2241 | { |
| 2242 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2243 | |
| 2244 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2245 | |
| 2246 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2247 | { |
| 2248 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2249 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2250 | VOS_ASSERT(0); |
| 2251 | } |
| 2252 | } |
| 2253 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2254 | } |
| 2255 | mutex_unlock(&pHddCtx->sap_lock); |
| 2256 | |
| 2257 | if(status != VOS_STATUS_SUCCESS) |
| 2258 | { |
| 2259 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2260 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2261 | return -EINVAL; |
| 2262 | } |
| 2263 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2264 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2265 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2266 | ==eHAL_STATUS_FAILURE) |
| 2267 | { |
| 2268 | hddLog(LOGE, |
| 2269 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2270 | } |
| 2271 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2272 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2273 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2274 | eANI_BOOLEAN_FALSE) ) |
| 2275 | { |
| 2276 | hddLog(LOGE, |
| 2277 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2278 | } |
| 2279 | |
| 2280 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2281 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2282 | |
| 2283 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2284 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2285 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2286 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2287 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2288 | { |
| 2289 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2290 | "GO got removed"); |
| 2291 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2292 | } |
| 2293 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2294 | } |
| 2295 | EXIT(); |
| 2296 | return status; |
| 2297 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2298 | |
| 2299 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2300 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2301 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2302 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2303 | struct cfg80211_ap_settings *params) |
| 2304 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2305 | hdd_adapter_t *pAdapter; |
| 2306 | hdd_context_t *pHddCtx; |
| 2307 | int status = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2308 | |
| 2309 | ENTER(); |
| 2310 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2311 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2312 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2313 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2314 | "%s: Device is Null", __func__); |
| 2315 | return -ENODEV; |
| 2316 | } |
| 2317 | |
| 2318 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2319 | if (NULL == pAdapter) |
| 2320 | { |
| 2321 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2322 | "%s: HDD adapter is Null", __func__); |
| 2323 | return -ENODEV; |
| 2324 | } |
| 2325 | |
| 2326 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2327 | { |
| 2328 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2329 | "%s: HDD adapter magic is invalid", __func__); |
| 2330 | return -ENODEV; |
| 2331 | } |
| 2332 | |
| 2333 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2334 | if (NULL == pHddCtx) |
| 2335 | { |
| 2336 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2337 | "%s: HDD context is Null", __func__); |
| 2338 | return -ENODEV; |
| 2339 | } |
| 2340 | |
| 2341 | if (pHddCtx->isLogpInProgress) |
| 2342 | { |
| 2343 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2344 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2345 | return -EAGAIN; |
| 2346 | } |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2347 | |
| 2348 | if (pHddCtx->isLoadUnloadInProgress) |
| 2349 | { |
| 2350 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2351 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 2352 | return -EAGAIN; |
| 2353 | } |
| 2354 | |
| 2355 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2356 | __func__, pAdapter->device_mode); |
| 2357 | |
| 2358 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2359 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2360 | ) |
| 2361 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2362 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2363 | |
| 2364 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2365 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2366 | if (old) |
| 2367 | return -EALREADY; |
| 2368 | |
| 2369 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2370 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2371 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2372 | { |
| 2373 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2374 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2375 | return -EINVAL; |
| 2376 | } |
| 2377 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2378 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2379 | wlan_hdd_cfg80211_set_channel(wiphy, dev, params->channel, params->channel_type); |
| 2380 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2381 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2382 | params->ssid_len, params->hidden_ssid); |
| 2383 | } |
| 2384 | |
| 2385 | EXIT(); |
| 2386 | return status; |
| 2387 | } |
| 2388 | |
| 2389 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2390 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2391 | struct net_device *dev, |
| 2392 | struct cfg80211_beacon_data *params) |
| 2393 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2394 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2395 | int status=VOS_STATUS_SUCCESS; |
| 2396 | |
| 2397 | ENTER(); |
| 2398 | |
| 2399 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2400 | __func__, pAdapter->device_mode); |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2401 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2402 | { |
| 2403 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2404 | return -EAGAIN; |
| 2405 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2406 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2407 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2408 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2409 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2410 | { |
| 2411 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2412 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2413 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2414 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2415 | if (!old) |
| 2416 | return -ENOENT; |
| 2417 | |
| 2418 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2419 | |
| 2420 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2421 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2422 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2423 | return -EINVAL; |
| 2424 | } |
| 2425 | |
| 2426 | pAdapter->sessionCtx.ap.beacon = new; |
| 2427 | |
| 2428 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2429 | } |
| 2430 | |
| 2431 | EXIT(); |
| 2432 | return status; |
| 2433 | } |
| 2434 | |
| 2435 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2436 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2437 | |
| 2438 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2439 | struct net_device *dev, |
| 2440 | struct bss_parameters *params) |
| 2441 | { |
| 2442 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2443 | |
| 2444 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2445 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2446 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2447 | __func__,pAdapter->device_mode); |
| 2448 | |
| 2449 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2450 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2451 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2452 | { |
| 2453 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2454 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2455 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2456 | { |
| 2457 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2458 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2459 | } |
| 2460 | |
| 2461 | EXIT(); |
| 2462 | return 0; |
| 2463 | } |
| 2464 | |
| 2465 | /* |
| 2466 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2467 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2468 | */ |
| 2469 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2470 | struct net_device *ndev, |
| 2471 | enum nl80211_iftype type, |
| 2472 | u32 *flags, |
| 2473 | struct vif_params *params |
| 2474 | ) |
| 2475 | { |
| 2476 | struct wireless_dev *wdev; |
| 2477 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2478 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2479 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2480 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2481 | eCsrRoamBssType LastBSSType; |
| 2482 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 2483 | eMib_dot11DesiredBssType connectedBssType; |
| 2484 | VOS_STATUS status; |
| 2485 | |
| 2486 | ENTER(); |
| 2487 | |
| 2488 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2489 | { |
| 2490 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2491 | return -EAGAIN; |
| 2492 | } |
| 2493 | |
| 2494 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2495 | __func__, pAdapter->device_mode); |
| 2496 | |
| 2497 | wdev = ndev->ieee80211_ptr; |
| 2498 | |
| 2499 | #ifdef WLAN_BTAMP_FEATURE |
| 2500 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2501 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2502 | (NL80211_IFTYPE_AP == type)|| |
| 2503 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2504 | { |
| 2505 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2506 | // stop AMP traffic |
| 2507 | status = WLANBAP_StopAmp(); |
| 2508 | if(VOS_STATUS_SUCCESS != status ) |
| 2509 | { |
| 2510 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2511 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2512 | "%s: Failed to stop AMP", __func__); |
| 2513 | return -EINVAL; |
| 2514 | } |
| 2515 | } |
| 2516 | #endif //WLAN_BTAMP_FEATURE |
| 2517 | /* Reset the current device mode bit mask*/ |
| 2518 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2519 | |
| 2520 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2521 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2522 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2523 | ) |
| 2524 | { |
| 2525 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2526 | pRoamProfile = &pWextState->roamProfile; |
| 2527 | LastBSSType = pRoamProfile->BSSType; |
| 2528 | |
| 2529 | switch (type) |
| 2530 | { |
| 2531 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2532 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2533 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2534 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2535 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2536 | #ifdef WLAN_FEATURE_11AC |
| 2537 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2538 | { |
| 2539 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2540 | } |
| 2541 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2542 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2543 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2544 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2545 | //Check for sub-string p2p to confirm its a p2p interface |
| 2546 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2547 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2548 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2549 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2550 | } |
| 2551 | else |
| 2552 | { |
| 2553 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2554 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2555 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2556 | break; |
| 2557 | case NL80211_IFTYPE_ADHOC: |
| 2558 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2559 | "%s: setting interface Type to ADHOC", __func__); |
| 2560 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2561 | pRoamProfile->phyMode = |
| 2562 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2563 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2564 | wdev->iftype = type; |
| 2565 | break; |
| 2566 | |
| 2567 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2568 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2569 | { |
| 2570 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2571 | "%s: setting interface Type to %s", __func__, |
| 2572 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2573 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2574 | //Cancel any remain on channel for GO mode |
| 2575 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2576 | { |
| 2577 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2578 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2579 | if (NL80211_IFTYPE_AP == type) |
| 2580 | { |
| 2581 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2582 | * address. This will take one HW STA and the max number of clients |
| 2583 | * that can connect to softAP will be reduced by one. so while changing |
| 2584 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2585 | * interface as it is not required in SoftAP mode. |
| 2586 | */ |
| 2587 | |
| 2588 | // Get P2P Adapter |
| 2589 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2590 | |
| 2591 | if (pP2pAdapter) |
| 2592 | { |
| 2593 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2594 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2595 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2596 | } |
| 2597 | } |
| 2598 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2599 | //De-init the adapter. |
| 2600 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2601 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2602 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2603 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2604 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2605 | |
| 2606 | //Disable BMPS and IMPS if enabled |
| 2607 | //before starting Go |
| 2608 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2609 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2610 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2611 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2612 | { |
| 2613 | //Fail to Exit BMPS |
| 2614 | VOS_ASSERT(0); |
| 2615 | } |
| 2616 | } |
| 2617 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2618 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2619 | (pConfig->apRandomBssidEnabled)) |
| 2620 | { |
| 2621 | /* To meet Android requirements create a randomized |
| 2622 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2623 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2624 | ndev->dev_addr[0] = 0x02; |
| 2625 | ndev->dev_addr[1] = 0x1A; |
| 2626 | ndev->dev_addr[2] = 0x11; |
| 2627 | ndev->dev_addr[3] |= 0xF0; |
| 2628 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2629 | VOS_MAC_ADDR_SIZE); |
| 2630 | pr_info("wlan: Generated HotSpot BSSID " |
| 2631 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2632 | ndev->dev_addr[0], |
| 2633 | ndev->dev_addr[1], |
| 2634 | ndev->dev_addr[2], |
| 2635 | ndev->dev_addr[3], |
| 2636 | ndev->dev_addr[4], |
| 2637 | ndev->dev_addr[5]); |
| 2638 | } |
| 2639 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2640 | hdd_set_ap_ops( pAdapter->dev ); |
| 2641 | |
| 2642 | status = hdd_init_ap_mode(pAdapter); |
| 2643 | if(status != VOS_STATUS_SUCCESS) |
| 2644 | { |
| 2645 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2646 | "%s: Error initializing the ap mode", __func__); |
| 2647 | return -EINVAL; |
| 2648 | } |
| 2649 | hdd_set_conparam(1); |
| 2650 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2651 | /*interface type changed update in wiphy structure*/ |
| 2652 | if(wdev) |
| 2653 | { |
| 2654 | wdev->iftype = type; |
| 2655 | pHddCtx->change_iface = type; |
| 2656 | } |
| 2657 | else |
| 2658 | { |
| 2659 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2660 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2661 | return -EINVAL; |
| 2662 | } |
| 2663 | goto done; |
| 2664 | } |
| 2665 | |
| 2666 | default: |
| 2667 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2668 | __func__); |
| 2669 | return -EOPNOTSUPP; |
| 2670 | } |
| 2671 | } |
| 2672 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2673 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2674 | ) |
| 2675 | { |
| 2676 | switch(type) |
| 2677 | { |
| 2678 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2679 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2680 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2681 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2682 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2683 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2684 | //Check for sub-string p2p to confirm its a p2p interface |
| 2685 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2686 | { |
| 2687 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2688 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2689 | } |
| 2690 | else |
| 2691 | { |
| 2692 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2693 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2694 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2695 | hdd_set_conparam(0); |
| 2696 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2697 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2698 | hdd_set_station_ops( pAdapter->dev ); |
| 2699 | status = hdd_init_station_mode( pAdapter ); |
| 2700 | if( VOS_STATUS_SUCCESS != status ) |
| 2701 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2702 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2703 | * This is the right place to enable back bmps_imps() |
| 2704 | */ |
| 2705 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2706 | goto done; |
| 2707 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2708 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2709 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2710 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2711 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2712 | goto done; |
| 2713 | default: |
| 2714 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2715 | __func__); |
| 2716 | return -EOPNOTSUPP; |
| 2717 | |
| 2718 | } |
| 2719 | |
| 2720 | } |
| 2721 | else |
| 2722 | { |
| 2723 | return -EOPNOTSUPP; |
| 2724 | } |
| 2725 | |
| 2726 | |
| 2727 | if(pRoamProfile) |
| 2728 | { |
| 2729 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2730 | { |
| 2731 | /*interface type changed update in wiphy structure*/ |
| 2732 | wdev->iftype = type; |
| 2733 | |
| 2734 | /*the BSS mode changed, We need to issue disconnect |
| 2735 | if connected or in IBSS disconnect state*/ |
| 2736 | if ( hdd_connGetConnectedBssType( |
| 2737 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2738 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2739 | { |
| 2740 | /*need to issue a disconnect to CSR.*/ |
| 2741 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2742 | if( eHAL_STATUS_SUCCESS == |
| 2743 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2744 | pAdapter->sessionId, |
| 2745 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2746 | { |
| 2747 | wait_for_completion_interruptible_timeout( |
| 2748 | &pAdapter->disconnect_comp_var, |
| 2749 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2750 | } |
| 2751 | } |
| 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | done: |
| 2756 | /*set bitmask based on updated value*/ |
| 2757 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2758 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2759 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2760 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2761 | { |
| 2762 | //we are ok to do AMP |
| 2763 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2764 | } |
| 2765 | #endif //WLAN_BTAMP_FEATURE |
| 2766 | EXIT(); |
| 2767 | return 0; |
| 2768 | } |
| 2769 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2770 | #ifdef FEATURE_WLAN_TDLS |
| 2771 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2772 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2773 | { |
| 2774 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2775 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2776 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2777 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2778 | |
| 2779 | ENTER(); |
| 2780 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2781 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2782 | { |
| 2783 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2784 | "Invalid arguments"); |
| 2785 | return -EINVAL; |
| 2786 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2787 | |
| 2788 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2789 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2790 | { |
| 2791 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2792 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2793 | MAC_ADDRESS_STR " Request declined.", |
| 2794 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2795 | return -ENOTSUPP; |
| 2796 | } |
| 2797 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2798 | if (pHddCtx->isLogpInProgress) |
| 2799 | { |
| 2800 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2801 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2802 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2803 | return -EBUSY; |
| 2804 | } |
| 2805 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2806 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2807 | |
| 2808 | if ( NULL == pTdlsPeer ) { |
| 2809 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2810 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2811 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2812 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2813 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2814 | |
| 2815 | /* in add station, we accept existing valid staId if there is */ |
| 2816 | if ((0 == update) && |
| 2817 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2818 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2819 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2820 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2821 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2822 | " link_status %d. staId %d. add station ignored.", |
| 2823 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2824 | return 0; |
| 2825 | } |
| 2826 | /* in change station, we accept only when staId is valid */ |
| 2827 | if ((1 == update) && |
| 2828 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2829 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2830 | { |
| 2831 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2832 | "%s: " MAC_ADDRESS_STR |
| 2833 | " link status %d. staId %d. change station %s.", |
| 2834 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2835 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2836 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2837 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2838 | |
| 2839 | /* 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] | 2840 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2841 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2842 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2843 | "%s: " MAC_ADDRESS_STR |
| 2844 | " TDLS setup is ongoing. Request declined.", |
| 2845 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2846 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2847 | } |
| 2848 | |
| 2849 | /* first to check if we reached to maximum supported TDLS peer. |
| 2850 | TODO: for now, return -EPERM looks working fine, |
| 2851 | but need to check if any other errno fit into this category.*/ |
| 2852 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2853 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2854 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2855 | "%s: " MAC_ADDRESS_STR |
| 2856 | " TDLS Max peer already connected. Request declined.", |
| 2857 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2858 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2859 | } |
| 2860 | else |
| 2861 | { |
| 2862 | hddTdlsPeer_t *pTdlsPeer; |
| 2863 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2864 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2865 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2866 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2867 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2868 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2869 | return -EPERM; |
| 2870 | } |
| 2871 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2872 | if (0 == update) |
| 2873 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2874 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2875 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2876 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2877 | { |
| 2878 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2879 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2880 | if(StaParams->htcap_present) |
| 2881 | { |
| 2882 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2883 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 2884 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2885 | "ht_capa->extended_capabilities: %0x", |
| 2886 | StaParams->HTCap.extendedHtCapInfo); |
| 2887 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2888 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2889 | "params->capability: %0x",StaParams->capability); |
| 2890 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2891 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2892 | if(StaParams->vhtcap_present) |
| 2893 | { |
| 2894 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2895 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 2896 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 2897 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 2898 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2899 | { |
| 2900 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2901 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2902 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 2903 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2904 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 2905 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2906 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2907 | else if ((1 == update) && (NULL == StaParams)) |
| 2908 | { |
| 2909 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2910 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 2911 | return -EPERM; |
| 2912 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2913 | |
| 2914 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 2915 | |
| 2916 | if (!update) |
| 2917 | { |
| 2918 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2919 | pAdapter->sessionId, mac); |
| 2920 | } |
| 2921 | else |
| 2922 | { |
| 2923 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2924 | pAdapter->sessionId, mac, StaParams); |
| 2925 | } |
| 2926 | |
| 2927 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 2928 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 2929 | |
| 2930 | if (!status) |
| 2931 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2932 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2933 | "%s: timeout waiting for tdls add station indication", |
| 2934 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2935 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2936 | } |
| 2937 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 2938 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2939 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2940 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2941 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2942 | } |
| 2943 | |
| 2944 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2945 | |
| 2946 | error: |
| 2947 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 2948 | return -EPERM; |
| 2949 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2950 | } |
| 2951 | #endif |
| 2952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2953 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 2954 | struct net_device *dev, |
| 2955 | u8 *mac, |
| 2956 | struct station_parameters *params) |
| 2957 | { |
| 2958 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2959 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 2960 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2961 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2962 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2963 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2964 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2965 | ENTER(); |
| 2966 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2967 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 2968 | { |
| 2969 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2970 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2971 | return -EAGAIN; |
| 2972 | } |
| 2973 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2974 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 2975 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2976 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 2977 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2978 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2979 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2980 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2981 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2982 | WLANTL_STA_AUTHENTICATED); |
| 2983 | |
| 2984 | VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2985 | "%s: Station MAC address does not matching", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2986 | return -EINVAL; |
| 2987 | } |
| 2988 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2989 | #ifdef FEATURE_WLAN_TDLS |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2990 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 2991 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2992 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 2993 | StaParams.capability = params->capability; |
| 2994 | StaParams.uapsd_queues = params->uapsd_queues; |
| 2995 | StaParams.max_sp = params->max_sp; |
| 2996 | |
| 2997 | if (0 != params->ext_capab_len) |
| 2998 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 2999 | sizeof(StaParams.extn_capability)); |
| 3000 | |
| 3001 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3002 | { |
| 3003 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3004 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3005 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3006 | |
| 3007 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3008 | |
| 3009 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3010 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3011 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3012 | * modified to send more rates. |
| 3013 | */ |
| 3014 | |
| 3015 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3016 | */ |
| 3017 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3018 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3019 | |
| 3020 | if (0 != StaParams.supported_rates_len) { |
| 3021 | int i = 0; |
| 3022 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3023 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3024 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3025 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3026 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3027 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3028 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3029 | } |
| 3030 | |
| 3031 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3032 | { |
| 3033 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3034 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3035 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3036 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3037 | if (0 != params->ext_capab_len ) { |
| 3038 | /*Define A Macro : TODO Sunil*/ |
| 3039 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3040 | isBufSta = 1; |
| 3041 | } |
| 3042 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3043 | //status = wlan_hdd_tdls_set_peer_caps( mac, params->uapsd_queues, |
| 3044 | // params->max_sp, isBufSta); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3045 | //if (VOS_STATUS_SUCCESS != status) { |
| 3046 | // VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3047 | // "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3048 | // return -EINVAL; |
| 3049 | //} |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3050 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3051 | |
| 3052 | if (VOS_STATUS_SUCCESS != status) { |
| 3053 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3054 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3055 | return -EINVAL; |
| 3056 | } |
| 3057 | } |
| 3058 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3059 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3060 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3061 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3062 | return status; |
| 3063 | } |
| 3064 | |
| 3065 | /* |
| 3066 | * FUNCTION: wlan_hdd_cfg80211_get_ibss_peer_staidx |
| 3067 | * This function is used to get peer station index in IBSS mode |
| 3068 | */ |
| 3069 | static u8 wlan_hdd_cfg80211_get_ibss_peer_staidx(hdd_adapter_t* pAdapter) |
| 3070 | { |
| 3071 | u8 idx = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3072 | u8 temp[VOS_MAC_ADDR_SIZE] = {0}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3073 | ENTER(); |
| 3074 | memset(temp, 0, VOS_MAC_ADDR_SIZE); |
| 3075 | for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ ) |
| 3076 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3077 | if ( (0 != |
| 3078 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[idx]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3079 | && memcmp((u8*)&(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.peerMacAddress[idx], |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3080 | temp, VOS_MAC_ADDR_SIZE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3081 | ) |
| 3082 | { |
| 3083 | return idx; |
| 3084 | } |
| 3085 | } |
| 3086 | return idx; |
| 3087 | } |
| 3088 | |
| 3089 | |
| 3090 | /* |
| 3091 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3092 | * This function is used to initialize the key information |
| 3093 | */ |
| 3094 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3095 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3096 | struct net_device *ndev, |
| 3097 | u8 key_index, bool pairwise, |
| 3098 | const u8 *mac_addr, |
| 3099 | struct key_params *params |
| 3100 | ) |
| 3101 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3102 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3103 | struct net_device *ndev, |
| 3104 | u8 key_index, const u8 *mac_addr, |
| 3105 | struct key_params *params |
| 3106 | ) |
| 3107 | #endif |
| 3108 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3109 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3110 | tCsrRoamSetKey setKey; |
| 3111 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3112 | int status = 0; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3113 | v_U32_t roamId= 0xFF; |
| 3114 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3115 | hdd_hostapd_state_t *pHostapdState; |
| 3116 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3117 | eHalStatus halStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3118 | |
| 3119 | ENTER(); |
| 3120 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3121 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 3122 | { |
| 3123 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3124 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3125 | return -EAGAIN; |
| 3126 | } |
| 3127 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3128 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3129 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3130 | |
| 3131 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3132 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3133 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3134 | key_index); |
| 3135 | |
| 3136 | return -EINVAL; |
| 3137 | } |
| 3138 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3139 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3140 | { |
| 3141 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3142 | params->key_len); |
| 3143 | |
| 3144 | return -EINVAL; |
| 3145 | } |
| 3146 | |
| 3147 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3148 | "%s: called with key index = %d & key length %d", |
| 3149 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3150 | |
| 3151 | /*extract key idx, key len and key*/ |
| 3152 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3153 | setKey.keyId = key_index; |
| 3154 | setKey.keyLength = params->key_len; |
| 3155 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3156 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3157 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3158 | { |
| 3159 | case WLAN_CIPHER_SUITE_WEP40: |
| 3160 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3161 | break; |
| 3162 | |
| 3163 | case WLAN_CIPHER_SUITE_WEP104: |
| 3164 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3165 | break; |
| 3166 | |
| 3167 | case WLAN_CIPHER_SUITE_TKIP: |
| 3168 | { |
| 3169 | u8 *pKey = &setKey.Key[0]; |
| 3170 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3171 | |
| 3172 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3173 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3174 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3175 | |
| 3176 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3177 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3178 | |--------------|----------|----------| |
| 3179 | <---16bytes---><--8bytes--><--8bytes--> |
| 3180 | |
| 3181 | */ |
| 3182 | /*Sme expects the 32 bytes key to be in the below order |
| 3183 | |
| 3184 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3185 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3186 | |--------------|----------|----------| |
| 3187 | <---16bytes---><--8bytes--><--8bytes--> |
| 3188 | */ |
| 3189 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3190 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3191 | |
| 3192 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3193 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3194 | |
| 3195 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3196 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3197 | |
| 3198 | |
| 3199 | break; |
| 3200 | } |
| 3201 | |
| 3202 | case WLAN_CIPHER_SUITE_CCMP: |
| 3203 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3204 | break; |
| 3205 | |
| 3206 | #ifdef FEATURE_WLAN_WAPI |
| 3207 | case WLAN_CIPHER_SUITE_SMS4: |
| 3208 | { |
| 3209 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3210 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3211 | params->key, params->key_len); |
| 3212 | return 0; |
| 3213 | } |
| 3214 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3215 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3216 | #ifdef FEATURE_WLAN_CCX |
| 3217 | case WLAN_CIPHER_SUITE_KRK: |
| 3218 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3219 | break; |
| 3220 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3221 | |
| 3222 | #ifdef WLAN_FEATURE_11W |
| 3223 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3224 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3225 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3226 | #endif |
| 3227 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3228 | default: |
| 3229 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3230 | __func__, params->cipher); |
| 3231 | return -EOPNOTSUPP; |
| 3232 | } |
| 3233 | |
| 3234 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3235 | __func__, setKey.encType); |
| 3236 | |
| 3237 | |
| 3238 | |
| 3239 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3240 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3241 | ) |
| 3242 | { |
| 3243 | |
| 3244 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3245 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3246 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3247 | (!pairwise) |
| 3248 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3249 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3250 | #endif |
| 3251 | ) |
| 3252 | { |
| 3253 | /* set group key*/ |
| 3254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 3255 | "%s- %d: setting Broadcast key", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3256 | __func__, __LINE__); |
| 3257 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3258 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3259 | } |
| 3260 | else |
| 3261 | { |
| 3262 | /* set pairwise key*/ |
| 3263 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3264 | "%s- %d: setting pairwise key", |
| 3265 | __func__, __LINE__); |
| 3266 | setKey.keyDirection = eSIR_TX_RX; |
| 3267 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3268 | } |
| 3269 | |
| 3270 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3271 | if( pHostapdState->bssState == BSS_START ) |
| 3272 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3273 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3274 | |
| 3275 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3276 | { |
| 3277 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3278 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3279 | __LINE__, status ); |
| 3280 | } |
| 3281 | } |
| 3282 | |
| 3283 | /* Saving WEP keys */ |
| 3284 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3285 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3286 | { |
| 3287 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3288 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3289 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3290 | } |
| 3291 | else |
| 3292 | { |
| 3293 | //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] | 3294 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3295 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3296 | } |
| 3297 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3298 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3299 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3300 | { |
| 3301 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3302 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3303 | |
| 3304 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3305 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3306 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3307 | |
| 3308 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3309 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3310 | params->key, params->key_len); |
| 3311 | |
| 3312 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3313 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3314 | if (!( ( IW_AUTH_KEY_MGMT_802_1X |
| 3315 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3316 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3317 | ) |
| 3318 | && |
| 3319 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3320 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3321 | ) |
| 3322 | ) |
| 3323 | { |
| 3324 | /* in case of static WEP, macaddr/bssid is not coming from nl80211 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3325 | * interface, copy bssid for pairwise key and group macaddr for |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3326 | * group key initialization*/ |
| 3327 | |
| 3328 | tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile; |
| 3329 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3330 | pWextState->roamProfile.negotiatedUCEncryptionType = |
| 3331 | pHddStaCtx->conn_info.ucEncryptionType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3332 | ((WLAN_CIPHER_SUITE_WEP40 == params->cipher) ? |
| 3333 | eCSR_ENCRYPT_TYPE_WEP40_STATICKEY : |
| 3334 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY); |
| 3335 | |
| 3336 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3337 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3338 | "%s: Negotiated encryption type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3339 | pWextState->roamProfile.negotiatedUCEncryptionType); |
| 3340 | |
| 3341 | sme_SetCfgPrivacy((tpAniSirGlobal)WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3342 | &pWextState->roamProfile, true); |
| 3343 | setKey.keyLength = 0; |
| 3344 | setKey.keyDirection = eSIR_TX_RX; |
| 3345 | |
| 3346 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3347 | if (pairwise) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3348 | { |
| 3349 | #endif |
| 3350 | if (mac_addr) |
| 3351 | { |
| 3352 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3353 | } |
| 3354 | else |
| 3355 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3356 | /* macaddr is NULL, set the peerMac to bssId in case of BSS, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3357 | * and peerMacAddress in case of IBSS*/ |
| 3358 | if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) |
| 3359 | { |
| 3360 | u8 staidx = wlan_hdd_cfg80211_get_ibss_peer_staidx(pAdapter); |
| 3361 | if (HDD_MAX_NUM_IBSS_STA != staidx) |
| 3362 | { |
| 3363 | vos_mem_copy(setKey.peerMac, |
| 3364 | &pHddStaCtx->conn_info.peerMacAddress[staidx], |
| 3365 | WNI_CFG_BSSID_LEN); |
| 3366 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3367 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3368 | else |
| 3369 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3370 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No peerMac found", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3371 | __func__); |
| 3372 | return -EOPNOTSUPP; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3373 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3374 | } |
| 3375 | else |
| 3376 | { |
| 3377 | vos_mem_copy(setKey.peerMac, |
| 3378 | &pHddStaCtx->conn_info.bssId[0], |
| 3379 | WNI_CFG_BSSID_LEN); |
| 3380 | } |
| 3381 | } |
| 3382 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3383 | } |
| 3384 | else |
| 3385 | { |
| 3386 | /* set group key*/ |
| 3387 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3388 | "%s- %d: setting Group key", |
| 3389 | __func__, __LINE__); |
| 3390 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3391 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3392 | } |
| 3393 | #endif |
| 3394 | } |
| 3395 | else if ( |
| 3396 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3397 | (!pairwise) |
| 3398 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3399 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3400 | #endif |
| 3401 | ) |
| 3402 | { |
| 3403 | /* set group key*/ |
| 3404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3405 | "%s- %d: setting Group key", |
| 3406 | __func__, __LINE__); |
| 3407 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3408 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3409 | } |
| 3410 | else |
| 3411 | { |
| 3412 | /* set pairwise key*/ |
| 3413 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3414 | "%s- %d: setting pairwise key", |
| 3415 | __func__, __LINE__); |
| 3416 | setKey.keyDirection = eSIR_TX_RX; |
| 3417 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3418 | } |
| 3419 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3420 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3421 | "%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] | 3422 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3423 | setKey.peerMac[2], setKey.peerMac[3], |
| 3424 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3425 | setKey.keyDirection); |
| 3426 | |
| 3427 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3428 | |
| 3429 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3430 | { |
| 3431 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3432 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3433 | __LINE__, vos_status ); |
| 3434 | |
| 3435 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3436 | |
| 3437 | return -EINVAL; |
| 3438 | |
| 3439 | } |
| 3440 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3441 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3442 | /* The supplicant may attempt to set the PTK once pre-authentication is done. |
| 3443 | 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] | 3444 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3445 | if( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_WAIT ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3446 | { |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3447 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3448 | } |
| 3449 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3450 | |
| 3451 | /* issue set key request to SME*/ |
| 3452 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3453 | pAdapter->sessionId, &setKey, &roamId ); |
| 3454 | |
| 3455 | if ( 0 != status ) |
| 3456 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3457 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3458 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3459 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3460 | return -EINVAL; |
| 3461 | } |
| 3462 | |
| 3463 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3464 | /* in case of IBSS as there was no information available about WEP keys during |
| 3465 | * 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] | 3466 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3467 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3468 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3469 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3470 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3471 | ) |
| 3472 | && |
| 3473 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3474 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3475 | ) |
| 3476 | ) |
| 3477 | { |
| 3478 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3479 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3480 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3481 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3482 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3483 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3484 | setKey.peerMac[2], setKey.peerMac[3], |
| 3485 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3486 | setKey.keyDirection); |
| 3487 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3488 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3489 | pAdapter->sessionId, &setKey, &roamId ); |
| 3490 | |
| 3491 | if ( 0 != status ) |
| 3492 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3493 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3494 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3495 | __func__, status); |
| 3496 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3497 | return -EINVAL; |
| 3498 | } |
| 3499 | } |
| 3500 | } |
| 3501 | |
| 3502 | return 0; |
| 3503 | } |
| 3504 | |
| 3505 | /* |
| 3506 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3507 | * This function is used to get the key information |
| 3508 | */ |
| 3509 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3510 | static int wlan_hdd_cfg80211_get_key( |
| 3511 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3512 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3513 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3514 | const u8 *mac_addr, void *cookie, |
| 3515 | void (*callback)(void *cookie, struct key_params*) |
| 3516 | ) |
| 3517 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3518 | static int wlan_hdd_cfg80211_get_key( |
| 3519 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3520 | struct net_device *ndev, |
| 3521 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3522 | void (*callback)(void *cookie, struct key_params*) |
| 3523 | ) |
| 3524 | #endif |
| 3525 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3526 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3527 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3528 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3529 | struct key_params params; |
| 3530 | |
| 3531 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3532 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3533 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3534 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3535 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3536 | memset(¶ms, 0, sizeof(params)); |
| 3537 | |
| 3538 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3539 | { |
| 3540 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3541 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3542 | |
| 3543 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3544 | { |
| 3545 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3546 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3547 | break; |
| 3548 | |
| 3549 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3550 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3551 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3552 | break; |
| 3553 | |
| 3554 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3555 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3556 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3557 | break; |
| 3558 | |
| 3559 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3560 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3561 | break; |
| 3562 | |
| 3563 | case eCSR_ENCRYPT_TYPE_AES: |
| 3564 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3565 | break; |
| 3566 | |
| 3567 | default: |
| 3568 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3569 | break; |
| 3570 | } |
| 3571 | |
| 3572 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3573 | params.seq_len = 0; |
| 3574 | params.seq = NULL; |
| 3575 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3576 | callback(cookie, ¶ms); |
| 3577 | return 0; |
| 3578 | } |
| 3579 | |
| 3580 | /* |
| 3581 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3582 | * This function is used to delete the key information |
| 3583 | */ |
| 3584 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3585 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3586 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3587 | u8 key_index, |
| 3588 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3589 | const u8 *mac_addr |
| 3590 | ) |
| 3591 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3592 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3593 | struct net_device *ndev, |
| 3594 | u8 key_index, |
| 3595 | const u8 *mac_addr |
| 3596 | ) |
| 3597 | #endif |
| 3598 | { |
| 3599 | int status = 0; |
| 3600 | |
| 3601 | //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] | 3602 | //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] | 3603 | //it is observed that this is invalidating peer |
| 3604 | //key index whenever re-key is done. This is affecting data link. |
| 3605 | //It should be ok to ignore del_key. |
| 3606 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3607 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3608 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3609 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3610 | tCsrRoamSetKey setKey; |
| 3611 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3612 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3613 | ENTER(); |
| 3614 | |
| 3615 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3616 | __func__,pAdapter->device_mode); |
| 3617 | |
| 3618 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3619 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3620 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3621 | key_index); |
| 3622 | |
| 3623 | return -EINVAL; |
| 3624 | } |
| 3625 | |
| 3626 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3627 | setKey.keyId = key_index; |
| 3628 | |
| 3629 | if (mac_addr) |
| 3630 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3631 | else |
| 3632 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3633 | |
| 3634 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3635 | |
| 3636 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3637 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3638 | ) |
| 3639 | { |
| 3640 | |
| 3641 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3642 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3643 | if( pHostapdState->bssState == BSS_START) |
| 3644 | { |
| 3645 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3646 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3647 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3648 | { |
| 3649 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3650 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3651 | __LINE__, status ); |
| 3652 | } |
| 3653 | } |
| 3654 | } |
| 3655 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3656 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3657 | ) |
| 3658 | { |
| 3659 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3660 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3661 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3662 | |
| 3663 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3664 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3665 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3666 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3667 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3668 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3669 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3670 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3671 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3672 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3673 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3674 | if ( 0 != status ) |
| 3675 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3676 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3677 | "%s: sme_RoamSetKey failure, returned %d", |
| 3678 | __func__, status); |
| 3679 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3680 | return -EINVAL; |
| 3681 | } |
| 3682 | } |
| 3683 | } |
| 3684 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3685 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3686 | return status; |
| 3687 | } |
| 3688 | |
| 3689 | /* |
| 3690 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3691 | * This function is used to set the default tx key index |
| 3692 | */ |
| 3693 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3694 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3695 | struct net_device *ndev, |
| 3696 | u8 key_index, |
| 3697 | bool unicast, bool multicast) |
| 3698 | #else |
| 3699 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3700 | struct net_device *ndev, |
| 3701 | u8 key_index) |
| 3702 | #endif |
| 3703 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3704 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3705 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3706 | int status = 0; |
| 3707 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3708 | |
| 3709 | ENTER(); |
| 3710 | |
| 3711 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3712 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3713 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3714 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3715 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3716 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3717 | key_index); |
| 3718 | |
| 3719 | return -EINVAL; |
| 3720 | } |
| 3721 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3722 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 3723 | { |
| 3724 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3725 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3726 | return -EAGAIN; |
| 3727 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3728 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3729 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3730 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3731 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3732 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3733 | if ( (key_index != pWextState->roamProfile.Keys.defaultIndex) && |
| 3734 | (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3735 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3736 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3737 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3738 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3739 | { |
| 3740 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3741 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3742 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3743 | tCsrRoamSetKey setKey; |
| 3744 | v_U32_t roamId= 0xFF; |
| 3745 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3746 | |
| 3747 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3748 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3749 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3750 | Keys->defaultIndex = (u8)key_index; |
| 3751 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3752 | setKey.keyId = key_index; |
| 3753 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3754 | |
| 3755 | vos_mem_copy(&setKey.Key[0], |
| 3756 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3757 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3758 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3759 | setKey.keyDirection = eSIR_TX_ONLY; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3760 | |
| 3761 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3762 | &pHddStaCtx->conn_info.bssId[0], |
| 3763 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3764 | |
| 3765 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3766 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3768 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3769 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3770 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3771 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3772 | if ( 0 != status ) |
| 3773 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3774 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3775 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3776 | status); |
| 3777 | return -EINVAL; |
| 3778 | } |
| 3779 | } |
| 3780 | } |
| 3781 | |
| 3782 | /* In SoftAp mode setting key direction for default mode */ |
| 3783 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3784 | { |
| 3785 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3786 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3787 | (eCSR_ENCRYPT_TYPE_AES != |
| 3788 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3789 | ) |
| 3790 | { |
| 3791 | /* Saving key direction for default key index to TX default */ |
| 3792 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3793 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3794 | } |
| 3795 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3796 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3797 | return status; |
| 3798 | } |
| 3799 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3800 | /* |
| 3801 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3802 | * This function is used to inform the BSS details to nl80211 interface. |
| 3803 | */ |
| 3804 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3805 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3806 | { |
| 3807 | struct net_device *dev = pAdapter->dev; |
| 3808 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3809 | struct wiphy *wiphy = wdev->wiphy; |
| 3810 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3811 | int chan_no; |
| 3812 | int ie_length; |
| 3813 | const char *ie; |
| 3814 | unsigned int freq; |
| 3815 | struct ieee80211_channel *chan; |
| 3816 | int rssi = 0; |
| 3817 | struct cfg80211_bss *bss = NULL; |
| 3818 | |
| 3819 | ENTER(); |
| 3820 | |
| 3821 | if( NULL == pBssDesc ) |
| 3822 | { |
| 3823 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3824 | return bss; |
| 3825 | } |
| 3826 | |
| 3827 | chan_no = pBssDesc->channelId; |
| 3828 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3829 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3830 | |
| 3831 | if( NULL == ie ) |
| 3832 | { |
| 3833 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3834 | return bss; |
| 3835 | } |
| 3836 | |
| 3837 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3838 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3839 | { |
| 3840 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3841 | } |
| 3842 | else |
| 3843 | { |
| 3844 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3845 | } |
| 3846 | #else |
| 3847 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3848 | #endif |
| 3849 | |
| 3850 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3851 | |
| 3852 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3853 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3854 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3855 | if (bss == NULL) |
| 3856 | { |
| 3857 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3858 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3859 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3860 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3861 | pBssDesc->capabilityInfo, |
| 3862 | pBssDesc->beaconInterval, ie, ie_length, |
| 3863 | rssi, GFP_KERNEL )); |
| 3864 | } |
| 3865 | else |
| 3866 | { |
| 3867 | return bss; |
| 3868 | } |
| 3869 | } |
| 3870 | |
| 3871 | |
| 3872 | |
| 3873 | /* |
| 3874 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3875 | * This function is used to inform the BSS details to nl80211 interface. |
| 3876 | */ |
| 3877 | struct cfg80211_bss* |
| 3878 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3879 | tSirBssDescription *bss_desc |
| 3880 | ) |
| 3881 | { |
| 3882 | /* |
| 3883 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3884 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3885 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3886 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3887 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3888 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3889 | cfg80211_inform_bss_frame. |
| 3890 | */ |
| 3891 | struct net_device *dev = pAdapter->dev; |
| 3892 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3893 | struct wiphy *wiphy = wdev->wiphy; |
| 3894 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3895 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3896 | qcom_ie_age *qie_age = NULL; |
| 3897 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3898 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3899 | 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] | 3900 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3901 | const char *ie = |
| 3902 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3903 | unsigned int freq; |
| 3904 | struct ieee80211_channel *chan; |
| 3905 | struct ieee80211_mgmt *mgmt = |
| 3906 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 3907 | struct cfg80211_bss *bss_status = NULL; |
| 3908 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 3909 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3910 | #ifdef WLAN_OPEN_SOURCE |
| 3911 | struct timespec ts; |
| 3912 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3913 | |
| 3914 | ENTER(); |
| 3915 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 3916 | if (!mgmt) |
| 3917 | return NULL; |
| 3918 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3919 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3920 | |
| 3921 | #ifdef WLAN_OPEN_SOURCE |
| 3922 | /* Android does not want the timestamp from the frame. |
| 3923 | Instead it wants a monotonic increasing value */ |
| 3924 | get_monotonic_boottime(&ts); |
| 3925 | mgmt->u.probe_resp.timestamp = |
| 3926 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 3927 | #else |
| 3928 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3929 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 3930 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3931 | |
| 3932 | #endif |
| 3933 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3934 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 3935 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3936 | |
| 3937 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3938 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 3939 | /* Assuming this is the last IE, copy at the end */ |
| 3940 | ie_length -=sizeof(qcom_ie_age); |
| 3941 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 3942 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 3943 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 3944 | qie_age->oui_1 = QCOM_OUI1; |
| 3945 | qie_age->oui_2 = QCOM_OUI2; |
| 3946 | qie_age->oui_3 = QCOM_OUI3; |
| 3947 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 3948 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 3949 | #endif |
| 3950 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3951 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
| 3952 | |
| 3953 | mgmt->frame_control |= |
| 3954 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 3955 | |
| 3956 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3957 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3958 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 3959 | { |
| 3960 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3961 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3962 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3963 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 3964 | |
| 3965 | { |
| 3966 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3967 | } |
| 3968 | else |
| 3969 | { |
| 3970 | kfree(mgmt); |
| 3971 | return NULL; |
| 3972 | } |
| 3973 | #else |
| 3974 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3975 | #endif |
| 3976 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3977 | /*when the band is changed on the fly using the GUI, three things are done |
| 3978 | * 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) |
| 3979 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 3980 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 3981 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 3982 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 3983 | * 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 |
| 3984 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 3985 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 3986 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 3987 | * So drop the bss and continue to next bss. |
| 3988 | */ |
| 3989 | if(chan == NULL) |
| 3990 | { |
| 3991 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 3992 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3993 | return NULL; |
| 3994 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3995 | /*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] | 3996 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3997 | * */ |
| 3998 | if (( eConnectionState_Associated == |
| 3999 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4000 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4001 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4002 | WNI_CFG_BSSID_LEN))) |
| 4003 | { |
| 4004 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4005 | rssi = (pAdapter->rssi * 100); |
| 4006 | } |
| 4007 | else |
| 4008 | { |
| 4009 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4010 | } |
| 4011 | |
| 4012 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4013 | frame_len, rssi, GFP_KERNEL); |
| 4014 | kfree(mgmt); |
| 4015 | return bss_status; |
| 4016 | } |
| 4017 | |
| 4018 | /* |
| 4019 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4020 | * This function is used to update the BSS data base of CFG8011 |
| 4021 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4022 | 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] | 4023 | tCsrRoamInfo *pRoamInfo |
| 4024 | ) |
| 4025 | { |
| 4026 | tCsrRoamConnectedProfile roamProfile; |
| 4027 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4028 | struct cfg80211_bss *bss = NULL; |
| 4029 | |
| 4030 | ENTER(); |
| 4031 | |
| 4032 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4033 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4034 | |
| 4035 | if (NULL != roamProfile.pBssDesc) |
| 4036 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4037 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4038 | &roamProfile); |
| 4039 | |
| 4040 | if (NULL == bss) |
| 4041 | { |
| 4042 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4043 | __func__); |
| 4044 | } |
| 4045 | |
| 4046 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4047 | } |
| 4048 | else |
| 4049 | { |
| 4050 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4051 | __func__); |
| 4052 | } |
| 4053 | return bss; |
| 4054 | } |
| 4055 | |
| 4056 | /* |
| 4057 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4058 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4059 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4060 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4061 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4062 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4063 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4064 | tCsrScanResultInfo *pScanResult; |
| 4065 | eHalStatus status = 0; |
| 4066 | tScanResultHandle pResult; |
| 4067 | struct cfg80211_bss *bss_status = NULL; |
| 4068 | |
| 4069 | ENTER(); |
| 4070 | |
| 4071 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4072 | { |
| 4073 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4074 | return -EAGAIN; |
| 4075 | } |
| 4076 | |
| 4077 | /* |
| 4078 | * start getting scan results and populate cgf80211 BSS database |
| 4079 | */ |
| 4080 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4081 | |
| 4082 | /* no scan results */ |
| 4083 | if (NULL == pResult) |
| 4084 | { |
| 4085 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 4086 | return status; |
| 4087 | } |
| 4088 | |
| 4089 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4090 | |
| 4091 | while (pScanResult) |
| 4092 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4093 | /* |
| 4094 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4095 | * entry already exists in bss data base of cfg80211 for that |
| 4096 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4097 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4098 | * mgmt packet as input. As of now there is no possibility to get |
| 4099 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4100 | * ieee80211_mgmt(probe response) and passing to c |
| 4101 | * fg80211_inform_bss_frame. |
| 4102 | * */ |
| 4103 | |
| 4104 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4105 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4106 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4107 | |
| 4108 | if (NULL == bss_status) |
| 4109 | { |
| 4110 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4111 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 4112 | } |
| 4113 | else |
| 4114 | { |
| 4115 | cfg80211_put_bss(bss_status); |
| 4116 | } |
| 4117 | |
| 4118 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4119 | } |
| 4120 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4121 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4122 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4123 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4124 | } |
| 4125 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4126 | void |
| 4127 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4128 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4129 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4130 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4131 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 4132 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4133 | } /****** end hddPrintMacAddr() ******/ |
| 4134 | |
| 4135 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4136 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4137 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4138 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4139 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4140 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4141 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4142 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4143 | } /****** end hddPrintPmkId() ******/ |
| 4144 | |
| 4145 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4146 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4147 | |
| 4148 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4149 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4150 | |
| 4151 | #define dump_bssid(bssid) \ |
| 4152 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4153 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4154 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 4155 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4156 | } |
| 4157 | |
| 4158 | #define dump_pmkid(pMac, pmkid) \ |
| 4159 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4160 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4161 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4162 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4163 | } |
| 4164 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4165 | #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] | 4166 | /* |
| 4167 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4168 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4169 | */ |
| 4170 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4171 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4172 | int index, bool preauth ) |
| 4173 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4174 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4175 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4176 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4177 | |
| 4178 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4179 | 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] | 4180 | |
| 4181 | if( NULL == pRoamInfo ) |
| 4182 | { |
| 4183 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4184 | return -EINVAL; |
| 4185 | } |
| 4186 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4187 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4188 | { |
| 4189 | dump_bssid(pRoamInfo->bssid); |
| 4190 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4191 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4192 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4193 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4194 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4195 | } |
| 4196 | #endif //FEATURE_WLAN_LFR |
| 4197 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4198 | /* |
| 4199 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4200 | * scanning callback function, called after finishing scan |
| 4201 | * |
| 4202 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4203 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4204 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4205 | { |
| 4206 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4207 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4208 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4209 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4210 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4211 | struct cfg80211_scan_request *req = NULL; |
| 4212 | int ret = 0; |
| 4213 | |
| 4214 | ENTER(); |
| 4215 | |
| 4216 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4217 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4218 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4219 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4220 | |
| 4221 | //Block on scan req completion variable. Can't wait forever though. |
| 4222 | ret = wait_for_completion_interruptible_timeout( |
| 4223 | &pScanInfo->scan_req_completion_event, |
| 4224 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4225 | if (!ret) |
| 4226 | { |
| 4227 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4228 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4229 | } |
| 4230 | |
| 4231 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4232 | { |
| 4233 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4234 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4235 | } |
| 4236 | |
| 4237 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4238 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4239 | { |
| 4240 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4241 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4242 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4243 | (int) scanId); |
| 4244 | } |
| 4245 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4246 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4247 | pAdapter); |
| 4248 | |
| 4249 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4250 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4251 | |
| 4252 | |
| 4253 | /* If any client wait scan result through WEXT |
| 4254 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4255 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4256 | { |
| 4257 | /* The other scan request waiting for current scan finish |
| 4258 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4259 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4260 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4261 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4262 | } |
| 4263 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4264 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4265 | { |
| 4266 | struct net_device *dev = pAdapter->dev; |
| 4267 | union iwreq_data wrqu; |
| 4268 | int we_event; |
| 4269 | char *msg; |
| 4270 | |
| 4271 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4272 | we_event = SIOCGIWSCAN; |
| 4273 | msg = NULL; |
| 4274 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4275 | } |
| 4276 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4277 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4278 | |
| 4279 | /* Get the Scan Req */ |
| 4280 | req = pAdapter->request; |
| 4281 | |
| 4282 | if (!req) |
| 4283 | { |
| 4284 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4285 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4286 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4287 | } |
| 4288 | |
| 4289 | /* |
| 4290 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4291 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4292 | req->n_ssids = 0; |
| 4293 | req->n_channels = 0; |
| 4294 | req->ie = 0; |
| 4295 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4296 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4297 | /* Scan is no longer pending */ |
| 4298 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4299 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4300 | /* |
| 4301 | * cfg80211_scan_done informing NL80211 about completion |
| 4302 | * of scanning |
| 4303 | */ |
| 4304 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4305 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4306 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4307 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4308 | /* release the wake lock at the end of the scan*/ |
| 4309 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4310 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4311 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4312 | * immediatly after the driver gets connect request(i.e after scan) |
| 4313 | * from supplicant, this result in app's is suspending and not able |
| 4314 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4315 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4316 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4317 | #ifdef FEATURE_WLAN_TDLS |
| 4318 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4319 | #endif |
| 4320 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4321 | EXIT(); |
| 4322 | return 0; |
| 4323 | } |
| 4324 | |
| 4325 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4326 | * FUNCTION: hdd_isScanAllowed |
| 4327 | * Go through each adapter and check if scan allowed |
| 4328 | * |
| 4329 | */ |
| 4330 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4331 | { |
| 4332 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4333 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4334 | hdd_adapter_t *pAdapter = NULL; |
| 4335 | VOS_STATUS status = 0; |
| 4336 | v_U8_t staId = 0; |
| 4337 | v_U8_t *staMac = NULL; |
| 4338 | |
| 4339 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4340 | |
| 4341 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4342 | { |
| 4343 | pAdapter = pAdapterNode->pAdapter; |
| 4344 | |
| 4345 | if( pAdapter ) |
| 4346 | { |
| 4347 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4348 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4349 | __func__, pAdapter->device_mode); |
| 4350 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4351 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4352 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4353 | { |
| 4354 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4355 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4356 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4357 | { |
| 4358 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4359 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4360 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4361 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4362 | staMac[0], staMac[1], staMac[2], |
| 4363 | staMac[3], staMac[4], staMac[5]); |
| 4364 | return VOS_FALSE; |
| 4365 | } |
| 4366 | } |
| 4367 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4368 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4369 | { |
| 4370 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4371 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4372 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4373 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4374 | { |
| 4375 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4376 | |
| 4377 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4378 | "%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] | 4379 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4380 | staMac[0], staMac[1], staMac[2], |
| 4381 | staMac[3], staMac[4], staMac[5]); |
| 4382 | return VOS_FALSE; |
| 4383 | } |
| 4384 | } |
| 4385 | } |
| 4386 | } |
| 4387 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4388 | pAdapterNode = pNext; |
| 4389 | } |
| 4390 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4391 | "%s: Scan allowed", __func__); |
| 4392 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4393 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4394 | |
| 4395 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4396 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4397 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4398 | * later, scan dump command can be used to recieve scan results |
| 4399 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4400 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4401 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4402 | struct net_device *dev, |
| 4403 | #endif |
| 4404 | struct cfg80211_scan_request *request) |
| 4405 | { |
| 4406 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4407 | struct net_device *dev = request->wdev->netdev; |
| 4408 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4409 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4410 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4411 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4412 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 4413 | tCsrScanRequest scanRequest; |
| 4414 | tANI_U8 *channelList = NULL, i; |
| 4415 | v_U32_t scanId = 0; |
| 4416 | int status = 0; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4417 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4418 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4419 | |
| 4420 | ENTER(); |
| 4421 | |
| 4422 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4423 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4424 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4425 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4426 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4427 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4428 | { |
| 4429 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4430 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4431 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4432 | return -EBUSY; |
| 4433 | } |
| 4434 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4435 | #ifdef WLAN_BTAMP_FEATURE |
| 4436 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4437 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4438 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4439 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4440 | "%s: No scanning when AMP is on", __func__); |
| 4441 | return -EOPNOTSUPP; |
| 4442 | } |
| 4443 | #endif |
| 4444 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4445 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4446 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4447 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4448 | "%s: Not scanning on device_mode = %d", |
| 4449 | __func__, pAdapter->device_mode); |
| 4450 | return -EOPNOTSUPP; |
| 4451 | } |
| 4452 | |
| 4453 | if (TRUE == pScanInfo->mScanPending) |
| 4454 | { |
| 4455 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4456 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4457 | } |
| 4458 | |
| 4459 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4460 | { |
| 4461 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4462 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 4463 | return -EAGAIN; |
| 4464 | } |
| 4465 | |
Mohit Khanna | 6c52bbf | 2012-09-11 15:10:12 -0700 | [diff] [blame] | 4466 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLoadUnloadInProgress) |
| 4467 | { |
| 4468 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4469 | "%s:Unloading/Loading in Progress. Ignore!!!", __func__); |
| 4470 | return -EAGAIN; |
| 4471 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4472 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4473 | //Channel and action frame is pending |
| 4474 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4475 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4476 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4477 | { |
| 4478 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4479 | return -EBUSY; |
| 4480 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4481 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4482 | /* if tdls disagree scan right now, return immediately. |
| 4483 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4484 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4485 | */ |
| 4486 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4487 | wiphy, |
| 4488 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4489 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4490 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4491 | request); |
| 4492 | if(status <= 0) |
| 4493 | { |
| 4494 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4495 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4496 | } |
| 4497 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4498 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4499 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4500 | { |
| 4501 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4502 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4503 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4504 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4505 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4506 | { |
| 4507 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4508 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4509 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4510 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4511 | } |
| 4512 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4513 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4514 | /* Check if scan is allowed at this point of time. |
| 4515 | */ |
| 4516 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4517 | { |
| 4518 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4519 | return -EBUSY; |
| 4520 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4522 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4523 | |
| 4524 | if (NULL != request) |
| 4525 | { |
| 4526 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4527 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4528 | |
| 4529 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4530 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4531 | * is not aging out the scan results. |
| 4532 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4533 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4534 | { |
| 4535 | request->n_ssids = 0; |
| 4536 | } |
| 4537 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4538 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4539 | { |
| 4540 | tCsrSSIDInfo *SsidInfo; |
| 4541 | int j; |
| 4542 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4543 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4544 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4545 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4546 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4547 | |
| 4548 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4549 | { |
| 4550 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4551 | "memory alloc failed SSIDInfo buffer"); |
| 4552 | return -ENOMEM; |
| 4553 | } |
| 4554 | |
| 4555 | /* copy all the ssid's and their length */ |
| 4556 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4557 | { |
| 4558 | /* get the ssid length */ |
| 4559 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4560 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4561 | SsidInfo->SSID.length); |
| 4562 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4563 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4564 | j, SsidInfo->SSID.ssId); |
| 4565 | } |
| 4566 | /* set the scan type to active */ |
| 4567 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4568 | } |
| 4569 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4570 | { |
| 4571 | /* set the scan type to active */ |
| 4572 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4573 | } |
| 4574 | else |
| 4575 | { |
| 4576 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4577 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4578 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4579 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4580 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4581 | } |
| 4582 | else |
| 4583 | { |
| 4584 | /* set the scan type to active */ |
| 4585 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4586 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4587 | |
| 4588 | /* set min and max channel time to zero */ |
| 4589 | scanRequest.minChnTime = 0; |
| 4590 | scanRequest.maxChnTime = 0; |
| 4591 | } |
| 4592 | |
| 4593 | /* set BSSType to default type */ |
| 4594 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4595 | |
| 4596 | /*TODO: scan the requested channels only*/ |
| 4597 | |
| 4598 | /*Right now scanning all the channels */ |
| 4599 | if( request ) |
| 4600 | { |
| 4601 | if( request->n_channels ) |
| 4602 | { |
| 4603 | channelList = vos_mem_malloc( request->n_channels ); |
| 4604 | if( NULL == channelList ) |
| 4605 | { |
| 4606 | status = -ENOMEM; |
| 4607 | goto free_mem; |
| 4608 | } |
| 4609 | |
| 4610 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4611 | channelList[i] = request->channels[i]->hw_value; |
| 4612 | } |
| 4613 | |
| 4614 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4615 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4616 | |
| 4617 | /* set requestType to full scan */ |
| 4618 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4619 | |
| 4620 | /* 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] | 4621 | * 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] | 4622 | * 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] | 4623 | */ |
| 4624 | |
| 4625 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4626 | * and in that case driver shoudnt flush scan results. If |
| 4627 | * driver flushes the scan results here and unfortunately if |
| 4628 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4629 | * fails which is not desired |
| 4630 | */ |
| 4631 | |
| 4632 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4633 | { |
| 4634 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4635 | pAdapter->sessionId ); |
| 4636 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4637 | |
| 4638 | if( request->ie_len ) |
| 4639 | { |
| 4640 | /* save this for future association (join requires this) */ |
| 4641 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4642 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4643 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4644 | |
| 4645 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4646 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4647 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4648 | ) |
| 4649 | { |
| 4650 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4651 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4652 | } |
| 4653 | |
| 4654 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4655 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4656 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4657 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4658 | request->ie_len); |
| 4659 | if (pP2pIe != NULL) |
| 4660 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4661 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4662 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4663 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4664 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4665 | { |
| 4666 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4667 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4668 | "Go nego completed to Connection is started"); |
| 4669 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4670 | "for 8way Handshake"); |
| 4671 | } |
| 4672 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4673 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4674 | { |
| 4675 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4676 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4677 | "Disconnected state to Connection is started"); |
| 4678 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4679 | "for 4way Handshake"); |
| 4680 | } |
| 4681 | #endif |
| 4682 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4683 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4684 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4685 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4686 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4687 | "%s: This is a P2P Search", __func__); |
| 4688 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4689 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4690 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4691 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4692 | /* set requestType to P2P Discovery */ |
| 4693 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4694 | } |
| 4695 | |
| 4696 | /* |
| 4697 | Skip Dfs Channel in case of P2P Search |
| 4698 | if it is set in ini file |
| 4699 | */ |
| 4700 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4701 | { |
| 4702 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4703 | } |
| 4704 | else |
| 4705 | { |
| 4706 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4707 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4708 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4709 | } |
| 4710 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4711 | } |
| 4712 | } |
| 4713 | |
| 4714 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4715 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4716 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4717 | * address the following issues. |
| 4718 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4719 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4720 | * for long time, this result in apps running at full power for long time. |
| 4721 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4722 | * be stuck in full power because of resume BMPS |
| 4723 | */ |
| 4724 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4725 | |
| 4726 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4727 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4728 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4729 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4730 | if (eHAL_STATUS_SUCCESS != status) |
| 4731 | { |
| 4732 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4733 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4734 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4735 | if(eHAL_STATUS_RESOURCES == status) |
| 4736 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4737 | 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] | 4738 | status = -EBUSY; |
| 4739 | } else { |
| 4740 | status = -EIO; |
| 4741 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4742 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4743 | goto free_mem; |
| 4744 | } |
| 4745 | |
| 4746 | pScanInfo->mScanPending = TRUE; |
| 4747 | pAdapter->request = request; |
| 4748 | pScanInfo->scanId = scanId; |
| 4749 | |
| 4750 | complete(&pScanInfo->scan_req_completion_event); |
| 4751 | |
| 4752 | free_mem: |
| 4753 | if( scanRequest.SSIDs.SSIDList ) |
| 4754 | { |
| 4755 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4756 | } |
| 4757 | |
| 4758 | if( channelList ) |
| 4759 | vos_mem_free( channelList ); |
| 4760 | |
| 4761 | EXIT(); |
| 4762 | |
| 4763 | return status; |
| 4764 | } |
| 4765 | |
| 4766 | /* |
| 4767 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4768 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4769 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4770 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4771 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4772 | { |
| 4773 | int status = 0; |
| 4774 | hdd_wext_state_t *pWextState; |
| 4775 | v_U32_t roamId; |
| 4776 | tCsrRoamProfile *pRoamProfile; |
| 4777 | eMib_dot11DesiredBssType connectedBssType; |
| 4778 | eCsrAuthType RSNAuthType; |
| 4779 | |
| 4780 | ENTER(); |
| 4781 | |
| 4782 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4783 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4784 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4785 | { |
| 4786 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4787 | return -EINVAL; |
| 4788 | } |
| 4789 | |
| 4790 | pRoamProfile = &pWextState->roamProfile; |
| 4791 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4792 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4793 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4794 | int ret = 0; |
| 4795 | hdd_station_ctx_t *pHddStaCtx; |
| 4796 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4797 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4798 | |
| 4799 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4800 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4801 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4802 | { |
| 4803 | /* Issue disconnect to CSR */ |
| 4804 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4805 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4806 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4807 | pAdapter->sessionId, |
| 4808 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4809 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4810 | ret = wait_for_completion_interruptible_timeout( |
| 4811 | &pAdapter->disconnect_comp_var, |
| 4812 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4813 | if (0 == ret) |
| 4814 | { |
| 4815 | VOS_ASSERT(0); |
| 4816 | } |
| 4817 | } |
| 4818 | } |
| 4819 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4820 | { |
| 4821 | ret = wait_for_completion_interruptible_timeout( |
| 4822 | &pAdapter->disconnect_comp_var, |
| 4823 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4824 | if (0 == ret) |
| 4825 | { |
| 4826 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4827 | } |
| 4828 | } |
| 4829 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4830 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4831 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4832 | { |
| 4833 | /*QoS not enabled in cfg file*/ |
| 4834 | pRoamProfile->uapsd_mask = 0; |
| 4835 | } |
| 4836 | else |
| 4837 | { |
| 4838 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4839 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4840 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4841 | } |
| 4842 | |
| 4843 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4844 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4845 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4846 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4847 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4848 | ssid, ssid_len); |
| 4849 | |
| 4850 | if (bssid) |
| 4851 | { |
| 4852 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4853 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4854 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4855 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4856 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4857 | case of join failure we should send valid BSSID to supplicant |
| 4858 | */ |
| 4859 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4860 | WNI_CFG_BSSID_LEN); |
| 4861 | } |
| 4862 | |
| 4863 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 4864 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4865 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4866 | /*set gen ie*/ |
| 4867 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 4868 | /*set auth*/ |
| 4869 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 4870 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4871 | else if ( (pWextState->roamProfile.AuthType.authType[0] == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4872 | eCSR_AUTH_TYPE_OPEN_SYSTEM) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4873 | && ((pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 4874 | eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) |
| 4875 | || (pWextState->roamProfile.EncryptionType.encryptionType[0] == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4876 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) |
| 4877 | ) |
| 4878 | { |
| 4879 | /*Android UI not having any option to configure the Authentication type to OPEN/SHARED; |
| 4880 | * The authentication type will be always eCSR_AUTH_TYPE_OPEN_SYSTEM when WEP is used |
| 4881 | * Use eCSR_AUTH_TYPE_AUTOSWITCH when WEP encryption used*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4882 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4883 | eCSR_AUTH_TYPE_AUTOSWITCH; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4884 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4885 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType; |
| 4886 | } |
| 4887 | #ifdef FEATURE_WLAN_WAPI |
| 4888 | if (pAdapter->wapi_info.nWapiMode) |
| 4889 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4890 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4891 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 4892 | { |
| 4893 | case WAPI_AUTH_MODE_PSK: |
| 4894 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4895 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4896 | pAdapter->wapi_info.wapiAuthMode); |
| 4897 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 4898 | break; |
| 4899 | } |
| 4900 | case WAPI_AUTH_MODE_CERT: |
| 4901 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4902 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4903 | pAdapter->wapi_info.wapiAuthMode); |
| 4904 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 4905 | break; |
| 4906 | } |
| 4907 | } // End of switch |
| 4908 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 4909 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 4910 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4911 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4912 | pRoamProfile->AuthType.numEntries = 1; |
| 4913 | pRoamProfile->EncryptionType.numEntries = 1; |
| 4914 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4915 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 4916 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4917 | } |
| 4918 | } |
| 4919 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 4920 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 4921 | /* Initializing gtkOffloadRequestParams */ |
| 4922 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4923 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4924 | { |
| 4925 | pHddStaCtx->gtkOffloadRequestParams.requested = FALSE; |
| 4926 | memset(&pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams, |
| 4927 | 0, sizeof (tSirGtkOffloadParams)); |
| 4928 | } |
| 4929 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4930 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 4931 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4932 | if( operatingChannel ) |
| 4933 | { |
| 4934 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 4935 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 4936 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 4937 | else |
| 4938 | { |
| 4939 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4940 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4941 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4942 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4943 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 4944 | * 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] | 4945 | * 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] | 4946 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4947 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 4948 | */ |
| 4949 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 4950 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 4951 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4952 | |
| 4953 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4954 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 4955 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4956 | if( (eHAL_STATUS_SUCCESS != status) && |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4957 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 4958 | |
| 4959 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4960 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 4961 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 4962 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4963 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4964 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4965 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4966 | |
| 4967 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4968 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4969 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4970 | } |
| 4971 | else |
| 4972 | { |
| 4973 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 4974 | return -EINVAL; |
| 4975 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4976 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4977 | return status; |
| 4978 | } |
| 4979 | |
| 4980 | /* |
| 4981 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 4982 | * This function is used to set the authentication type (OPEN/SHARED). |
| 4983 | * |
| 4984 | */ |
| 4985 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 4986 | enum nl80211_auth_type auth_type) |
| 4987 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4988 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4989 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4990 | |
| 4991 | ENTER(); |
| 4992 | |
| 4993 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4994 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4995 | { |
| 4996 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 4997 | case NL80211_AUTHTYPE_AUTOMATIC: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 4998 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4999 | case NL80211_AUTHTYPE_FT: |
| 5000 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5001 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5002 | "%s: set authentication type to OPEN", __func__); |
| 5003 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5004 | break; |
| 5005 | |
| 5006 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5007 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5008 | "%s: set authentication type to SHARED", __func__); |
| 5009 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5010 | break; |
| 5011 | #ifdef FEATURE_WLAN_CCX |
| 5012 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5013 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5014 | "%s: set authentication type to CCKM WPA", __func__); |
| 5015 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5016 | break; |
| 5017 | #endif |
| 5018 | |
| 5019 | |
| 5020 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5021 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5022 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5023 | auth_type); |
| 5024 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5025 | return -EINVAL; |
| 5026 | } |
| 5027 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5028 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5029 | pHddStaCtx->conn_info.authType; |
| 5030 | return 0; |
| 5031 | } |
| 5032 | |
| 5033 | /* |
| 5034 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5035 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5036 | * |
| 5037 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5038 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5039 | u32 key_mgmt |
| 5040 | ) |
| 5041 | { |
| 5042 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5043 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5044 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5045 | /*set key mgmt type*/ |
| 5046 | switch(key_mgmt) |
| 5047 | { |
| 5048 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5049 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5050 | case WLAN_AKM_SUITE_FT_PSK: |
| 5051 | #endif |
| 5052 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5053 | __func__); |
| 5054 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5055 | break; |
| 5056 | |
| 5057 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5058 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5059 | case WLAN_AKM_SUITE_FT_8021X: |
| 5060 | #endif |
| 5061 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5062 | __func__); |
| 5063 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5064 | break; |
| 5065 | #ifdef FEATURE_WLAN_CCX |
| 5066 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5067 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5068 | case WLAN_AKM_SUITE_CCKM: |
| 5069 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5070 | __func__); |
| 5071 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5072 | break; |
| 5073 | #endif |
| 5074 | |
| 5075 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5076 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5077 | __func__, key_mgmt); |
| 5078 | return -EINVAL; |
| 5079 | |
| 5080 | } |
| 5081 | return 0; |
| 5082 | } |
| 5083 | |
| 5084 | /* |
| 5085 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5086 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5087 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5088 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5089 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5090 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5091 | bool ucast |
| 5092 | ) |
| 5093 | { |
| 5094 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5095 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5096 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5097 | |
| 5098 | ENTER(); |
| 5099 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5100 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5101 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5102 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5103 | __func__, cipher); |
| 5104 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5105 | } |
| 5106 | else |
| 5107 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5108 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5110 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5111 | { |
| 5112 | case IW_AUTH_CIPHER_NONE: |
| 5113 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5114 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5115 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5116 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5117 | if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5118 | (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)) |
| 5119 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
| 5120 | else |
| 5121 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5122 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5123 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5124 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5125 | if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5126 | (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)) |
| 5127 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
| 5128 | else |
| 5129 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 5130 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5131 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5132 | case WLAN_CIPHER_SUITE_TKIP: |
| 5133 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5134 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5136 | case WLAN_CIPHER_SUITE_CCMP: |
| 5137 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5138 | break; |
| 5139 | #ifdef FEATURE_WLAN_WAPI |
| 5140 | case WLAN_CIPHER_SUITE_SMS4: |
| 5141 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5142 | break; |
| 5143 | #endif |
| 5144 | |
| 5145 | #ifdef FEATURE_WLAN_CCX |
| 5146 | case WLAN_CIPHER_SUITE_KRK: |
| 5147 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5148 | break; |
| 5149 | #endif |
| 5150 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5151 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5152 | __func__, cipher); |
| 5153 | return -EOPNOTSUPP; |
| 5154 | } |
| 5155 | } |
| 5156 | |
| 5157 | if (ucast) |
| 5158 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5159 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5160 | __func__, encryptionType); |
| 5161 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5162 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5163 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5164 | encryptionType; |
| 5165 | } |
| 5166 | else |
| 5167 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5168 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5169 | __func__, encryptionType); |
| 5170 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5171 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5172 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5173 | } |
| 5174 | |
| 5175 | return 0; |
| 5176 | } |
| 5177 | |
| 5178 | |
| 5179 | /* |
| 5180 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5181 | * This function is used to parse WPA/RSN IE's. |
| 5182 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5183 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5184 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5185 | size_t ie_len |
| 5186 | ) |
| 5187 | { |
| 5188 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5189 | u8 *genie = ie; |
| 5190 | v_U16_t remLen = ie_len; |
| 5191 | #ifdef FEATURE_WLAN_WAPI |
| 5192 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5193 | u16 *tmp; |
| 5194 | v_U16_t akmsuiteCount; |
| 5195 | int *akmlist; |
| 5196 | #endif |
| 5197 | ENTER(); |
| 5198 | |
| 5199 | /* clear previous assocAddIE */ |
| 5200 | pWextState->assocAddIE.length = 0; |
| 5201 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5202 | |
| 5203 | while (remLen >= 2) |
| 5204 | { |
| 5205 | v_U16_t eLen = 0; |
| 5206 | v_U8_t elementId; |
| 5207 | elementId = *genie++; |
| 5208 | eLen = *genie++; |
| 5209 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5210 | |
| 5211 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5212 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5213 | |
| 5214 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5215 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5216 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5217 | 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] | 5218 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5219 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5220 | "%s: Invalid WPA IE", __func__); |
| 5221 | return -EINVAL; |
| 5222 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5223 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5224 | { |
| 5225 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5226 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5227 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5228 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5229 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5230 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5231 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5232 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5233 | VOS_ASSERT(0); |
| 5234 | return -ENOMEM; |
| 5235 | } |
| 5236 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5237 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5238 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5239 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5240 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5241 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5242 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5243 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5244 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5245 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5246 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5247 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5248 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5249 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5250 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5251 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5252 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5253 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5254 | /*Consider P2P IE, only for P2P Client */ |
| 5255 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5256 | { |
| 5257 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5258 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5259 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5260 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5261 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5262 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5263 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5264 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5265 | VOS_ASSERT(0); |
| 5266 | return -ENOMEM; |
| 5267 | } |
| 5268 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5269 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5270 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5271 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5272 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5273 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5274 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5275 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5276 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5277 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5278 | /*Consider WFD IE, only for P2P Client */ |
| 5279 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5280 | { |
| 5281 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5282 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5283 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5284 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5285 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5286 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5287 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5288 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5289 | VOS_ASSERT(0); |
| 5290 | return -ENOMEM; |
| 5291 | } |
| 5292 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5293 | // WPS IE + P2P IE + WFD IE |
| 5294 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5295 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5296 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5297 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5298 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5299 | } |
| 5300 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5301 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5302 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5303 | HS20_OUI_TYPE_SIZE)) ) |
| 5304 | { |
| 5305 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5306 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5307 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5308 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5309 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5310 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5311 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5312 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5313 | VOS_ASSERT(0); |
| 5314 | return -ENOMEM; |
| 5315 | } |
| 5316 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5317 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5318 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5319 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5320 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5321 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5322 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5323 | break; |
| 5324 | case DOT11F_EID_RSN: |
| 5325 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5326 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5327 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5328 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5329 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5330 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5331 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5332 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5333 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5334 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5335 | 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] | 5336 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5337 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5338 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5339 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5340 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5341 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5342 | VOS_ASSERT(0); |
| 5343 | return -ENOMEM; |
| 5344 | } |
| 5345 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5346 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5347 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5348 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5349 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5350 | break; |
| 5351 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5352 | #ifdef FEATURE_WLAN_WAPI |
| 5353 | case WLAN_EID_WAPI: |
| 5354 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5355 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5356 | pAdapter->wapi_info.nWapiMode); |
| 5357 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5358 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5359 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5360 | tmp = tmp + 1; |
| 5361 | akmlist = (int *)(tmp); |
| 5362 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5363 | { |
| 5364 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5365 | } |
| 5366 | else |
| 5367 | { |
| 5368 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5369 | VOS_ASSERT(0); |
| 5370 | return -EINVAL; |
| 5371 | } |
| 5372 | |
| 5373 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5374 | { |
| 5375 | 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] | 5376 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5377 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5378 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5379 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5380 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5381 | 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] | 5382 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5383 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5384 | } |
| 5385 | break; |
| 5386 | #endif |
| 5387 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5388 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5390 | /* when Unknown IE is received we should break and continue |
| 5391 | * to the next IE in the buffer instead we were returning |
| 5392 | * so changing this to break */ |
| 5393 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5394 | } |
| 5395 | genie += eLen; |
| 5396 | remLen -= eLen; |
| 5397 | } |
| 5398 | EXIT(); |
| 5399 | return 0; |
| 5400 | } |
| 5401 | |
| 5402 | /* |
| 5403 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5404 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5405 | * parameters during connect operation. |
| 5406 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5407 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5408 | struct cfg80211_connect_params *req |
| 5409 | ) |
| 5410 | { |
| 5411 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5412 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5413 | ENTER(); |
| 5414 | |
| 5415 | /*set wpa version*/ |
| 5416 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5417 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5418 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5419 | { |
| 5420 | if ( (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5421 | && ( (req->ie_len) |
| 5422 | && (0 == memcmp( &req->ie[2], "\x00\x50\xf2",3) ) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5423 | // Make sure that it is including a WPA IE. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5424 | /* Currently NL is putting WPA version 1 even for open, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5425 | * since p2p ie is also put in same buffer. |
| 5426 | * */ |
| 5427 | { |
| 5428 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5429 | } |
| 5430 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5431 | { |
| 5432 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5433 | } |
| 5434 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5435 | |
| 5436 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5437 | pWextState->wpaVersion); |
| 5438 | |
| 5439 | /*set authentication type*/ |
| 5440 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5441 | |
| 5442 | if (0 > status) |
| 5443 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5444 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5445 | "%s: failed to set authentication type ", __func__); |
| 5446 | return status; |
| 5447 | } |
| 5448 | |
| 5449 | /*set key mgmt type*/ |
| 5450 | if (req->crypto.n_akm_suites) |
| 5451 | { |
| 5452 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5453 | if (0 > status) |
| 5454 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5455 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5456 | __func__); |
| 5457 | return status; |
| 5458 | } |
| 5459 | } |
| 5460 | |
| 5461 | /*set pairwise cipher type*/ |
| 5462 | if (req->crypto.n_ciphers_pairwise) |
| 5463 | { |
| 5464 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5465 | req->crypto.ciphers_pairwise[0], true); |
| 5466 | if (0 > status) |
| 5467 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5468 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5469 | "%s: failed to set unicast cipher type", __func__); |
| 5470 | return status; |
| 5471 | } |
| 5472 | } |
| 5473 | else |
| 5474 | { |
| 5475 | /*Reset previous cipher suite to none*/ |
| 5476 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5477 | if (0 > status) |
| 5478 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5479 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5480 | "%s: failed to set unicast cipher type", __func__); |
| 5481 | return status; |
| 5482 | } |
| 5483 | } |
| 5484 | |
| 5485 | /*set group cipher type*/ |
| 5486 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5487 | false); |
| 5488 | |
| 5489 | if (0 > status) |
| 5490 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5491 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5492 | __func__); |
| 5493 | return status; |
| 5494 | } |
| 5495 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5496 | #ifdef WLAN_FEATURE_11W |
| 5497 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5498 | #endif |
| 5499 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5500 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5501 | if (req->ie_len) |
| 5502 | { |
| 5503 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5504 | if ( 0 > status) |
| 5505 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5506 | 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] | 5507 | __func__); |
| 5508 | return status; |
| 5509 | } |
| 5510 | } |
| 5511 | |
| 5512 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5513 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5514 | { |
| 5515 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5516 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5517 | ) |
| 5518 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5519 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5520 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5521 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5522 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5523 | __func__); |
| 5524 | return -EOPNOTSUPP; |
| 5525 | } |
| 5526 | else |
| 5527 | { |
| 5528 | u8 key_len = req->key_len; |
| 5529 | u8 key_idx = req->key_idx; |
| 5530 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5531 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5532 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5533 | ) |
| 5534 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5535 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5536 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5537 | __func__, key_idx, key_len); |
| 5538 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5539 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5540 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5541 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5542 | (u8)key_len; |
| 5543 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5544 | } |
| 5545 | } |
| 5546 | } |
| 5547 | } |
| 5548 | |
| 5549 | return status; |
| 5550 | } |
| 5551 | |
| 5552 | /* |
| 5553 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5554 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5555 | * parameters during connect operation. |
| 5556 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5557 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5558 | struct net_device *ndev, |
| 5559 | struct cfg80211_connect_params *req |
| 5560 | ) |
| 5561 | { |
| 5562 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5563 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5564 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5565 | hdd_context_t *pHddCtx = NULL; |
| 5566 | |
| 5567 | ENTER(); |
| 5568 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5569 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5570 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5571 | |
| 5572 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5573 | { |
| 5574 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5575 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5576 | return -EAGAIN; |
| 5577 | } |
| 5578 | |
| 5579 | #ifdef WLAN_BTAMP_FEATURE |
| 5580 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5581 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5582 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5583 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5584 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5585 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5586 | } |
| 5587 | #endif |
| 5588 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5589 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5590 | |
| 5591 | if ( 0 > status) |
| 5592 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5593 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5594 | __func__); |
| 5595 | return status; |
| 5596 | } |
| 5597 | |
| 5598 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5599 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5600 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5601 | (vos_concurrent_sessions_running())) |
| 5602 | { |
| 5603 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 5604 | |
| 5605 | if (NULL != pVosContext) |
| 5606 | { |
| 5607 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 5608 | if(NULL != pHddCtx) |
| 5609 | { |
| 5610 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 5611 | } |
| 5612 | } |
| 5613 | } |
| 5614 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5615 | if ( req->channel ) |
| 5616 | { |
| 5617 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5618 | req->ssid_len, req->bssid, |
| 5619 | req->channel->hw_value); |
| 5620 | } |
| 5621 | else |
| 5622 | { |
| 5623 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5624 | req->ssid_len, req->bssid, |
| 5625 | 0); |
| 5626 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5627 | |
| 5628 | if (0 > status) |
| 5629 | { |
| 5630 | //ReEnable BMPS if disabled |
| 5631 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5632 | (NULL != pHddCtx)) |
| 5633 | { |
| 5634 | //ReEnable Bmps and Imps back |
| 5635 | hdd_enable_bmps_imps(pHddCtx); |
| 5636 | } |
| 5637 | |
| 5638 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5639 | return status; |
| 5640 | } |
| 5641 | (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE; |
| 5642 | EXIT(); |
| 5643 | return status; |
| 5644 | } |
| 5645 | |
| 5646 | |
| 5647 | /* |
| 5648 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5649 | * This function is used to issue a disconnect request to SME |
| 5650 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5651 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5652 | struct net_device *dev, |
| 5653 | u16 reason |
| 5654 | ) |
| 5655 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5656 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5657 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5658 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
| 5659 | int status = 0; |
| 5660 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5661 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5662 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5663 | tANI_U8 staIdx; |
| 5664 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5665 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5666 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5667 | |
| 5668 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5669 | __func__,pAdapter->device_mode); |
| 5670 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5671 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5672 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5673 | |
| 5674 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 5675 | { |
| 5676 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5677 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 5678 | return -EAGAIN; |
| 5679 | } |
| 5680 | if (NULL != pRoamProfile) |
| 5681 | { |
| 5682 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5683 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5684 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5685 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5686 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5687 | switch(reason) |
| 5688 | { |
| 5689 | case WLAN_REASON_MIC_FAILURE: |
| 5690 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5691 | break; |
| 5692 | |
| 5693 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5694 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5695 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5696 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5697 | break; |
| 5698 | |
| 5699 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5700 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5701 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5702 | break; |
| 5703 | |
| 5704 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5705 | default: |
| 5706 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5707 | break; |
| 5708 | } |
| 5709 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5710 | (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_TRUE; |
| 5711 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5712 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5713 | #ifdef FEATURE_WLAN_TDLS |
| 5714 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5715 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5716 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5717 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5718 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5719 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5720 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5721 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5722 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5723 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5724 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5725 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5726 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5727 | pAdapter->sessionId, |
| 5728 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5729 | } |
| 5730 | } |
| 5731 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5732 | /*issue disconnect*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5733 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5734 | pAdapter->sessionId, reasonCode); |
| 5735 | |
| 5736 | if ( 0 != status) |
| 5737 | { |
| 5738 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5739 | "%s csrRoamDisconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5740 | __func__, (int)status ); |
| 5741 | return -EINVAL; |
| 5742 | } |
| 5743 | |
| 5744 | wait_for_completion_interruptible_timeout( |
| 5745 | &pAdapter->disconnect_comp_var, |
| 5746 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5747 | |
| 5748 | |
| 5749 | /*stop tx queues*/ |
| 5750 | netif_tx_disable(dev); |
| 5751 | netif_carrier_off(dev); |
| 5752 | } |
| 5753 | } |
| 5754 | else |
| 5755 | { |
| 5756 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5757 | } |
| 5758 | |
| 5759 | return status; |
| 5760 | } |
| 5761 | |
| 5762 | /* |
| 5763 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5764 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5765 | * settings in IBSS mode. |
| 5766 | */ |
| 5767 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5768 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5769 | struct cfg80211_ibss_params *params |
| 5770 | ) |
| 5771 | { |
| 5772 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5773 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5774 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5775 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5776 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5777 | ENTER(); |
| 5778 | |
| 5779 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5780 | |
| 5781 | if (params->ie_len && ( NULL != params->ie) ) |
| 5782 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5783 | if (WLAN_EID_RSN == params->ie[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5784 | { |
| 5785 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5786 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5787 | } |
| 5788 | else |
| 5789 | { |
| 5790 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5791 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5792 | } |
| 5793 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 5794 | |
| 5795 | if (0 > status) |
| 5796 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5797 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5798 | __func__); |
| 5799 | return status; |
| 5800 | } |
| 5801 | } |
| 5802 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5803 | pWextState->roamProfile.AuthType.authType[0] = |
| 5804 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5805 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5806 | |
| 5807 | if (params->privacy) |
| 5808 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5809 | /* Security enabled IBSS, At this time there is no information available |
| 5810 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5811 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5812 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5813 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5814 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5815 | *enable privacy bit in beacons */ |
| 5816 | |
| 5817 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5818 | } |
| 5819 | |
| 5820 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5821 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 5822 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
| 5823 | |
| 5824 | return status; |
| 5825 | } |
| 5826 | |
| 5827 | /* |
| 5828 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5829 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5830 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5831 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5832 | struct net_device *dev, |
| 5833 | struct cfg80211_ibss_params *params |
| 5834 | ) |
| 5835 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5836 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5837 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5838 | tCsrRoamProfile *pRoamProfile; |
| 5839 | int status; |
| 5840 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5841 | |
| 5842 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5843 | |
| 5844 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5845 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5846 | |
| 5847 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5848 | { |
| 5849 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5850 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5851 | return -EAGAIN; |
| 5852 | } |
| 5853 | |
| 5854 | if (NULL == pWextState) |
| 5855 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5856 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | __func__); |
| 5858 | return -EIO; |
| 5859 | } |
| 5860 | |
| 5861 | pRoamProfile = &pWextState->roamProfile; |
| 5862 | |
| 5863 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 5864 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5865 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5866 | "%s Interface type is not set to IBSS \n", __func__); |
| 5867 | return -EINVAL; |
| 5868 | } |
| 5869 | |
| 5870 | /* Set Channel */ |
| 5871 | if (NULL != params->channel) |
| 5872 | { |
| 5873 | u8 channelNum; |
| 5874 | if (IEEE80211_BAND_5GHZ == params->channel->band) |
| 5875 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5876 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5877 | "%s: IBSS join is called with unsupported band %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5878 | __func__, params->channel->band); |
| 5879 | return -EOPNOTSUPP; |
| 5880 | } |
| 5881 | |
| 5882 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5883 | channelNum = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5884 | ieee80211_frequency_to_channel(params->channel->center_freq); |
| 5885 | |
| 5886 | /*TODO: use macro*/ |
| 5887 | if (14 >= channelNum) |
| 5888 | { |
| 5889 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 5890 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5891 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5892 | int indx; |
| 5893 | |
| 5894 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 5895 | validChan, &numChans)) |
| 5896 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5897 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5898 | __func__); |
| 5899 | return -EOPNOTSUPP; |
| 5900 | } |
| 5901 | |
| 5902 | for (indx = 0; indx < numChans; indx++) |
| 5903 | { |
| 5904 | if (channelNum == validChan[indx]) |
| 5905 | { |
| 5906 | break; |
| 5907 | } |
| 5908 | } |
| 5909 | if (indx >= numChans) |
| 5910 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5911 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5912 | __func__, channelNum); |
| 5913 | return -EINVAL; |
| 5914 | } |
| 5915 | /* Set the Operational Channel */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5916 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5917 | channelNum); |
| 5918 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5919 | pHddStaCtx->conn_info.operationChannel = channelNum; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5920 | pRoamProfile->ChannelInfo.ChannelList = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5921 | &pHddStaCtx->conn_info.operationChannel; |
| 5922 | } |
| 5923 | else |
| 5924 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5925 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5926 | __func__, channelNum); |
| 5927 | return -EINVAL; |
| 5928 | } |
| 5929 | } |
| 5930 | |
| 5931 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5932 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5933 | if (status < 0) |
| 5934 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5935 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5936 | __func__); |
| 5937 | return status; |
| 5938 | } |
| 5939 | |
| 5940 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5941 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5942 | params->ssid_len, params->bssid, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5943 | |
| 5944 | if (0 > status) |
| 5945 | { |
| 5946 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5947 | return status; |
| 5948 | } |
| 5949 | |
| 5950 | return 0; |
| 5951 | } |
| 5952 | |
| 5953 | /* |
| 5954 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5955 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5956 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5957 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5958 | struct net_device *dev |
| 5959 | ) |
| 5960 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5961 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5962 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5963 | tCsrRoamProfile *pRoamProfile; |
| 5964 | |
| 5965 | ENTER(); |
| 5966 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5967 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5968 | { |
| 5969 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5970 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5971 | return -EAGAIN; |
| 5972 | } |
| 5973 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5974 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5975 | if (NULL == pWextState) |
| 5976 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5977 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5978 | __func__); |
| 5979 | return -EIO; |
| 5980 | } |
| 5981 | |
| 5982 | pRoamProfile = &pWextState->roamProfile; |
| 5983 | |
| 5984 | /* Issue disconnect only if interface type is set to IBSS */ |
| 5985 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 5986 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5987 | 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] | 5988 | __func__); |
| 5989 | return -EINVAL; |
| 5990 | } |
| 5991 | |
| 5992 | /* Issue Disconnect request */ |
| 5993 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5994 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 5995 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 5996 | |
| 5997 | return 0; |
| 5998 | } |
| 5999 | |
| 6000 | /* |
| 6001 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6002 | * This function is used to set the phy parameters |
| 6003 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6004 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6005 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6006 | u32 changed) |
| 6007 | { |
| 6008 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6009 | tHalHandle hHal = pHddCtx->hHal; |
| 6010 | |
| 6011 | ENTER(); |
| 6012 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6013 | if ( pHddCtx->isLogpInProgress ) |
| 6014 | { |
| 6015 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6016 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6017 | return -EAGAIN; |
| 6018 | } |
| 6019 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6020 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6021 | { |
| 6022 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6023 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6024 | wiphy->rts_threshold; |
| 6025 | |
| 6026 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6027 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6028 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6029 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6030 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6031 | __func__, rts_threshold); |
| 6032 | return -EINVAL; |
| 6033 | } |
| 6034 | |
| 6035 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6036 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6037 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6038 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6039 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6040 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6041 | __func__, rts_threshold); |
| 6042 | return -EIO; |
| 6043 | } |
| 6044 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6045 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6046 | rts_threshold); |
| 6047 | } |
| 6048 | |
| 6049 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6050 | { |
| 6051 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6052 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6053 | wiphy->frag_threshold; |
| 6054 | |
| 6055 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6056 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6057 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6058 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6059 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6060 | frag_threshold); |
| 6061 | return -EINVAL; |
| 6062 | } |
| 6063 | |
| 6064 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6065 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6066 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6067 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6068 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6069 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6070 | __func__, frag_threshold); |
| 6071 | return -EIO; |
| 6072 | } |
| 6073 | |
| 6074 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6075 | frag_threshold); |
| 6076 | } |
| 6077 | |
| 6078 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6079 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6080 | { |
| 6081 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6082 | wiphy->retry_short : |
| 6083 | wiphy->retry_long; |
| 6084 | |
| 6085 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6086 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6087 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6088 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6089 | __func__, retry_value); |
| 6090 | return -EINVAL; |
| 6091 | } |
| 6092 | |
| 6093 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6094 | { |
| 6095 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6096 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6097 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6098 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6099 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6100 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6101 | __func__, retry_value); |
| 6102 | return -EIO; |
| 6103 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6104 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6105 | __func__, retry_value); |
| 6106 | } |
| 6107 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6108 | { |
| 6109 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6110 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6111 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6112 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6113 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6114 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6115 | __func__, retry_value); |
| 6116 | return -EIO; |
| 6117 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6118 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6119 | __func__, retry_value); |
| 6120 | } |
| 6121 | } |
| 6122 | |
| 6123 | return 0; |
| 6124 | } |
| 6125 | |
| 6126 | /* |
| 6127 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6128 | * This function is used to set the txpower |
| 6129 | */ |
| 6130 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 6131 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6132 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6133 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6134 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6135 | #endif |
| 6136 | int dbm) |
| 6137 | { |
| 6138 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6139 | tHalHandle hHal = pHddCtx->hHal; |
| 6140 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6141 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6142 | |
| 6143 | ENTER(); |
| 6144 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6145 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6146 | dbm, ccmCfgSetCallback, |
| 6147 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6148 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6149 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6150 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6151 | return -EIO; |
| 6152 | } |
| 6153 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6154 | if ( pHddCtx->isLogpInProgress ) |
| 6155 | { |
| 6156 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6157 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6158 | return -EAGAIN; |
| 6159 | } |
| 6160 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6161 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6162 | dbm); |
| 6163 | |
| 6164 | switch(type) |
| 6165 | { |
| 6166 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6167 | /* Fall through */ |
| 6168 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6169 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6170 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6171 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6172 | __func__); |
| 6173 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6174 | } |
| 6175 | break; |
| 6176 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6177 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6178 | __func__); |
| 6179 | return -EOPNOTSUPP; |
| 6180 | break; |
| 6181 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6182 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6183 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6184 | return -EIO; |
| 6185 | } |
| 6186 | |
| 6187 | return 0; |
| 6188 | } |
| 6189 | |
| 6190 | /* |
| 6191 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6192 | * This function is used to read the txpower |
| 6193 | */ |
| 6194 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) |
| 6195 | { |
| 6196 | |
| 6197 | hdd_adapter_t *pAdapter; |
| 6198 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6199 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6200 | ENTER(); |
| 6201 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6202 | if (NULL == pHddCtx) |
| 6203 | { |
| 6204 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 6205 | *dbm = 0; |
| 6206 | return -ENOENT; |
| 6207 | } |
| 6208 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6209 | if ( pHddCtx->isLogpInProgress ) |
| 6210 | { |
| 6211 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6212 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6213 | return -EAGAIN; |
| 6214 | } |
| 6215 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6216 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6217 | if (NULL == pAdapter) |
| 6218 | { |
| 6219 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6220 | return -ENOENT; |
| 6221 | } |
| 6222 | |
| 6223 | wlan_hdd_get_classAstats(pAdapter); |
| 6224 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6225 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6226 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6227 | return 0; |
| 6228 | } |
| 6229 | |
| 6230 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6231 | u8* mac, struct station_info *sinfo) |
| 6232 | { |
| 6233 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6234 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6235 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6236 | tANI_U8 rate_flags; |
| 6237 | |
| 6238 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6239 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6240 | |
| 6241 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6242 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6243 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6244 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6245 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6246 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6247 | tANI_U16 maxRate = 0; |
| 6248 | tANI_U16 myRate; |
| 6249 | tANI_U16 currentRate = 0; |
| 6250 | tANI_U8 maxSpeedMCS = 0; |
| 6251 | tANI_U8 maxMCSIdx = 0; |
| 6252 | tANI_U8 rateFlag = 1; |
| 6253 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6254 | tANI_U16 temp; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6255 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6256 | #ifdef WLAN_FEATURE_11AC |
| 6257 | tANI_U32 vht_mcs_map; |
| 6258 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6259 | #endif /* WLAN_FEATURE_11AC */ |
| 6260 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6261 | ENTER(); |
| 6262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6263 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6264 | (0 == ssidlen)) |
| 6265 | { |
| 6266 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6267 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6268 | /*To keep GUI happy*/ |
| 6269 | return 0; |
| 6270 | } |
| 6271 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6272 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6273 | { |
| 6274 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6275 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6276 | return -EAGAIN; |
| 6277 | } |
| 6278 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6279 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6280 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6281 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6282 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6283 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6284 | |
| 6285 | //convert to the UI units of 100kbps |
| 6286 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6287 | |
| 6288 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6289 | 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] | 6290 | sinfo->signal, |
| 6291 | pCfg->reportMaxLinkSpeed, |
| 6292 | myRate, |
| 6293 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6294 | (int) pCfg->linkSpeedRssiMid, |
| 6295 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6296 | (int) rate_flags, |
| 6297 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6298 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6299 | |
| 6300 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6301 | { |
| 6302 | // we do not want to necessarily report the current speed |
| 6303 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6304 | { |
| 6305 | // report the max possible speed |
| 6306 | rssidx = 0; |
| 6307 | } |
| 6308 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6309 | { |
| 6310 | // report the max possible speed with RSSI scaling |
| 6311 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6312 | { |
| 6313 | // report the max possible speed |
| 6314 | rssidx = 0; |
| 6315 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6316 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6317 | { |
| 6318 | // report middle speed |
| 6319 | rssidx = 1; |
| 6320 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6321 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6322 | { |
| 6323 | // report middle speed |
| 6324 | rssidx = 2; |
| 6325 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6326 | else |
| 6327 | { |
| 6328 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6329 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6330 | } |
| 6331 | } |
| 6332 | else |
| 6333 | { |
| 6334 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6335 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6336 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6337 | __func__, pCfg->reportMaxLinkSpeed); |
| 6338 | rssidx = 0; |
| 6339 | } |
| 6340 | |
| 6341 | maxRate = 0; |
| 6342 | |
| 6343 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6344 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6345 | OperationalRates, &ORLeng)) |
| 6346 | { |
| 6347 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6348 | /*To keep GUI happy*/ |
| 6349 | return 0; |
| 6350 | } |
| 6351 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6352 | for (i = 0; i < ORLeng; i++) |
| 6353 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6354 | 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] | 6355 | { |
| 6356 | /* Validate Rate Set */ |
| 6357 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6358 | { |
| 6359 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6360 | break; |
| 6361 | } |
| 6362 | } |
| 6363 | /* Update MAX rate */ |
| 6364 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6365 | } |
| 6366 | |
| 6367 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6368 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6369 | ExtendedRates, &ERLeng)) |
| 6370 | { |
| 6371 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6372 | /*To keep GUI happy*/ |
| 6373 | return 0; |
| 6374 | } |
| 6375 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6376 | for (i = 0; i < ERLeng; i++) |
| 6377 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6378 | 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] | 6379 | { |
| 6380 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6381 | { |
| 6382 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6383 | break; |
| 6384 | } |
| 6385 | } |
| 6386 | /* Update MAX rate */ |
| 6387 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6388 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6389 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6390 | rates or if we are always reporting max speed or if we have |
| 6391 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6392 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6393 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6394 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6395 | MCSRates, &MCSLeng)) |
| 6396 | { |
| 6397 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6398 | /*To keep GUI happy*/ |
| 6399 | return 0; |
| 6400 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6401 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6402 | #ifdef WLAN_FEATURE_11AC |
| 6403 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6404 | 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] | 6405 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6406 | 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] | 6407 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6408 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6409 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6410 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6411 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6412 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6413 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6414 | maxMCSIdx = 7; |
| 6415 | } |
| 6416 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6417 | { |
| 6418 | maxMCSIdx = 8; |
| 6419 | } |
| 6420 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6421 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6422 | //VHT20 is supporting 0~8 |
| 6423 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6424 | maxMCSIdx = 8; |
| 6425 | else |
| 6426 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6427 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6428 | |
| 6429 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6430 | { |
| 6431 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6432 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6433 | } |
| 6434 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6435 | { |
| 6436 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6437 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6438 | } |
| 6439 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6440 | { |
| 6441 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6442 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6443 | } |
| 6444 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6445 | maxSpeedMCS = 1; |
| 6446 | if (currentRate > maxRate) |
| 6447 | { |
| 6448 | maxRate = currentRate; |
| 6449 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6450 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6451 | } |
| 6452 | else |
| 6453 | #endif /* WLAN_FEATURE_11AC */ |
| 6454 | { |
| 6455 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6456 | { |
| 6457 | rateFlag |= 1; |
| 6458 | } |
| 6459 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6460 | { |
| 6461 | rateFlag |= 2; |
| 6462 | } |
| 6463 | |
| 6464 | for (i = 0; i < MCSLeng; i++) |
| 6465 | { |
| 6466 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6467 | for (j = 0; j < temp; j++) |
| 6468 | { |
| 6469 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6470 | { |
| 6471 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6472 | break; |
| 6473 | } |
| 6474 | } |
| 6475 | if ((j < temp) && (currentRate > maxRate)) |
| 6476 | { |
| 6477 | maxRate = currentRate; |
| 6478 | maxSpeedMCS = 1; |
| 6479 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6480 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6481 | } |
| 6482 | } |
| 6483 | } |
| 6484 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6485 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6486 | { |
| 6487 | maxRate = myRate; |
| 6488 | maxSpeedMCS = 1; |
| 6489 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6490 | } |
| 6491 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6492 | // 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] | 6493 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6494 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6495 | { |
| 6496 | maxRate = myRate; |
| 6497 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6498 | { |
| 6499 | maxSpeedMCS = 0; |
| 6500 | } |
| 6501 | else |
| 6502 | { |
| 6503 | maxSpeedMCS = 1; |
| 6504 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6505 | } |
| 6506 | } |
| 6507 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6508 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6509 | { |
| 6510 | sinfo->txrate.legacy = maxRate; |
| 6511 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6512 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6513 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6514 | } |
| 6515 | else |
| 6516 | { |
| 6517 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6518 | #ifdef WLAN_FEATURE_11AC |
| 6519 | sinfo->txrate.nss = 1; |
| 6520 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6521 | { |
| 6522 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6523 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6524 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6525 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6526 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6527 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6528 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6529 | } |
| 6530 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6531 | { |
| 6532 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6533 | } |
| 6534 | #endif /* WLAN_FEATURE_11AC */ |
| 6535 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6536 | { |
| 6537 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6538 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6539 | { |
| 6540 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6541 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6542 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6543 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6544 | { |
| 6545 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6546 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6547 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6548 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6549 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6550 | sinfo->txrate.mcs, |
| 6551 | sinfo->txrate.flags ); |
| 6552 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6553 | } |
| 6554 | } |
| 6555 | else |
| 6556 | { |
| 6557 | // report current rate instead of max rate |
| 6558 | |
| 6559 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6560 | { |
| 6561 | //provide to the UI in units of 100kbps |
| 6562 | sinfo->txrate.legacy = myRate; |
| 6563 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6564 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6565 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6566 | } |
| 6567 | else |
| 6568 | { |
| 6569 | //must be MCS |
| 6570 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6571 | #ifdef WLAN_FEATURE_11AC |
| 6572 | sinfo->txrate.nss = 1; |
| 6573 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6574 | { |
| 6575 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6576 | } |
| 6577 | else |
| 6578 | #endif /* WLAN_FEATURE_11AC */ |
| 6579 | { |
| 6580 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6581 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6582 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6583 | { |
| 6584 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6585 | } |
| 6586 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6587 | { |
| 6588 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6589 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6590 | #ifdef WLAN_FEATURE_11AC |
| 6591 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6592 | { |
| 6593 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6594 | } |
| 6595 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6596 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6597 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6598 | sinfo->txrate.mcs, |
| 6599 | sinfo->txrate.flags ); |
| 6600 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6601 | } |
| 6602 | } |
| 6603 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6604 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6605 | sinfo->tx_packets = |
| 6606 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6607 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6608 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6609 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6610 | |
| 6611 | sinfo->tx_retries = |
| 6612 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6613 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6614 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6615 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6616 | |
| 6617 | sinfo->tx_failed = |
| 6618 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6619 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6620 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6621 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6622 | |
| 6623 | sinfo->filled |= |
| 6624 | STATION_INFO_TX_PACKETS | |
| 6625 | STATION_INFO_TX_RETRIES | |
| 6626 | STATION_INFO_TX_FAILED; |
| 6627 | |
| 6628 | EXIT(); |
| 6629 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6630 | } |
| 6631 | |
| 6632 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 6633 | struct net_device *dev, bool mode, v_SINT_t timeout) |
| 6634 | { |
| 6635 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6636 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6637 | VOS_STATUS vos_status; |
| 6638 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6639 | ENTER(); |
| 6640 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6641 | if (NULL == pAdapter) |
| 6642 | { |
| 6643 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6644 | return -ENODEV; |
| 6645 | } |
| 6646 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6647 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6648 | if (NULL == pHddCtx) |
| 6649 | { |
| 6650 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is NULL\n", __func__); |
| 6651 | return -ENODEV; |
| 6652 | } |
| 6653 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6654 | if ( pHddCtx->isLogpInProgress ) |
| 6655 | { |
| 6656 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6657 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6658 | return -EAGAIN; |
| 6659 | } |
| 6660 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6661 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6662 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6663 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6664 | (eConnectionState_Associated == |
| 6665 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6666 | { |
| 6667 | vos_status = hdd_conf_hostarpoffload(pAdapter, TRUE); |
| 6668 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6669 | { |
| 6670 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6671 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6672 | __func__, vos_status); |
| 6673 | } |
| 6674 | } |
| 6675 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6676 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6677 | *on successful execution of the function call |
| 6678 | *we are oppositely mapped w.r.t mode in the driver |
| 6679 | **/ |
| 6680 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6681 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6682 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6683 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6684 | { |
| 6685 | return -EINVAL; |
| 6686 | } |
| 6687 | return 0; |
| 6688 | } |
| 6689 | |
| 6690 | |
| 6691 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6692 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6693 | struct net_device *netdev, |
| 6694 | u8 key_index) |
| 6695 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6696 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6697 | return 0; |
| 6698 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6699 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6700 | |
| 6701 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6702 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6703 | struct net_device *dev, |
| 6704 | struct ieee80211_txq_params *params) |
| 6705 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6706 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6707 | return 0; |
| 6708 | } |
| 6709 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6710 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6711 | struct ieee80211_txq_params *params) |
| 6712 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6713 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6714 | return 0; |
| 6715 | } |
| 6716 | #endif //LINUX_VERSION_CODE |
| 6717 | |
| 6718 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6719 | struct net_device *dev, u8 *mac) |
| 6720 | { |
| 6721 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6722 | VOS_STATUS vos_status; |
| 6723 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6724 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6725 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6726 | if ( NULL == pAdapter || NULL == pAdapter->pHddCtx) |
| 6727 | { |
| 6728 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__); |
| 6729 | return -EINVAL; |
| 6730 | } |
| 6731 | |
| 6732 | if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress) |
| 6733 | { |
| 6734 | hddLog( LOGE, |
| 6735 | "%s: Wlan Load/Unload is in progress", __func__); |
| 6736 | return -EBUSY; |
| 6737 | } |
| 6738 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6739 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6740 | { |
| 6741 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6742 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6743 | return -EAGAIN; |
| 6744 | } |
| 6745 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6746 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6747 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6748 | ) |
| 6749 | { |
| 6750 | if( NULL == mac ) |
| 6751 | { |
| 6752 | v_U16_t i; |
| 6753 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6754 | { |
| 6755 | if(pAdapter->aStaInfo[i].isUsed) |
| 6756 | { |
| 6757 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6758 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6759 | "%s: Delete STA with MAC::" |
| 6760 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6761 | __func__, |
| 6762 | macAddr[0], macAddr[1], macAddr[2], |
| 6763 | macAddr[3], macAddr[4], macAddr[5]); |
| 6764 | hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6765 | } |
| 6766 | } |
| 6767 | } |
| 6768 | else |
| 6769 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6770 | |
| 6771 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6772 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6773 | { |
| 6774 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6775 | "%s: Skip this DEL STA as this is not used::" |
| 6776 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6777 | __func__, |
| 6778 | mac[0], mac[1], mac[2], |
| 6779 | mac[3], mac[4], mac[5]); |
| 6780 | return -ENOENT; |
| 6781 | } |
| 6782 | |
| 6783 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 6784 | { |
| 6785 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6786 | "%s: Skip this DEL STA as deauth is in progress::" |
| 6787 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6788 | __func__, |
| 6789 | mac[0], mac[1], mac[2], |
| 6790 | mac[3], mac[4], mac[5]); |
| 6791 | return -ENOENT; |
| 6792 | } |
| 6793 | |
| 6794 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 6795 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6796 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6797 | "%s: Delete STA with MAC::" |
| 6798 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6799 | __func__, |
| 6800 | mac[0], mac[1], mac[2], |
| 6801 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6802 | |
| 6803 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 6804 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6805 | { |
| 6806 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 6807 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6808 | "%s: STA removal failed for ::" |
| 6809 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6810 | __func__, |
| 6811 | mac[0], mac[1], mac[2], |
| 6812 | mac[3], mac[4], mac[5]); |
| 6813 | return -ENOENT; |
| 6814 | } |
| 6815 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6816 | } |
| 6817 | } |
| 6818 | |
| 6819 | EXIT(); |
| 6820 | |
| 6821 | return 0; |
| 6822 | } |
| 6823 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6824 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 6825 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 6826 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6827 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6828 | #ifdef FEATURE_WLAN_TDLS |
| 6829 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6830 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6831 | mask = params->sta_flags_mask; |
| 6832 | |
| 6833 | set = params->sta_flags_set; |
| 6834 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6835 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 6836 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6837 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 6838 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 6839 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6840 | |
| 6841 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 6842 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6843 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6844 | } |
| 6845 | } |
| 6846 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6847 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6848 | } |
| 6849 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6850 | |
| 6851 | #ifdef FEATURE_WLAN_LFR |
| 6852 | 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] | 6853 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6854 | { |
| 6855 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 6856 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6857 | static tANI_U32 i; // HDD Local Cache index |
| 6858 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6859 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6860 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6861 | eHalStatus result; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6862 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6863 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6864 | ENTER(); |
| 6865 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6866 | // Validate pAdapter |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6867 | if ( NULL == pAdapter || NULL == pAdapter->pHddCtx) |
| 6868 | { |
| 6869 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__); |
| 6870 | return -EINVAL; |
| 6871 | } |
| 6872 | |
| 6873 | if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress) |
| 6874 | { |
| 6875 | hddLog( LOGE, |
| 6876 | "%s: Wlan Load/Unload is in progress", __func__); |
| 6877 | return -EBUSY; |
| 6878 | } |
| 6879 | |
| 6880 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6881 | { |
| 6882 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6883 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6884 | return -EAGAIN; |
| 6885 | } |
| 6886 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6887 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6888 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6889 | |
| 6890 | for (j = 0; j < i; j++) |
| 6891 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6892 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6893 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 6894 | { |
| 6895 | /* BSSID matched previous entry. Overwrite it. */ |
| 6896 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6897 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6898 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6899 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 6900 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6901 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6902 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6903 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6904 | dump_bssid(pmksa->bssid); |
| 6905 | dump_pmkid(halHandle, pmksa->pmkid); |
| 6906 | break; |
| 6907 | } |
| 6908 | } |
| 6909 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 6910 | /* Check we compared all entries,if then take the first slot now */ |
| 6911 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 6912 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6913 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6914 | { |
| 6915 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 6916 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 6917 | pmksa->bssid, ETHER_ADDR_LEN); |
| 6918 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 6919 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6920 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6921 | 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] | 6922 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6923 | dump_bssid(pmksa->bssid); |
| 6924 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6925 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6926 | // 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] | 6927 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6928 | } |
| 6929 | |
| 6930 | |
| 6931 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6932 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6933 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6934 | 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] | 6935 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6936 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6937 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 6938 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6939 | i ); |
| 6940 | return 0; |
| 6941 | } |
| 6942 | |
| 6943 | |
| 6944 | 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] | 6945 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6946 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6947 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6948 | // TODO: Implement this later. |
| 6949 | return 0; |
| 6950 | } |
| 6951 | |
| 6952 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 6953 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6954 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6955 | // TODO: Implement this later. |
| 6956 | return 0; |
| 6957 | } |
| 6958 | #endif |
| 6959 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6960 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6961 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6962 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 6963 | { |
| 6964 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6965 | hdd_station_ctx_t *pHddStaCtx; |
| 6966 | |
| 6967 | if (NULL == pAdapter) |
| 6968 | { |
| 6969 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6970 | return -ENODEV; |
| 6971 | } |
| 6972 | |
| 6973 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6974 | |
| 6975 | // Added for debug on reception of Re-assoc Req. |
| 6976 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6977 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6978 | 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] | 6979 | ftie->ie_len); |
| 6980 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 6981 | } |
| 6982 | |
| 6983 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6984 | 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] | 6985 | ftie->ie_len); |
| 6986 | #endif |
| 6987 | |
| 6988 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 6989 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6990 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6991 | ftie->ie_len); |
| 6992 | return 0; |
| 6993 | } |
| 6994 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6995 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6996 | #ifdef FEATURE_WLAN_TDLS |
| 6997 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 6998 | u8 *peer, u8 action_code, u8 dialog_token, |
| 6999 | u16 status_code, const u8 *buf, size_t len) |
| 7000 | { |
| 7001 | |
| 7002 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7003 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7004 | u8 peerMac[6]; |
| 7005 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7006 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7007 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7008 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7009 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7010 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7011 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7012 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7013 | "Invalid arguments"); |
| 7014 | return -EINVAL; |
| 7015 | } |
| 7016 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7017 | if (pHddCtx->isLogpInProgress) |
| 7018 | { |
| 7019 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7020 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7021 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7022 | return -EBUSY; |
| 7023 | } |
| 7024 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7025 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7026 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7027 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7028 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7029 | MAC_ADDRESS_STR " action %d declined.", |
| 7030 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7031 | return -ENOTSUPP; |
| 7032 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7033 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7034 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 7035 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 7036 | { |
| 7037 | /* if tdls_mode is disabled to respond to peer's request */ |
| 7038 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 7039 | { |
| 7040 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7041 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7042 | " TDLS mode is disabled. action %d declined.", |
| 7043 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7044 | |
| 7045 | return -ENOTSUPP; |
| 7046 | } |
| 7047 | } |
| 7048 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7049 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 7050 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 7051 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7052 | { |
| 7053 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7054 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7055 | " TDLS setup is ongoing. action %d declined.", |
| 7056 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7057 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7058 | } |
| 7059 | } |
| 7060 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7061 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 7062 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7063 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7064 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7065 | { |
| 7066 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 7067 | we return error code at 'add_station()'. Hence we have this |
| 7068 | check again in addtion to add_station(). |
| 7069 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7070 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7071 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7072 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7073 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7074 | " TDLS Max peer already connected. action %d declined.", |
| 7075 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7076 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7077 | } |
| 7078 | else |
| 7079 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7080 | /* maximum reached. tweak to send error code to peer and return |
| 7081 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7082 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7083 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7084 | "%s: " MAC_ADDRESS_STR |
| 7085 | " TDLS Max peer already connected send response status %d", |
| 7086 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7087 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7088 | /* fall through to send setup resp with failure status |
| 7089 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7090 | } |
| 7091 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7092 | else |
| 7093 | { |
| 7094 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7095 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7096 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7097 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7098 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7099 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 7100 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7101 | return -EPERM; |
| 7102 | } |
| 7103 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7104 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7105 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7106 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7107 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7108 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7109 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 7110 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 7111 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7112 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7113 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7114 | /*Except teardown responder will not be used so just make 0*/ |
| 7115 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7116 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7117 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7118 | |
| 7119 | hddTdlsPeer_t *pTdlsPeer; |
| 7120 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 7121 | |
| 7122 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 7123 | responder = pTdlsPeer->is_responder; |
| 7124 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7125 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7126 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7127 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 7128 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 7129 | dialog_token, status_code, len); |
| 7130 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7131 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7132 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7133 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7134 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
| 7135 | (SIR_MAC_TDLS_DIS_RSP == action_code)) |
| 7136 | { |
| 7137 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 7138 | { |
| 7139 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7140 | "%s: Sending Disc/Setup Rsp Frame.Disable BMPS", __func__); |
| 7141 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7142 | } |
| 7143 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
| 7144 | } |
| 7145 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7146 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7147 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7148 | { |
| 7149 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7150 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7151 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7152 | return -EBUSY; |
| 7153 | } |
| 7154 | |
| 7155 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7156 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7157 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7158 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7159 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7160 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7161 | if (VOS_STATUS_SUCCESS != status) |
| 7162 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7163 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7164 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7165 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7166 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7167 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7168 | } |
| 7169 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7170 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7171 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7172 | |
| 7173 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7174 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7175 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7176 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7177 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7178 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7179 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7180 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7181 | } |
| 7182 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7183 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7184 | { |
| 7185 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7186 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7187 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7188 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7189 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7190 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7191 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7192 | } |
| 7193 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7194 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7195 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7196 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7197 | |
| 7198 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7199 | error: |
| 7200 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7201 | because we already know that this transaction will be failed, |
| 7202 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7203 | to be safe, do not change the state mahine. |
| 7204 | */ |
| 7205 | if(max_sta_failed == 0 && |
| 7206 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7207 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7208 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7209 | } |
| 7210 | |
| 7211 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7212 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7213 | { |
| 7214 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7215 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7216 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7217 | const char *tdls_oper_str[]= { |
| 7218 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7219 | "NL80211_TDLS_SETUP", |
| 7220 | "NL80211_TDLS_TEARDOWN", |
| 7221 | "NL80211_TDLS_ENABLE_LINK", |
| 7222 | "NL80211_TDLS_DISABLE_LINK", |
| 7223 | "NL80211_TDLS_UNKONW_OPER"}; |
| 7224 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7225 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7226 | |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7227 | if ( NULL == pHddCtx || NULL == pHddCtx->cfg_ini || NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7228 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7229 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7230 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7231 | return -EINVAL; |
| 7232 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7233 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7234 | if (pHddCtx->isLogpInProgress) |
| 7235 | { |
| 7236 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7237 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 7238 | return -EBUSY; |
| 7239 | } |
| 7240 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7241 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7242 | |
| 7243 | if ( NULL == pTdlsPeer ) { |
| 7244 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7245 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7246 | return -EINVAL; |
| 7247 | } |
| 7248 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7249 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7250 | if((int)oper > 4) |
| 7251 | oper = 5; |
| 7252 | |
| 7253 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7254 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7255 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7256 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7257 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7258 | |
| 7259 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7260 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7261 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7262 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7263 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7264 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7265 | return -ENOTSUPP; |
| 7266 | } |
| 7267 | |
| 7268 | switch (oper) { |
| 7269 | case NL80211_TDLS_ENABLE_LINK: |
| 7270 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7271 | VOS_STATUS status; |
| 7272 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7273 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7274 | { |
| 7275 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7276 | MAC_ADDRESS_STR " failed", |
| 7277 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7278 | return -EINVAL; |
| 7279 | } |
| 7280 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7281 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7282 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7283 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7284 | /* start TDLS client registration with TL */ |
| 7285 | status = hdd_roamRegisterTDLSSTA( pAdapter, peer, pTdlsPeer->staId, pTdlsPeer->signature); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7286 | if (VOS_STATUS_SUCCESS == status) |
| 7287 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7288 | if (pTdlsPeer->is_responder == 0) |
| 7289 | { |
| 7290 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7291 | |
| 7292 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7293 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7294 | WAIT_TIME_TDLS_INITIATOR); |
| 7295 | /* suspend initiator TX until it receives direct packet from the |
| 7296 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7297 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7298 | &staId, NULL); |
| 7299 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7300 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7301 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7302 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7303 | } |
| 7304 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7305 | } |
| 7306 | break; |
| 7307 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7308 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7309 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7310 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7311 | long status; |
| 7312 | |
| 7313 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7314 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7315 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7316 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7317 | |
| 7318 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7319 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7320 | if (status <= 0) |
| 7321 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7322 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7324 | "%s: Del station failed status %ld", |
| 7325 | __func__, status); |
| 7326 | return -EPERM; |
| 7327 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7328 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7329 | } |
| 7330 | else |
| 7331 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7333 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7334 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7335 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7336 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7337 | case NL80211_TDLS_TEARDOWN: |
| 7338 | case NL80211_TDLS_SETUP: |
| 7339 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7340 | /* We don't support in-driver setup/teardown/discovery */ |
| 7341 | return -ENOTSUPP; |
| 7342 | default: |
| 7343 | return -ENOTSUPP; |
| 7344 | } |
| 7345 | return 0; |
| 7346 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7347 | |
| 7348 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7349 | struct net_device *dev, u8 *peer) |
| 7350 | { |
| 7351 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7352 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7353 | |
| 7354 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7355 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7356 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7357 | #endif |
| 7358 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7359 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7360 | /* |
| 7361 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7362 | * Callback rountine called upon receiving response for |
| 7363 | * get offload info |
| 7364 | */ |
| 7365 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7366 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7367 | { |
| 7368 | |
| 7369 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
| 7370 | |
| 7371 | ENTER(); |
| 7372 | |
| 7373 | if (NULL == pAdapter) |
| 7374 | { |
| 7375 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7376 | "%s: HDD adapter is Null", __func__); |
| 7377 | return ; |
| 7378 | } |
| 7379 | |
| 7380 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7381 | { |
| 7382 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7383 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7384 | return ; |
| 7385 | } |
| 7386 | |
| 7387 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7388 | { |
| 7389 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7390 | "%s: wlan Failed to get replay counter value", |
| 7391 | __func__); |
| 7392 | return ; |
| 7393 | } |
| 7394 | |
| 7395 | /* Update replay counter to NL */ |
| 7396 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
| 7397 | (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter, GFP_KERNEL); |
| 7398 | } |
| 7399 | |
| 7400 | /* |
| 7401 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 7402 | * This function is used to offload GTK rekeying job to the firmware. |
| 7403 | */ |
| 7404 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 7405 | struct cfg80211_gtk_rekey_data *data) |
| 7406 | { |
| 7407 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7408 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 7409 | hdd_station_ctx_t *pHddStaCtx; |
| 7410 | tHalHandle hHal; |
| 7411 | tpSirGtkOffloadParams pGtkOffloadReqParams; |
| 7412 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7413 | |
| 7414 | ENTER(); |
| 7415 | |
| 7416 | if (NULL == pAdapter) |
| 7417 | { |
| 7418 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7419 | "%s: HDD adapter is Null", __func__); |
| 7420 | return -ENODEV; |
| 7421 | } |
| 7422 | |
| 7423 | if (NULL == pHddCtx) |
| 7424 | { |
| 7425 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7426 | "%s: HDD context is Null!!!", __func__); |
| 7427 | return -ENODEV; |
| 7428 | } |
| 7429 | |
| 7430 | if (pHddCtx->isLogpInProgress) |
| 7431 | { |
| 7432 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7433 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7434 | return -EAGAIN; |
| 7435 | } |
| 7436 | |
| 7437 | if (pHddCtx->isLoadUnloadInProgress) |
| 7438 | { |
| 7439 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7440 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 7441 | return -EAGAIN; |
| 7442 | } |
| 7443 | |
| 7444 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7445 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7446 | if (NULL == hHal) |
| 7447 | { |
| 7448 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7449 | "%s: HAL context is Null!!!", __func__); |
| 7450 | return -EAGAIN; |
| 7451 | } |
| 7452 | |
| 7453 | pGtkOffloadReqParams = |
| 7454 | &pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams; |
| 7455 | |
| 7456 | pGtkOffloadReqParams->ulFlags = GTK_OFFLOAD_ENABLE; |
| 7457 | memcpy(pGtkOffloadReqParams->aKCK, data->kck, NL80211_KCK_LEN); |
| 7458 | memcpy(pGtkOffloadReqParams->aKEK, data->kek, NL80211_KEK_LEN); |
| 7459 | memcpy(pGtkOffloadReqParams->bssId, &pHddStaCtx->conn_info.bssId, |
| 7460 | WNI_CFG_BSSID_LEN); |
| 7461 | memcpy(&pGtkOffloadReqParams->ullKeyReplayCounter, &data->replay_ctr, |
| 7462 | sizeof (tANI_U64)); |
| 7463 | |
| 7464 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 7465 | { |
| 7466 | /* if wlan is suspended, enable GTK offload directly from here */ |
| 7467 | status = sme_SetGTKOffload(hHal, pGtkOffloadReqParams, |
| 7468 | pAdapter->sessionId); |
| 7469 | |
| 7470 | if (eHAL_STATUS_SUCCESS != status) |
| 7471 | { |
| 7472 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7473 | "%s: sme_SetGTKOffload failed, returned %d", |
| 7474 | __func__, status); |
| 7475 | return status; |
| 7476 | } |
| 7477 | pHddStaCtx->gtkOffloadRequestParams.requested = FALSE; |
| 7478 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7479 | "%s: sme_SetGTKOffload successfull", __func__); |
| 7480 | } |
| 7481 | else |
| 7482 | { |
| 7483 | pHddStaCtx->gtkOffloadRequestParams.requested = TRUE; |
| 7484 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7485 | "%s: wlan not suspended GTKOffload request is stored", |
| 7486 | __func__); |
| 7487 | return eHAL_STATUS_SUCCESS; |
| 7488 | } |
| 7489 | return status; |
| 7490 | } |
| 7491 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 7492 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7493 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7494 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7495 | { |
| 7496 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 7497 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 7498 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 7499 | .change_station = wlan_hdd_change_station, |
| 7500 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 7501 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 7502 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 7503 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7504 | #else |
| 7505 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 7506 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 7507 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7508 | #endif |
| 7509 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 7510 | .add_key = wlan_hdd_cfg80211_add_key, |
| 7511 | .get_key = wlan_hdd_cfg80211_get_key, |
| 7512 | .del_key = wlan_hdd_cfg80211_del_key, |
| 7513 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 7514 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7515 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 7516 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7517 | .scan = wlan_hdd_cfg80211_scan, |
| 7518 | .connect = wlan_hdd_cfg80211_connect, |
| 7519 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 7520 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 7521 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 7522 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 7523 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 7524 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7525 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 7526 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 7527 | .mgmt_tx = wlan_hdd_action, |
| 7528 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7529 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 7530 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 7531 | .set_txq_params = wlan_hdd_set_txq_params, |
| 7532 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7533 | .get_station = wlan_hdd_cfg80211_get_station, |
| 7534 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 7535 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7536 | .add_station = wlan_hdd_cfg80211_add_station, |
| 7537 | #ifdef FEATURE_WLAN_LFR |
| 7538 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 7539 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 7540 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 7541 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7542 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 7543 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 7544 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7545 | #ifdef FEATURE_WLAN_TDLS |
| 7546 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 7547 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 7548 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7549 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7550 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 7551 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7552 | }; |
| 7553 | |