Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 21 | |
| 22 | /**======================================================================== |
| 23 | |
| 24 | \file wlan_hdd_cfg80211.c |
| 25 | |
| 26 | \brief WLAN Host Device Driver implementation |
| 27 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 28 | Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 30 | Qualcomm Technologies Confidential and Proprietary. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | |
| 32 | ========================================================================*/ |
| 33 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 34 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 36 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | |
| 38 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 39 | This section contains comments describing changes made to the module. |
| 40 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | |
| 42 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 43 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | |
| 45 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 46 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 48 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 49 | |
| 50 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 51 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | ==========================================================================*/ |
| 53 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | |
| 55 | #include <linux/version.h> |
| 56 | #include <linux/module.h> |
| 57 | #include <linux/kernel.h> |
| 58 | #include <linux/init.h> |
| 59 | #include <linux/wireless.h> |
| 60 | #include <wlan_hdd_includes.h> |
| 61 | #include <net/arp.h> |
| 62 | #include <net/cfg80211.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <wlan_hdd_wowl.h> |
| 65 | #include <aniGlobal.h> |
| 66 | #include "ccmApi.h" |
| 67 | #include "sirParams.h" |
| 68 | #include "dot11f.h" |
| 69 | #include "wlan_hdd_assoc.h" |
| 70 | #include "wlan_hdd_wext.h" |
| 71 | #include "sme_Api.h" |
| 72 | #include "wlan_hdd_p2p.h" |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_hostapd.h" |
| 75 | #include "sapInternal.h" |
| 76 | #include "wlan_hdd_softap_tx_rx.h" |
| 77 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 78 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 79 | #include "wlan_hdd_power.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 80 | #ifdef WLAN_BTAMP_FEATURE |
| 81 | #include "bap_hdd_misc.h" |
| 82 | #endif |
| 83 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 84 | #ifdef FEATURE_WLAN_TDLS |
| 85 | #include "wlan_hdd_tdls.h" |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 86 | #include "wlan_hdd_wmm.h" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 87 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 88 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 89 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 90 | |
| 91 | #define g_mode_rates_size (12) |
| 92 | #define a_mode_rates_size (8) |
| 93 | #define FREQ_BASE_80211G (2407) |
| 94 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 95 | #define MAX_SCAN_SSID 9 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 96 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 97 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 98 | |
| 99 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 100 | .band = IEEE80211_BAND_2GHZ, \ |
| 101 | .center_freq = (freq), \ |
| 102 | .hw_value = (chan),\ |
| 103 | .flags = (flag), \ |
| 104 | .max_antenna_gain = 0 ,\ |
| 105 | .max_power = 30, \ |
| 106 | } |
| 107 | |
| 108 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 109 | .band = IEEE80211_BAND_5GHZ, \ |
| 110 | .center_freq = (freq), \ |
| 111 | .hw_value = (chan),\ |
| 112 | .flags = (flag), \ |
| 113 | .max_antenna_gain = 0 ,\ |
| 114 | .max_power = 30, \ |
| 115 | } |
| 116 | |
| 117 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 118 | {\ |
| 119 | .bitrate = rate, \ |
| 120 | .hw_value = rate_id, \ |
| 121 | .flags = flag, \ |
| 122 | } |
| 123 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 124 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 125 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 126 | #else |
| 127 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 128 | #endif |
| 129 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 130 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 131 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 132 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 133 | #endif |
| 134 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 135 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 136 | { |
| 137 | WLAN_CIPHER_SUITE_WEP40, |
| 138 | WLAN_CIPHER_SUITE_WEP104, |
| 139 | WLAN_CIPHER_SUITE_TKIP, |
| 140 | #ifdef FEATURE_WLAN_CCX |
| 141 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 142 | WLAN_CIPHER_SUITE_KRK, |
| 143 | WLAN_CIPHER_SUITE_CCMP, |
| 144 | #else |
| 145 | WLAN_CIPHER_SUITE_CCMP, |
| 146 | #endif |
| 147 | #ifdef FEATURE_WLAN_WAPI |
| 148 | WLAN_CIPHER_SUITE_SMS4, |
| 149 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 150 | #ifdef WLAN_FEATURE_11W |
| 151 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 152 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 156 | { |
| 157 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 158 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 159 | } |
| 160 | |
| 161 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 162 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 163 | HDD2GHZCHAN(2412, 1, 0) , |
| 164 | HDD2GHZCHAN(2417, 2, 0) , |
| 165 | HDD2GHZCHAN(2422, 3, 0) , |
| 166 | HDD2GHZCHAN(2427, 4, 0) , |
| 167 | HDD2GHZCHAN(2432, 5, 0) , |
| 168 | HDD2GHZCHAN(2437, 6, 0) , |
| 169 | HDD2GHZCHAN(2442, 7, 0) , |
| 170 | HDD2GHZCHAN(2447, 8, 0) , |
| 171 | HDD2GHZCHAN(2452, 9, 0) , |
| 172 | HDD2GHZCHAN(2457, 10, 0) , |
| 173 | HDD2GHZCHAN(2462, 11, 0) , |
| 174 | HDD2GHZCHAN(2467, 12, 0) , |
| 175 | HDD2GHZCHAN(2472, 13, 0) , |
| 176 | HDD2GHZCHAN(2484, 14, 0) , |
| 177 | }; |
| 178 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 179 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 180 | { |
| 181 | HDD2GHZCHAN(2412, 1, 0) , |
| 182 | HDD2GHZCHAN(2437, 6, 0) , |
| 183 | HDD2GHZCHAN(2462, 11, 0) , |
| 184 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 185 | |
| 186 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 187 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 188 | HDD5GHZCHAN(4920, 240, 0) , |
| 189 | HDD5GHZCHAN(4940, 244, 0) , |
| 190 | HDD5GHZCHAN(4960, 248, 0) , |
| 191 | HDD5GHZCHAN(4980, 252, 0) , |
| 192 | HDD5GHZCHAN(5040, 208, 0) , |
| 193 | HDD5GHZCHAN(5060, 212, 0) , |
| 194 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 195 | HDD5GHZCHAN(5180, 36, 0) , |
| 196 | HDD5GHZCHAN(5200, 40, 0) , |
| 197 | HDD5GHZCHAN(5220, 44, 0) , |
| 198 | HDD5GHZCHAN(5240, 48, 0) , |
| 199 | HDD5GHZCHAN(5260, 52, 0) , |
| 200 | HDD5GHZCHAN(5280, 56, 0) , |
| 201 | HDD5GHZCHAN(5300, 60, 0) , |
| 202 | HDD5GHZCHAN(5320, 64, 0) , |
| 203 | HDD5GHZCHAN(5500,100, 0) , |
| 204 | HDD5GHZCHAN(5520,104, 0) , |
| 205 | HDD5GHZCHAN(5540,108, 0) , |
| 206 | HDD5GHZCHAN(5560,112, 0) , |
| 207 | HDD5GHZCHAN(5580,116, 0) , |
| 208 | HDD5GHZCHAN(5600,120, 0) , |
| 209 | HDD5GHZCHAN(5620,124, 0) , |
| 210 | HDD5GHZCHAN(5640,128, 0) , |
| 211 | HDD5GHZCHAN(5660,132, 0) , |
| 212 | HDD5GHZCHAN(5680,136, 0) , |
| 213 | HDD5GHZCHAN(5700,140, 0) , |
| 214 | HDD5GHZCHAN(5745,149, 0) , |
| 215 | HDD5GHZCHAN(5765,153, 0) , |
| 216 | HDD5GHZCHAN(5785,157, 0) , |
| 217 | HDD5GHZCHAN(5805,161, 0) , |
| 218 | HDD5GHZCHAN(5825,165, 0) , |
| 219 | }; |
| 220 | |
| 221 | static struct ieee80211_rate g_mode_rates[] = |
| 222 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 223 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 224 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 225 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 226 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 227 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 228 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 229 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 230 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 231 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 232 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 233 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 234 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 235 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 236 | |
| 237 | static struct ieee80211_rate a_mode_rates[] = |
| 238 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 239 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 240 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 241 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 242 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 243 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 244 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 245 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 246 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 247 | }; |
| 248 | |
| 249 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 250 | { |
| 251 | .channels = hdd_channels_2_4_GHZ, |
| 252 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 253 | .band = IEEE80211_BAND_2GHZ, |
| 254 | .bitrates = g_mode_rates, |
| 255 | .n_bitrates = g_mode_rates_size, |
| 256 | .ht_cap.ht_supported = 1, |
| 257 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 258 | | IEEE80211_HT_CAP_GRN_FLD |
| 259 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 260 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 261 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 262 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 263 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 264 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 265 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 266 | }; |
| 267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 268 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 269 | { |
| 270 | .channels = hdd_social_channels_2_4_GHZ, |
| 271 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 272 | .band = IEEE80211_BAND_2GHZ, |
| 273 | .bitrates = g_mode_rates, |
| 274 | .n_bitrates = g_mode_rates_size, |
| 275 | .ht_cap.ht_supported = 1, |
| 276 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 277 | | IEEE80211_HT_CAP_GRN_FLD |
| 278 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 279 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 280 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 281 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 282 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 283 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 284 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 285 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 286 | |
| 287 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 288 | { |
| 289 | .channels = hdd_channels_5_GHZ, |
| 290 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 291 | .band = IEEE80211_BAND_5GHZ, |
| 292 | .bitrates = a_mode_rates, |
| 293 | .n_bitrates = a_mode_rates_size, |
| 294 | .ht_cap.ht_supported = 1, |
| 295 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 296 | | IEEE80211_HT_CAP_GRN_FLD |
| 297 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 298 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 299 | | IEEE80211_HT_CAP_SGI_40 |
| 300 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 301 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 302 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 303 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 304 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 305 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 306 | }; |
| 307 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 308 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 309 | TX/RX direction for each kind of interface */ |
| 310 | static const struct ieee80211_txrx_stypes |
| 311 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 312 | [NL80211_IFTYPE_STATION] = { |
| 313 | .tx = 0xffff, |
| 314 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 315 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 316 | }, |
| 317 | [NL80211_IFTYPE_AP] = { |
| 318 | .tx = 0xffff, |
| 319 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 320 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 321 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 322 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 323 | BIT(SIR_MAC_MGMT_AUTH) | |
| 324 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 325 | BIT(SIR_MAC_MGMT_ACTION), |
| 326 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 327 | [NL80211_IFTYPE_ADHOC] = { |
| 328 | .tx = 0xffff, |
| 329 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 330 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 331 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 332 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 333 | BIT(SIR_MAC_MGMT_AUTH) | |
| 334 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 335 | BIT(SIR_MAC_MGMT_ACTION), |
| 336 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 337 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 338 | .tx = 0xffff, |
| 339 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 340 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 341 | }, |
| 342 | [NL80211_IFTYPE_P2P_GO] = { |
| 343 | /* This is also same as for SoftAP */ |
| 344 | .tx = 0xffff, |
| 345 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 346 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 347 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 348 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 349 | BIT(SIR_MAC_MGMT_AUTH) | |
| 350 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 351 | BIT(SIR_MAC_MGMT_ACTION), |
| 352 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 353 | }; |
| 354 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 355 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 356 | static const struct ieee80211_iface_limit |
| 357 | wlan_hdd_iface_limit[] = { |
| 358 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 359 | /* max = 3 ; Our driver create two interfaces during driver init |
| 360 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 361 | * interface until a group is formed. In JB architecture, once the |
| 362 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 363 | * Client. |
| 364 | * When supplicant remove the group, it first issue a set interface |
| 365 | * cmd to change the mode back to Station. In JB this works fine as |
| 366 | * we advertize two station type interface during driver init. |
| 367 | * Some vendors create separate interface for P2P GO/Client, |
| 368 | * after group formation(Third one). But while group remove |
| 369 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 370 | * But as we advertized only two sta type interfaces nl80211 was |
| 371 | * returning error for the third one which was leading to failure in |
| 372 | * delete interface. Ideally while removing the group, supplicant |
| 373 | * should not try to change the 3rd interface mode to Station type. |
| 374 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 375 | * interface type to 3 |
| 376 | */ |
| 377 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 378 | .types = BIT(NL80211_IFTYPE_STATION), |
| 379 | }, |
| 380 | { |
| 381 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 382 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 383 | }, |
| 384 | { |
| 385 | .max = 1, |
| 386 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 387 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 388 | }, |
| 389 | }; |
| 390 | |
| 391 | /* By default, only single channel concurrency is allowed */ |
| 392 | static struct ieee80211_iface_combination |
| 393 | wlan_hdd_iface_combination = { |
| 394 | .limits = wlan_hdd_iface_limit, |
| 395 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 396 | /* |
| 397 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 398 | * and p2p0 interfaces during driver init |
| 399 | * Some vendors create separate interface for P2P operations. |
| 400 | * wlan0: STA interface |
| 401 | * p2p0: P2P Device interface, action frames goes |
| 402 | * through this interface. |
| 403 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 404 | * created for p2p operations(GO/CLIENT interface). |
| 405 | */ |
| 406 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 407 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 408 | .beacon_int_infra_match = false, |
| 409 | }; |
| 410 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 412 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 413 | |
| 414 | /* Data rate 100KBPS based on IE Index */ |
| 415 | struct index_data_rate_type |
| 416 | { |
| 417 | v_U8_t beacon_rate_index; |
| 418 | v_U16_t supported_rate[4]; |
| 419 | }; |
| 420 | |
| 421 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 422 | The IDX field is the rate index |
| 423 | The HI field is the rate when RSSI is strong or being ignored |
| 424 | (in this case we report actual rate) |
| 425 | The MID field is the rate when RSSI is moderate |
| 426 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 427 | The LO field is the rate when RSSI is low |
| 428 | (in this case we don't report rates, actual current rate used) |
| 429 | */ |
| 430 | static const struct |
| 431 | { |
| 432 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 433 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 434 | } supported_data_rate[] = |
| 435 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 436 | /* IDX HI HM LM LO (RSSI-based index */ |
| 437 | {2, { 10, 10, 10, 0}}, |
| 438 | {4, { 20, 20, 10, 0}}, |
| 439 | {11, { 55, 20, 10, 0}}, |
| 440 | {12, { 60, 55, 20, 0}}, |
| 441 | {18, { 90, 55, 20, 0}}, |
| 442 | {22, {110, 55, 20, 0}}, |
| 443 | {24, {120, 90, 60, 0}}, |
| 444 | {36, {180, 120, 60, 0}}, |
| 445 | {44, {220, 180, 60, 0}}, |
| 446 | {48, {240, 180, 90, 0}}, |
| 447 | {66, {330, 180, 90, 0}}, |
| 448 | {72, {360, 240, 90, 0}}, |
| 449 | {96, {480, 240, 120, 0}}, |
| 450 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 451 | }; |
| 452 | |
| 453 | /* MCS Based rate table */ |
| 454 | static struct index_data_rate_type supported_mcs_rate[] = |
| 455 | { |
| 456 | /* MCS L20 L40 S20 S40 */ |
| 457 | {0, {65, 135, 72, 150}}, |
| 458 | {1, {130, 270, 144, 300}}, |
| 459 | {2, {195, 405, 217, 450}}, |
| 460 | {3, {260, 540, 289, 600}}, |
| 461 | {4, {390, 810, 433, 900}}, |
| 462 | {5, {520, 1080, 578, 1200}}, |
| 463 | {6, {585, 1215, 650, 1350}}, |
| 464 | {7, {650, 1350, 722, 1500}} |
| 465 | }; |
| 466 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 467 | #ifdef WLAN_FEATURE_11AC |
| 468 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 469 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 470 | |
| 471 | struct index_vht_data_rate_type |
| 472 | { |
| 473 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 474 | v_U16_t supported_VHT80_rate[2]; |
| 475 | v_U16_t supported_VHT40_rate[2]; |
| 476 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 477 | }; |
| 478 | |
| 479 | typedef enum |
| 480 | { |
| 481 | DATA_RATE_11AC_MAX_MCS_7, |
| 482 | DATA_RATE_11AC_MAX_MCS_8, |
| 483 | DATA_RATE_11AC_MAX_MCS_9, |
| 484 | DATA_RATE_11AC_MAX_MCS_NA |
| 485 | } eDataRate11ACMaxMcs; |
| 486 | |
| 487 | /* MCS Based VHT rate table */ |
| 488 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 489 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 490 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 491 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 492 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 493 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 494 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 495 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 496 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 497 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 498 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 499 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 500 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 501 | }; |
| 502 | #endif /* WLAN_FEATURE_11AC */ |
| 503 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 504 | extern struct net_device_ops net_ops_struct; |
| 505 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 506 | #ifdef WLAN_NL80211_TESTMODE |
| 507 | enum wlan_hdd_tm_attr |
| 508 | { |
| 509 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 510 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 511 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 512 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 513 | /* keep last */ |
| 514 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 515 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 516 | }; |
| 517 | |
| 518 | enum wlan_hdd_tm_cmd |
| 519 | { |
| 520 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 521 | }; |
| 522 | |
| 523 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 524 | |
| 525 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 526 | { |
| 527 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 528 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 529 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 530 | }; |
| 531 | #endif /* WLAN_NL80211_TESTMODE */ |
| 532 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 533 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 534 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 535 | * This function is called by hdd_wlan_startup() |
| 536 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 537 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 538 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 539 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 540 | { |
| 541 | struct wiphy *wiphy; |
| 542 | ENTER(); |
| 543 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 544 | /* |
| 545 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 546 | */ |
| 547 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 548 | |
| 549 | if (!wiphy) |
| 550 | { |
| 551 | /* Print error and jump into err label and free the memory */ |
| 552 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 553 | return NULL; |
| 554 | } |
| 555 | |
| 556 | return wiphy; |
| 557 | } |
| 558 | |
| 559 | /* |
| 560 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 561 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 562 | * private ioctl to change the band value |
| 563 | */ |
| 564 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 565 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 566 | int i, j; |
| 567 | eNVChannelEnabledType channelEnabledState; |
| 568 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 569 | ENTER(); |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 570 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 571 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 572 | |
| 573 | if (NULL == wiphy->bands[i]) |
| 574 | { |
| 575 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 576 | __func__, i); |
| 577 | continue; |
| 578 | } |
| 579 | |
| 580 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 581 | { |
| 582 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 583 | |
| 584 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 585 | band->channels[j].hw_value); |
| 586 | |
| 587 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 588 | { |
| 589 | // Enable Social channels for P2P |
| 590 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 591 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 592 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 593 | else |
| 594 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 595 | continue; |
| 596 | } |
| 597 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 598 | { |
| 599 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 600 | continue; |
| 601 | } |
| 602 | |
| 603 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 604 | NV_CHANNEL_INVALID == channelEnabledState) |
| 605 | { |
| 606 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 607 | } |
| 608 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 609 | { |
| 610 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 611 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 612 | } |
| 613 | else |
| 614 | { |
| 615 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 616 | |IEEE80211_CHAN_RADAR); |
| 617 | } |
| 618 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 619 | } |
| 620 | return 0; |
| 621 | } |
| 622 | /* |
| 623 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 624 | * This function is called by hdd_wlan_startup() |
| 625 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 626 | * This function is used to initialize and register wiphy structure. |
| 627 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 628 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 629 | struct wiphy *wiphy, |
| 630 | hdd_config_t *pCfg |
| 631 | ) |
| 632 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 633 | int i, j; |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 634 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 635 | ENTER(); |
| 636 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 637 | /* Now bind the underlying wlan device with wiphy */ |
| 638 | set_wiphy_dev(wiphy, dev); |
| 639 | |
| 640 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 641 | if (memcmp(pHddCtx->cfg_ini->crdaDefaultCountryCode, |
| 642 | CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0) |
| 643 | { |
| 644 | wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY; |
| 645 | } |
| 646 | else |
| 647 | { |
| 648 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
| 649 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 650 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 651 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 652 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 653 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 654 | | WIPHY_FLAG_OFFCHAN_TX; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 655 | #endif |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 656 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 657 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 658 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 659 | || pCfg->isFastRoamIniFeatureEnabled |
| 660 | #endif |
| 661 | #ifdef FEATURE_WLAN_CCX |
| 662 | || pCfg->isCcxIniFeatureEnabled |
| 663 | #endif |
| 664 | ) |
| 665 | { |
| 666 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 667 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 668 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 669 | #ifdef FEATURE_WLAN_TDLS |
| 670 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 671 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 672 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 673 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 674 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 675 | wiphy->max_sched_scan_ssids = MAX_SCAN_SSID; |
| 676 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 677 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 678 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 679 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 680 | driver can still register regulatory callback and |
| 681 | it will get CRDA setting in wiphy->band[], but |
| 682 | driver need to determine what to do with both |
| 683 | regulatory settings */ |
| 684 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 685 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 686 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 687 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 688 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 689 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 690 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 691 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 692 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 693 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 694 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 695 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 696 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 697 | | BIT(NL80211_IFTYPE_AP); |
| 698 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 699 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 700 | if( pCfg->enableMCC ) |
| 701 | { |
| 702 | /* Currently, supports up to two channels */ |
| 703 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 704 | |
| 705 | if( !pCfg->allowMCCGODiffBI ) |
| 706 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 707 | |
| 708 | } |
| 709 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 710 | wiphy->n_iface_combinations = 1; |
| 711 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 712 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | /* Before registering we need to update the ht capabilitied based |
| 714 | * on ini values*/ |
| 715 | if( !pCfg->ShortGI20MhzEnable ) |
| 716 | { |
| 717 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 718 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 719 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 720 | } |
| 721 | |
| 722 | if( !pCfg->ShortGI40MhzEnable ) |
| 723 | { |
| 724 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 725 | } |
| 726 | |
| 727 | if( !pCfg->nChannelBondingMode5GHz ) |
| 728 | { |
| 729 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 730 | } |
| 731 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 732 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 733 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 734 | |
| 735 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 736 | { |
| 737 | |
| 738 | if (NULL == wiphy->bands[i]) |
| 739 | { |
| 740 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 741 | __func__, i); |
| 742 | continue; |
| 743 | } |
| 744 | |
| 745 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 746 | { |
| 747 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 748 | |
| 749 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 750 | { |
| 751 | // Enable social channels for P2P |
| 752 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 753 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 754 | else |
| 755 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 756 | continue; |
| 757 | } |
| 758 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 759 | { |
| 760 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 761 | continue; |
| 762 | } |
| 763 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 764 | } |
| 765 | /*Initialise the supported cipher suite details*/ |
| 766 | wiphy->cipher_suites = hdd_cipher_suites; |
| 767 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 768 | |
| 769 | /*signal strength in mBm (100*dBm) */ |
| 770 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 771 | |
| 772 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 773 | wiphy->max_remain_on_channel_duration = 1000; |
| 774 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 775 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 776 | EXIT(); |
| 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | /* In this function we are registering wiphy. */ |
| 781 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 782 | { |
| 783 | ENTER(); |
| 784 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 785 | if (0 > wiphy_register(wiphy)) |
| 786 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 787 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 788 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 789 | return -EIO; |
| 790 | } |
| 791 | |
| 792 | EXIT(); |
| 793 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 794 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 795 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 796 | /* In this function we will try to get default country code from crda. |
| 797 | If the gCrdaDefaultCountryCode is configured in ini file, |
| 798 | we will try to call user space crda to get the regulatory settings for |
| 799 | that country. We will timeout if we can't get it from crda. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 800 | It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_init. |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 801 | */ |
| 802 | int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg) |
| 803 | { |
| 804 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Madan Mohan Koyyalamudi | 113ac74 | 2013-08-06 22:45:43 +0530 | [diff] [blame] | 805 | int status; |
| 806 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 807 | if (memcmp(pCfg->crdaDefaultCountryCode, |
| 808 | CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0) |
| 809 | { |
Madan Mohan Koyyalamudi | 113ac74 | 2013-08-06 22:45:43 +0530 | [diff] [blame] | 810 | INIT_COMPLETION(pHddCtx->driver_crda_req); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 811 | regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode); |
Madan Mohan Koyyalamudi | 113ac74 | 2013-08-06 22:45:43 +0530 | [diff] [blame] | 812 | status = wait_for_completion_interruptible_timeout( |
| 813 | &pHddCtx->driver_crda_req, |
| 814 | msecs_to_jiffies(CRDA_WAIT_TIME)); |
| 815 | if (!status) |
| 816 | { |
| 817 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: timeout waiting for CRDA REQ", |
| 818 | __func__); |
| 819 | } |
| 820 | |
Yunsen Wang | e3ba1fb | 2013-04-05 15:04:43 -0700 | [diff] [blame] | 821 | /* if the country is not found from current regulatory.bin, |
| 822 | fall back to world domain */ |
| 823 | if (is_crda_regulatory_entry_valid() == VOS_FALSE) |
| 824 | crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 825 | } |
| 826 | return 0; |
| 827 | } |
| 828 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame^] | 829 | /* In this function we are updating channel list when, |
| 830 | regulatory domain is FCC and country code is US. |
| 831 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 832 | As per FCC smart phone is not a indoor device. |
| 833 | GO should not opeate on indoor channels */ |
| 834 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 835 | { |
| 836 | int j; |
| 837 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 838 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 839 | //Default counrtycode from NV at the time of wiphy initialization. |
| 840 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 841 | &defaultCountryCode[0])) |
| 842 | { |
| 843 | hddLog(LOGE, FL("%s Failed to get default country code from NV")); |
| 844 | } |
| 845 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 846 | { |
| 847 | /* This will disable updating of NL channels from passive to |
| 848 | active if a beacon is received on passive channel. |
| 849 | If this flag is not disabled then nl can change passive channel to |
| 850 | active channels. |
| 851 | */ |
| 852 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
| 853 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 854 | { |
| 855 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 856 | return; |
| 857 | } |
| 858 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 859 | { |
| 860 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 861 | // Mark UNII -1 band channel as passive |
| 862 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 863 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 864 | } |
| 865 | } |
| 866 | } |
| 867 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 868 | /* In this function we will do all post VOS start initialization. |
| 869 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 870 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 871 | */ |
| 872 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 873 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 874 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 875 | /* Register for all P2P action, public action etc frames */ |
| 876 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 877 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 878 | ENTER(); |
| 879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 880 | /* Right now we are registering these frame when driver is getting |
| 881 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 882 | frame register ops, we will move this code as a part of that */ |
| 883 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 884 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 885 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 886 | |
| 887 | /* GAS Initial Response */ |
| 888 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 889 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 890 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 891 | /* GAS Comeback Request */ |
| 892 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 893 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 894 | |
| 895 | /* GAS Comeback Response */ |
| 896 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 897 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 898 | |
| 899 | /* P2P Public Action */ |
| 900 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 901 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 902 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 903 | |
| 904 | /* P2P Action */ |
| 905 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 906 | (v_U8_t*)P2P_ACTION_FRAME, |
| 907 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 908 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 909 | /* WNM BSS Transition Request frame */ |
| 910 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 911 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 912 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 913 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 914 | #ifdef WLAN_FEATURE_11W |
| 915 | /* SA Query Response Action Frame */ |
| 916 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 917 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 918 | SA_QUERY_FRAME_RSP_SIZE ); |
| 919 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 923 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 924 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 925 | /* Register for all P2P action, public action etc frames */ |
| 926 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 927 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 928 | ENTER(); |
| 929 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 930 | /* Right now we are registering these frame when driver is getting |
| 931 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 932 | frame register ops, we will move this code as a part of that */ |
| 933 | /* GAS Initial Request */ |
| 934 | |
| 935 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 936 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 937 | |
| 938 | /* GAS Initial Response */ |
| 939 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 940 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 941 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 942 | /* GAS Comeback Request */ |
| 943 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 944 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 945 | |
| 946 | /* GAS Comeback Response */ |
| 947 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 948 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 949 | |
| 950 | /* P2P Public Action */ |
| 951 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 952 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 953 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 954 | |
| 955 | /* P2P Action */ |
| 956 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 957 | (v_U8_t*)P2P_ACTION_FRAME, |
| 958 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 959 | |
| 960 | #ifdef WLAN_FEATURE_11W |
| 961 | /* SA Query Response Action Frame */ |
| 962 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 963 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 964 | SA_QUERY_FRAME_RSP_SIZE ); |
| 965 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | #ifdef FEATURE_WLAN_WAPI |
| 969 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 970 | const u8 *mac_addr, u8 *key , int key_Len) |
| 971 | { |
| 972 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 973 | tCsrRoamSetKey setKey; |
| 974 | v_BOOL_t isConnected = TRUE; |
| 975 | int status = 0; |
| 976 | v_U32_t roamId= 0xFF; |
| 977 | tANI_U8 *pKeyPtr = NULL; |
| 978 | int n = 0; |
| 979 | |
| 980 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 981 | __func__,pAdapter->device_mode); |
| 982 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 983 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 984 | setKey.keyId = key_index; // Store Key ID |
| 985 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 986 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 987 | setKey.paeRole = 0 ; // the PAE role |
| 988 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 989 | { |
| 990 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 991 | } |
| 992 | else |
| 993 | { |
| 994 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 995 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 996 | } |
| 997 | setKey.keyLength = key_Len; |
| 998 | pKeyPtr = setKey.Key; |
| 999 | memcpy( pKeyPtr, key, key_Len); |
| 1000 | |
| 1001 | hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x", |
| 1002 | __func__, key_Len); |
| 1003 | for (n = 0 ; n < key_Len; n++) |
| 1004 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 1005 | __func__,n,setKey.Key[n]); |
| 1006 | |
| 1007 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 1008 | if ( isConnected ) |
| 1009 | { |
| 1010 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1011 | pAdapter->sessionId, &setKey, &roamId ); |
| 1012 | } |
| 1013 | if ( status != 0 ) |
| 1014 | { |
| 1015 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1016 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 1017 | __LINE__, status ); |
| 1018 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 1019 | } |
| 1020 | } |
| 1021 | #endif /* FEATURE_WLAN_WAPI*/ |
| 1022 | |
| 1023 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1024 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1025 | beacon_data_t **ppBeacon, |
| 1026 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1027 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1028 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1029 | beacon_data_t **ppBeacon, |
| 1030 | struct cfg80211_beacon_data *params, |
| 1031 | int dtim_period) |
| 1032 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1033 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1034 | int size; |
| 1035 | beacon_data_t *beacon = NULL; |
| 1036 | beacon_data_t *old = NULL; |
| 1037 | int head_len,tail_len; |
| 1038 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1039 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1040 | if (params->head && !params->head_len) |
| 1041 | return -EINVAL; |
| 1042 | |
| 1043 | old = pAdapter->sessionCtx.ap.beacon; |
| 1044 | |
| 1045 | if (!params->head && !old) |
| 1046 | return -EINVAL; |
| 1047 | |
| 1048 | if (params->tail && !params->tail_len) |
| 1049 | return -EINVAL; |
| 1050 | |
| 1051 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 1052 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 1053 | if (!params->dtim_period) |
| 1054 | return -EINVAL; |
| 1055 | #endif |
| 1056 | |
| 1057 | if(params->head) |
| 1058 | head_len = params->head_len; |
| 1059 | else |
| 1060 | head_len = old->head_len; |
| 1061 | |
| 1062 | if(params->tail || !old) |
| 1063 | tail_len = params->tail_len; |
| 1064 | else |
| 1065 | tail_len = old->tail_len; |
| 1066 | |
| 1067 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 1068 | |
| 1069 | beacon = kzalloc(size, GFP_KERNEL); |
| 1070 | |
| 1071 | if( beacon == NULL ) |
| 1072 | return -ENOMEM; |
| 1073 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1074 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1075 | if(params->dtim_period || !old ) |
| 1076 | beacon->dtim_period = params->dtim_period; |
| 1077 | else |
| 1078 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1079 | #else |
| 1080 | if(dtim_period || !old ) |
| 1081 | beacon->dtim_period = dtim_period; |
| 1082 | else |
| 1083 | beacon->dtim_period = old->dtim_period; |
| 1084 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1085 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1086 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 1087 | beacon->tail = beacon->head + head_len; |
| 1088 | beacon->head_len = head_len; |
| 1089 | beacon->tail_len = tail_len; |
| 1090 | |
| 1091 | if(params->head) { |
| 1092 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1093 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1094 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1095 | if(old) |
| 1096 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1097 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1098 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1099 | if(params->tail) { |
| 1100 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1101 | } |
| 1102 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1103 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1104 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1105 | } |
| 1106 | |
| 1107 | *ppBeacon = beacon; |
| 1108 | |
| 1109 | kfree(old); |
| 1110 | |
| 1111 | return 0; |
| 1112 | |
| 1113 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1114 | |
| 1115 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1116 | { |
| 1117 | int left = length; |
| 1118 | v_U8_t *ptr = pIes; |
| 1119 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1121 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1122 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1123 | elem_id = ptr[0]; |
| 1124 | elem_len = ptr[1]; |
| 1125 | left -= 2; |
| 1126 | if(elem_len > left) |
| 1127 | { |
| 1128 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1129 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1130 | eid,elem_len,left); |
| 1131 | return NULL; |
| 1132 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1133 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1134 | { |
| 1135 | return ptr; |
| 1136 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1137 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1138 | left -= elem_len; |
| 1139 | ptr += (elem_len + 2); |
| 1140 | } |
| 1141 | return NULL; |
| 1142 | } |
| 1143 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1144 | /* Check if rate is 11g rate or not */ |
| 1145 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1146 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 1147 | static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1148 | u8 i; |
| 1149 | for (i = 0; i < 8; i++) |
| 1150 | { |
| 1151 | if(rate == gRateArray[i]) |
| 1152 | return TRUE; |
| 1153 | } |
| 1154 | return FALSE; |
| 1155 | } |
| 1156 | |
| 1157 | /* Check for 11g rate and set proper 11g only mode */ |
| 1158 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1159 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1160 | { |
| 1161 | u8 i, num_rates = pIe[0]; |
| 1162 | |
| 1163 | pIe += 1; |
| 1164 | for ( i = 0; i < num_rates; i++) |
| 1165 | { |
| 1166 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1167 | { |
| 1168 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1169 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1170 | if (pIe[i] & BASIC_RATE_MASK) |
| 1171 | { |
| 1172 | /* If we have 11g rate as basic rate, it means mode |
| 1173 | is 11g only mode. |
| 1174 | */ |
| 1175 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1176 | *pCheckRatesfor11g = FALSE; |
| 1177 | } |
| 1178 | } |
| 1179 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1180 | { |
| 1181 | *require_ht = TRUE; |
| 1182 | } |
| 1183 | } |
| 1184 | return; |
| 1185 | } |
| 1186 | |
| 1187 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1188 | { |
| 1189 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1190 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1191 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1192 | u8 checkRatesfor11g = TRUE; |
| 1193 | u8 require_ht = FALSE; |
| 1194 | u8 *pIe=NULL; |
| 1195 | |
| 1196 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1197 | |
| 1198 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1199 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1200 | if (pIe != NULL) |
| 1201 | { |
| 1202 | pIe += 1; |
| 1203 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1204 | &pConfig->SapHw_mode); |
| 1205 | } |
| 1206 | |
| 1207 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1208 | WLAN_EID_EXT_SUPP_RATES); |
| 1209 | if (pIe != NULL) |
| 1210 | { |
| 1211 | |
| 1212 | pIe += 1; |
| 1213 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1214 | &pConfig->SapHw_mode); |
| 1215 | } |
| 1216 | |
| 1217 | if( pConfig->channel > 14 ) |
| 1218 | { |
| 1219 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1220 | } |
| 1221 | |
| 1222 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1223 | WLAN_EID_HT_CAPABILITY); |
| 1224 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1225 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1226 | { |
| 1227 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1228 | if(require_ht) |
| 1229 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1230 | } |
| 1231 | } |
| 1232 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1233 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1234 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1235 | { |
| 1236 | v_U8_t ielen = 0; |
| 1237 | v_U8_t *pIe = NULL; |
| 1238 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1239 | |
| 1240 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1241 | pBeacon->tail, pBeacon->tail_len); |
| 1242 | |
| 1243 | if (pIe) |
| 1244 | { |
| 1245 | ielen = pIe[1] + 2; |
| 1246 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1247 | { |
| 1248 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1249 | } |
| 1250 | else |
| 1251 | { |
| 1252 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1253 | return -EINVAL; |
| 1254 | } |
| 1255 | *total_ielen += ielen; |
| 1256 | } |
| 1257 | return 0; |
| 1258 | } |
| 1259 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1260 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1261 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1262 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1263 | #else |
| 1264 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1265 | struct cfg80211_beacon_data *params) |
| 1266 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1267 | { |
| 1268 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1269 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1270 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1271 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1272 | |
| 1273 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1274 | |
| 1275 | if(genie == NULL) { |
| 1276 | |
| 1277 | return -ENOMEM; |
| 1278 | } |
| 1279 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1280 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1281 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1282 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1283 | ret = -EINVAL; |
| 1284 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1288 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1289 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1290 | { |
| 1291 | ret = -EINVAL; |
| 1292 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1293 | } |
| 1294 | #endif |
| 1295 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1296 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1297 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1298 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1299 | ret = -EINVAL; |
| 1300 | goto done; |
| 1301 | } |
| 1302 | |
| 1303 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1304 | { |
| 1305 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1306 | &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1307 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1308 | ret = -EINVAL; |
| 1309 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1310 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1311 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1312 | |
| 1313 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1314 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1315 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1316 | { |
| 1317 | hddLog(LOGE, |
| 1318 | "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] | 1319 | ret = -EINVAL; |
| 1320 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1324 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1325 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1326 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1327 | ==eHAL_STATUS_FAILURE) |
| 1328 | { |
| 1329 | hddLog(LOGE, |
| 1330 | "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] | 1331 | ret = -EINVAL; |
| 1332 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | // Added for ProResp IE |
| 1336 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1337 | { |
| 1338 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1339 | u8 probe_rsp_ie_len[3] = {0}; |
| 1340 | u8 counter = 0; |
| 1341 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1342 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1343 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1344 | Store More then 255 bytes into One Variable. |
| 1345 | */ |
| 1346 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1347 | { |
| 1348 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1349 | { |
| 1350 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1351 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1352 | } |
| 1353 | else |
| 1354 | { |
| 1355 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1356 | rem_probe_resp_ie_len = 0; |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | rem_probe_resp_ie_len = 0; |
| 1361 | |
| 1362 | if (probe_rsp_ie_len[0] > 0) |
| 1363 | { |
| 1364 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1365 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1366 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1367 | probe_rsp_ie_len[0], NULL, |
| 1368 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1369 | { |
| 1370 | hddLog(LOGE, |
| 1371 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1372 | ret = -EINVAL; |
| 1373 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1374 | } |
| 1375 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1376 | } |
| 1377 | |
| 1378 | if (probe_rsp_ie_len[1] > 0) |
| 1379 | { |
| 1380 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1381 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1382 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1383 | probe_rsp_ie_len[1], NULL, |
| 1384 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1385 | { |
| 1386 | hddLog(LOGE, |
| 1387 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1388 | ret = -EINVAL; |
| 1389 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1390 | } |
| 1391 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1392 | } |
| 1393 | |
| 1394 | if (probe_rsp_ie_len[2] > 0) |
| 1395 | { |
| 1396 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1397 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1398 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1399 | probe_rsp_ie_len[2], NULL, |
| 1400 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1401 | { |
| 1402 | hddLog(LOGE, |
| 1403 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1404 | ret = -EINVAL; |
| 1405 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1406 | } |
| 1407 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1408 | } |
| 1409 | |
| 1410 | if (probe_rsp_ie_len[1] == 0 ) |
| 1411 | { |
| 1412 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1413 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1414 | eANI_BOOLEAN_FALSE) ) |
| 1415 | { |
| 1416 | hddLog(LOGE, |
| 1417 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n"); |
| 1418 | } |
| 1419 | } |
| 1420 | |
| 1421 | if (probe_rsp_ie_len[2] == 0 ) |
| 1422 | { |
| 1423 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1424 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1425 | eANI_BOOLEAN_FALSE) ) |
| 1426 | { |
| 1427 | hddLog(LOGE, |
| 1428 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n"); |
| 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1433 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1434 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1435 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1436 | == eHAL_STATUS_FAILURE) |
| 1437 | { |
| 1438 | hddLog(LOGE, |
| 1439 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1440 | ret = -EINVAL; |
| 1441 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1442 | } |
| 1443 | } |
| 1444 | else |
| 1445 | { |
| 1446 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1447 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1448 | |
| 1449 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1450 | "%s: No Probe Response IE received in set beacon", |
| 1451 | __func__); |
| 1452 | } |
| 1453 | |
| 1454 | // Added for AssocResp IE |
| 1455 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1456 | { |
| 1457 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1458 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1459 | params->assocresp_ies_len, NULL, |
| 1460 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1461 | { |
| 1462 | hddLog(LOGE, |
| 1463 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1464 | ret = -EINVAL; |
| 1465 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1466 | } |
| 1467 | |
| 1468 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1469 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1470 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1471 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1472 | == eHAL_STATUS_FAILURE) |
| 1473 | { |
| 1474 | hddLog(LOGE, |
| 1475 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1476 | ret = -EINVAL; |
| 1477 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1478 | } |
| 1479 | } |
| 1480 | else |
| 1481 | { |
| 1482 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1483 | "%s: No Assoc Response IE received in set beacon", |
| 1484 | __func__); |
| 1485 | |
| 1486 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1487 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1488 | eANI_BOOLEAN_FALSE) ) |
| 1489 | { |
| 1490 | hddLog(LOGE, |
| 1491 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 1492 | } |
| 1493 | } |
| 1494 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1495 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1496 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1497 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1498 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1499 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1500 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1501 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1502 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1503 | * wlan_hdd_cfg80211_set_channel() |
| 1504 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1505 | * channel list. |
| 1506 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 1507 | VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1508 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1509 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1510 | v_U32_t num_ch = 0; |
| 1511 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1512 | u32 indx = 0; |
| 1513 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1514 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1515 | 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] | 1516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1517 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1518 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1519 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1520 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1521 | /* Validate the channel */ |
| 1522 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1523 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1524 | if ( channel == rfChannels[count].channelNum ) |
| 1525 | { |
| 1526 | fValidChannel = TRUE; |
| 1527 | break; |
| 1528 | } |
| 1529 | } |
| 1530 | if (fValidChannel != TRUE) |
| 1531 | { |
| 1532 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1533 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1534 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1535 | } |
| 1536 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1537 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1538 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1539 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1540 | valid_ch, &num_ch)) |
| 1541 | { |
| 1542 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1543 | "%s: failed to get valid channel list", __func__); |
| 1544 | return VOS_STATUS_E_FAILURE; |
| 1545 | } |
| 1546 | for (indx = 0; indx < num_ch; indx++) |
| 1547 | { |
| 1548 | if (channel == valid_ch[indx]) |
| 1549 | { |
| 1550 | break; |
| 1551 | } |
| 1552 | } |
| 1553 | |
| 1554 | if (indx >= num_ch) |
| 1555 | { |
| 1556 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1557 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1558 | return VOS_STATUS_E_FAILURE; |
| 1559 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1560 | } |
| 1561 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1562 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1565 | /** |
| 1566 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1567 | * This function is used to set the channel number |
| 1568 | */ |
| 1569 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1570 | struct ieee80211_channel *chan, |
| 1571 | enum nl80211_channel_type channel_type |
| 1572 | ) |
| 1573 | { |
| 1574 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1575 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1576 | hdd_adapter_t *pAdapter = NULL; |
| 1577 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1578 | hdd_context_t *pHddCtx; |
| 1579 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1580 | |
| 1581 | ENTER(); |
| 1582 | |
| 1583 | if( NULL == dev ) |
| 1584 | { |
| 1585 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1586 | "%s: Called with dev = NULL.\n", __func__); |
| 1587 | return -ENODEV; |
| 1588 | } |
| 1589 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1590 | |
| 1591 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1592 | "%s: device_mode = %d freq = %d \n",__func__, |
| 1593 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1594 | |
| 1595 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1596 | status = wlan_hdd_validate_context(pHddCtx); |
| 1597 | |
| 1598 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1599 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1600 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1601 | "%s: HDD context is not valid", __func__); |
| 1602 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1603 | } |
| 1604 | |
| 1605 | /* |
| 1606 | * Do freq to chan conversion |
| 1607 | * TODO: for 11a |
| 1608 | */ |
| 1609 | |
| 1610 | channel = ieee80211_frequency_to_channel(freq); |
| 1611 | |
| 1612 | /* Check freq range */ |
| 1613 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1614 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1615 | { |
| 1616 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1617 | "%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1618 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1619 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1620 | return -EINVAL; |
| 1621 | } |
| 1622 | |
| 1623 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1624 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1625 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1626 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1627 | { |
| 1628 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1629 | { |
| 1630 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1631 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1632 | return -EINVAL; |
| 1633 | } |
| 1634 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1635 | "%s: set channel to [%d] for device mode =%d", |
| 1636 | __func__, channel,pAdapter->device_mode); |
| 1637 | } |
| 1638 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1639 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1640 | ) |
| 1641 | { |
| 1642 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1643 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1644 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1645 | |
| 1646 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1647 | { |
| 1648 | /* Link is up then return cant set channel*/ |
| 1649 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1650 | "%s: IBSS Associated, can't set the channel\n", __func__); |
| 1651 | return -EINVAL; |
| 1652 | } |
| 1653 | |
| 1654 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1655 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1656 | pRoamProfile->ChannelInfo.ChannelList = |
| 1657 | &pHddStaCtx->conn_info.operationChannel; |
| 1658 | } |
| 1659 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1660 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1661 | ) |
| 1662 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1663 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1664 | { |
| 1665 | if(VOS_STATUS_SUCCESS != |
| 1666 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1667 | { |
| 1668 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1669 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1670 | return -EINVAL; |
| 1671 | } |
| 1672 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1673 | } |
| 1674 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1675 | { |
| 1676 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1677 | |
| 1678 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1679 | channel set by supplicant |
| 1680 | */ |
| 1681 | if ( cfg_param->apAutoChannelSelection ) |
| 1682 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1683 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1684 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1685 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1686 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1687 | __func__, pAdapter->device_mode); |
| 1688 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1689 | else |
| 1690 | { |
| 1691 | if(VOS_STATUS_SUCCESS != |
| 1692 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1693 | { |
| 1694 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1695 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1696 | return -EINVAL; |
| 1697 | } |
| 1698 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1699 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1700 | } |
| 1701 | } |
| 1702 | else |
| 1703 | { |
| 1704 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1705 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1706 | return -EINVAL; |
| 1707 | } |
| 1708 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1709 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1710 | } |
| 1711 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1712 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1713 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1714 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1715 | #else |
| 1716 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1717 | struct cfg80211_beacon_data *params, |
| 1718 | const u8 *ssid, size_t ssid_len, |
| 1719 | enum nl80211_hidden_ssid hidden_ssid) |
| 1720 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1721 | { |
| 1722 | tsap_Config_t *pConfig; |
| 1723 | beacon_data_t *pBeacon = NULL; |
| 1724 | struct ieee80211_mgmt *pMgmt_frame; |
| 1725 | v_U8_t *pIe=NULL; |
| 1726 | v_U16_t capab_info; |
| 1727 | eCsrAuthType RSNAuthType; |
| 1728 | eCsrEncryptionType RSNEncryptType; |
| 1729 | eCsrEncryptionType mcRSNEncryptType; |
| 1730 | int status = VOS_STATUS_SUCCESS; |
| 1731 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1732 | hdd_hostapd_state_t *pHostapdState; |
| 1733 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1734 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1735 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1736 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1737 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1738 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1739 | |
| 1740 | ENTER(); |
| 1741 | |
| 1742 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1743 | |
| 1744 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1745 | |
| 1746 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1747 | |
| 1748 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1749 | |
| 1750 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1751 | |
| 1752 | //channel is already set in the set_channel Call back |
| 1753 | //pConfig->channel = pCommitConfig->channel; |
| 1754 | |
| 1755 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1756 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1757 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1758 | |
| 1759 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1760 | |
| 1761 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1762 | pConfig->dtim_period); |
| 1763 | |
| 1764 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1765 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1766 | { |
| 1767 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1768 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1769 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1770 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1771 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1772 | pConfig->ieee80211d = 1; |
| 1773 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1774 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1775 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1776 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1777 | else |
| 1778 | { |
| 1779 | pConfig->ieee80211d = 0; |
| 1780 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1781 | /* |
| 1782 | * If auto channel is configured i.e. channel is 0, |
| 1783 | * so skip channel validation. |
| 1784 | */ |
| 1785 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1786 | { |
| 1787 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1788 | { |
| 1789 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1790 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1791 | return -EINVAL; |
| 1792 | } |
| 1793 | } |
| 1794 | else |
| 1795 | { |
| 1796 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1797 | { |
| 1798 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1799 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1800 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1801 | } |
| 1802 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1803 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1804 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1805 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1806 | { |
| 1807 | pConfig->ieee80211d = 0; |
| 1808 | } |
| 1809 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1810 | |
| 1811 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1812 | |
| 1813 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1814 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1815 | |
| 1816 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1817 | |
| 1818 | /*Set wps station to configured*/ |
| 1819 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1820 | |
| 1821 | if(pIe) |
| 1822 | { |
| 1823 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1824 | { |
| 1825 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1826 | return -EINVAL; |
| 1827 | } |
| 1828 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1829 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1830 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1831 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1832 | * WPS state |
| 1833 | */ |
| 1834 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1835 | { |
| 1836 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1837 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1838 | { |
| 1839 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1840 | } |
| 1841 | } |
| 1842 | } |
| 1843 | else |
| 1844 | { |
| 1845 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1846 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1847 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1848 | |
| 1849 | pConfig->RSNWPAReqIELength = 0; |
| 1850 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1851 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1852 | WLAN_EID_RSN); |
| 1853 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1854 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1855 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1856 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1857 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1858 | /* The actual processing may eventually be more extensive than |
| 1859 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1860 | * by the app. |
| 1861 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1862 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1863 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1864 | &RSNEncryptType, |
| 1865 | &mcRSNEncryptType, |
| 1866 | &RSNAuthType, |
| 1867 | pConfig->pRSNWPAReqIE[1]+2, |
| 1868 | pConfig->pRSNWPAReqIE ); |
| 1869 | |
| 1870 | if( VOS_STATUS_SUCCESS == status ) |
| 1871 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1872 | /* Now copy over all the security attributes you have |
| 1873 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1874 | * */ |
| 1875 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1876 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1877 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1878 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1879 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1880 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1881 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1882 | } |
| 1883 | } |
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 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1886 | pBeacon->tail, pBeacon->tail_len); |
| 1887 | |
| 1888 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1889 | { |
| 1890 | if (pConfig->pRSNWPAReqIE) |
| 1891 | { |
| 1892 | /*Mixed mode WPA/WPA2*/ |
| 1893 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1894 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1895 | } |
| 1896 | else |
| 1897 | { |
| 1898 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1899 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1900 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1901 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1902 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1903 | &RSNEncryptType, |
| 1904 | &mcRSNEncryptType, |
| 1905 | &RSNAuthType, |
| 1906 | pConfig->pRSNWPAReqIE[1]+2, |
| 1907 | pConfig->pRSNWPAReqIE ); |
| 1908 | |
| 1909 | if( VOS_STATUS_SUCCESS == status ) |
| 1910 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1911 | /* Now copy over all the security attributes you have |
| 1912 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1913 | * */ |
| 1914 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1915 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1916 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1917 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1918 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1919 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1920 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1921 | } |
| 1922 | } |
| 1923 | } |
| 1924 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1925 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1926 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1927 | return -EINVAL; |
| 1928 | } |
| 1929 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1930 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1931 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1932 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1933 | if (params->ssid != NULL) |
| 1934 | { |
| 1935 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1936 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1937 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1938 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1939 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1940 | #else |
| 1941 | if (ssid != NULL) |
| 1942 | { |
| 1943 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1944 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1945 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1946 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1947 | } |
| 1948 | #endif |
| 1949 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1950 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1951 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1953 | /* default value */ |
| 1954 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1955 | pConfig->num_accept_mac = 0; |
| 1956 | pConfig->num_deny_mac = 0; |
| 1957 | |
| 1958 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1959 | pBeacon->tail, pBeacon->tail_len); |
| 1960 | |
| 1961 | /* pIe for black list is following form: |
| 1962 | type : 1 byte |
| 1963 | length : 1 byte |
| 1964 | OUI : 4 bytes |
| 1965 | acl type : 1 byte |
| 1966 | no of mac addr in black list: 1 byte |
| 1967 | 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] | 1968 | */ |
| 1969 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1970 | { |
| 1971 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1972 | pConfig->num_deny_mac = pIe[7]; |
| 1973 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1974 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1975 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 1976 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1977 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1978 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1979 | { |
| 1980 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1981 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1982 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1983 | } |
| 1984 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1985 | pBeacon->tail, pBeacon->tail_len); |
| 1986 | |
| 1987 | /* pIe for white list is following form: |
| 1988 | type : 1 byte |
| 1989 | length : 1 byte |
| 1990 | OUI : 4 bytes |
| 1991 | acl type : 1 byte |
| 1992 | no of mac addr in white list: 1 byte |
| 1993 | 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] | 1994 | */ |
| 1995 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1996 | { |
| 1997 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1998 | pConfig->num_accept_mac = pIe[7]; |
| 1999 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 2000 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2001 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 2002 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2003 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2004 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 2005 | { |
| 2006 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2007 | acl_entry++; |
| 2008 | } |
| 2009 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2010 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2011 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 2012 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2013 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2014 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 2015 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 2016 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 2017 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 2018 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2019 | (((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] | 2020 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 2021 | ((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] | 2022 | { |
| 2023 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 2024 | |
| 2025 | /* Disable VHT support in 2.4 GHz band */ |
| 2026 | if (pConfig->channel <= 14 && |
| 2027 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE) |
| 2028 | { |
| 2029 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 2030 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2031 | } |
| 2032 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2033 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 2034 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 2035 | { |
| 2036 | sme_SelectCBMode(hHal, |
| 2037 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 2038 | pConfig->channel); |
| 2039 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2040 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 2041 | pConfig->ht_capab = |
| 2042 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 2043 | |
| 2044 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 2045 | { |
| 2046 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 2047 | return -EINVAL; |
| 2048 | } |
| 2049 | |
| 2050 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2051 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2052 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 2053 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2054 | pConfig->obssProtEnabled = |
| 2055 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2056 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2057 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2058 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2059 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2060 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 2061 | (int)pConfig->channel); |
| 2062 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2063 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 2064 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2065 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2066 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2067 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 2068 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 2069 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2070 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2071 | { |
| 2072 | //Bss already started. just return. |
| 2073 | //TODO Probably it should update some beacon params. |
| 2074 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 2075 | EXIT(); |
| 2076 | return 0; |
| 2077 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2078 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2079 | pConfig->persona = pHostapdAdapter->device_mode; |
| 2080 | |
| 2081 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 2082 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 2083 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 2084 | { |
| 2085 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 2086 | return -EINVAL; |
| 2087 | } |
| 2088 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2089 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2090 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2091 | |
| 2092 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2093 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2094 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2095 | { |
| 2096 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2097 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2098 | VOS_ASSERT(0); |
| 2099 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2100 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2101 | //Succesfully started Bss update the state bit. |
| 2102 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2103 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2104 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2105 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2106 | { |
| 2107 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2108 | { |
| 2109 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2110 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2111 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2112 | } |
| 2113 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2114 | { |
| 2115 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2116 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2117 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2118 | } |
| 2119 | } |
| 2120 | #endif |
| 2121 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2122 | pHostapdState->bCommit = TRUE; |
| 2123 | EXIT(); |
| 2124 | |
| 2125 | return 0; |
| 2126 | } |
| 2127 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2128 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2129 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2130 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2131 | struct beacon_parameters *params) |
| 2132 | { |
| 2133 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2134 | hdd_context_t *pHddCtx; |
| 2135 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2136 | |
| 2137 | ENTER(); |
| 2138 | |
| 2139 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 2140 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2141 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2142 | status = wlan_hdd_validate_context(pHddCtx); |
| 2143 | |
| 2144 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2145 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2146 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2147 | "%s: HDD context is not valid", __func__); |
| 2148 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2149 | } |
| 2150 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2151 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2152 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2153 | ) |
| 2154 | { |
| 2155 | beacon_data_t *old,*new; |
| 2156 | |
| 2157 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2158 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2159 | if (old) |
| 2160 | return -EALREADY; |
| 2161 | |
| 2162 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2163 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2164 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2165 | { |
| 2166 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2167 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 2168 | return -EINVAL; |
| 2169 | } |
| 2170 | |
| 2171 | pAdapter->sessionCtx.ap.beacon = new; |
| 2172 | |
| 2173 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2174 | } |
| 2175 | |
| 2176 | EXIT(); |
| 2177 | return status; |
| 2178 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2179 | |
| 2180 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2181 | struct net_device *dev, |
| 2182 | struct beacon_parameters *params) |
| 2183 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2184 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2185 | hdd_context_t *pHddCtx; |
| 2186 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2187 | |
| 2188 | ENTER(); |
| 2189 | |
| 2190 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2191 | __func__,pAdapter->device_mode); |
| 2192 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2193 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2194 | status = wlan_hdd_validate_context(pHddCtx); |
| 2195 | |
| 2196 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2197 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2198 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2199 | "%s: HDD context is not valid", __func__); |
| 2200 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2201 | } |
| 2202 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2203 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2204 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2205 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2206 | { |
| 2207 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2208 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2209 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2210 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2211 | if (!old) |
| 2212 | return -ENOENT; |
| 2213 | |
| 2214 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2215 | |
| 2216 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2217 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2218 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2219 | return -EINVAL; |
| 2220 | } |
| 2221 | |
| 2222 | pAdapter->sessionCtx.ap.beacon = new; |
| 2223 | |
| 2224 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2225 | } |
| 2226 | |
| 2227 | EXIT(); |
| 2228 | return status; |
| 2229 | } |
| 2230 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2231 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2232 | |
| 2233 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2234 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2235 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2236 | #else |
| 2237 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2238 | struct net_device *dev) |
| 2239 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2240 | { |
| 2241 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2242 | hdd_context_t *pHddCtx = NULL; |
| 2243 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2244 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2245 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2246 | |
| 2247 | ENTER(); |
| 2248 | |
| 2249 | if (NULL == pAdapter) |
| 2250 | { |
| 2251 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2252 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2253 | return -ENODEV; |
| 2254 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2255 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2256 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2257 | status = wlan_hdd_validate_context(pHddCtx); |
| 2258 | |
| 2259 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2260 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2261 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2262 | "%s: HDD context is not valid", __func__); |
| 2263 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2264 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2265 | |
| 2266 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2267 | if (NULL == staAdapter) |
| 2268 | { |
| 2269 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2270 | if (NULL == staAdapter) |
| 2271 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2272 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2273 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2274 | return -ENODEV; |
| 2275 | } |
| 2276 | } |
| 2277 | |
| 2278 | pScanInfo = &pHddCtx->scan_info; |
| 2279 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2280 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2281 | __func__,pAdapter->device_mode); |
| 2282 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2283 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2284 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2285 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2286 | hdd_abort_mac_scan(staAdapter->pHddCtx); |
| 2287 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2288 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2289 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2290 | if (!status) |
| 2291 | { |
| 2292 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2293 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2294 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2295 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2296 | return 0; |
| 2297 | } |
| 2298 | } |
| 2299 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2300 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2301 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2302 | ) |
| 2303 | { |
| 2304 | beacon_data_t *old; |
| 2305 | |
| 2306 | old = pAdapter->sessionCtx.ap.beacon; |
| 2307 | |
| 2308 | if (!old) |
| 2309 | return -ENOENT; |
| 2310 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2311 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2312 | |
| 2313 | mutex_lock(&pHddCtx->sap_lock); |
| 2314 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2315 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2316 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2317 | { |
| 2318 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2319 | |
| 2320 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2321 | |
| 2322 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2323 | { |
| 2324 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2325 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2326 | VOS_ASSERT(0); |
| 2327 | } |
| 2328 | } |
| 2329 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2330 | } |
| 2331 | mutex_unlock(&pHddCtx->sap_lock); |
| 2332 | |
| 2333 | if(status != VOS_STATUS_SUCCESS) |
| 2334 | { |
| 2335 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2336 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2337 | return -EINVAL; |
| 2338 | } |
| 2339 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2340 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2341 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2342 | ==eHAL_STATUS_FAILURE) |
| 2343 | { |
| 2344 | hddLog(LOGE, |
| 2345 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2346 | } |
| 2347 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2348 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2349 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2350 | eANI_BOOLEAN_FALSE) ) |
| 2351 | { |
| 2352 | hddLog(LOGE, |
| 2353 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2354 | } |
| 2355 | |
| 2356 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2357 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2358 | |
| 2359 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2360 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2361 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2362 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2363 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2364 | { |
| 2365 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2366 | "GO got removed"); |
| 2367 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2368 | } |
| 2369 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2370 | } |
| 2371 | EXIT(); |
| 2372 | return status; |
| 2373 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2374 | |
| 2375 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2376 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2377 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2378 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2379 | struct cfg80211_ap_settings *params) |
| 2380 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2381 | hdd_adapter_t *pAdapter; |
| 2382 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2383 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2384 | |
| 2385 | ENTER(); |
| 2386 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2387 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2388 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2389 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2390 | "%s: Device is Null", __func__); |
| 2391 | return -ENODEV; |
| 2392 | } |
| 2393 | |
| 2394 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2395 | if (NULL == pAdapter) |
| 2396 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2397 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2398 | "%s: HDD adapter is Null", __func__); |
| 2399 | return -ENODEV; |
| 2400 | } |
| 2401 | |
| 2402 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2403 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2405 | "%s: HDD adapter magic is invalid", __func__); |
| 2406 | return -ENODEV; |
| 2407 | } |
| 2408 | |
| 2409 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2410 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2411 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2412 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2413 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2414 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2415 | "%s: HDD context is not valid", __func__); |
| 2416 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2417 | } |
| 2418 | |
| 2419 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2420 | __func__, pAdapter->device_mode); |
| 2421 | |
| 2422 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2423 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2424 | ) |
| 2425 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2426 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2427 | |
| 2428 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2429 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2430 | if (old) |
| 2431 | return -EALREADY; |
| 2432 | |
| 2433 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2434 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2435 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2436 | { |
| 2437 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2438 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2439 | return -EINVAL; |
| 2440 | } |
| 2441 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2442 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2443 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 2444 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2445 | params->channel, params->channel_type); |
| 2446 | #else |
| 2447 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 2448 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2449 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2450 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2451 | params->ssid_len, params->hidden_ssid); |
Gopichand Nakkala | 8c0386c | 2013-07-09 23:31:37 +0530 | [diff] [blame] | 2452 | if (0 == status) |
| 2453 | { |
| 2454 | hdd_start_p2p_go_connection_in_progress_timer(pAdapter); |
| 2455 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2456 | } |
| 2457 | |
| 2458 | EXIT(); |
| 2459 | return status; |
| 2460 | } |
| 2461 | |
| 2462 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2463 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2464 | struct net_device *dev, |
| 2465 | struct cfg80211_beacon_data *params) |
| 2466 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2467 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2468 | hdd_context_t *pHddCtx; |
| 2469 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2470 | |
| 2471 | ENTER(); |
| 2472 | |
| 2473 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2474 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2475 | |
| 2476 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2477 | status = wlan_hdd_validate_context(pHddCtx); |
| 2478 | |
| 2479 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2480 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2481 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2482 | "%s: HDD context is not valid", __func__); |
| 2483 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2484 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2485 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2486 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2487 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2488 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2489 | { |
| 2490 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2491 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2492 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2493 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2494 | if (!old) |
| 2495 | return -ENOENT; |
| 2496 | |
| 2497 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2498 | |
| 2499 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2500 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2501 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2502 | return -EINVAL; |
| 2503 | } |
| 2504 | |
| 2505 | pAdapter->sessionCtx.ap.beacon = new; |
| 2506 | |
| 2507 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2508 | } |
| 2509 | |
| 2510 | EXIT(); |
| 2511 | return status; |
| 2512 | } |
| 2513 | |
| 2514 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2515 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2516 | |
| 2517 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2518 | struct net_device *dev, |
| 2519 | struct bss_parameters *params) |
| 2520 | { |
| 2521 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2522 | |
| 2523 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2524 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2525 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2526 | __func__,pAdapter->device_mode); |
| 2527 | |
| 2528 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2529 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2530 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2531 | { |
| 2532 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2533 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2534 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2535 | { |
| 2536 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2537 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2538 | } |
| 2539 | |
| 2540 | EXIT(); |
| 2541 | return 0; |
| 2542 | } |
| 2543 | |
| 2544 | /* |
| 2545 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2546 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2547 | */ |
| 2548 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2549 | struct net_device *ndev, |
| 2550 | enum nl80211_iftype type, |
| 2551 | u32 *flags, |
| 2552 | struct vif_params *params |
| 2553 | ) |
| 2554 | { |
| 2555 | struct wireless_dev *wdev; |
| 2556 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2557 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2558 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2559 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2560 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2561 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2562 | eMib_dot11DesiredBssType connectedBssType; |
| 2563 | VOS_STATUS status; |
| 2564 | |
| 2565 | ENTER(); |
| 2566 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2567 | status = wlan_hdd_validate_context(pHddCtx); |
| 2568 | |
| 2569 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2570 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2571 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2572 | "%s: HDD context is not valid", __func__); |
| 2573 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2574 | } |
| 2575 | |
| 2576 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2577 | __func__, pAdapter->device_mode); |
| 2578 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2579 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2580 | wdev = ndev->ieee80211_ptr; |
| 2581 | |
| 2582 | #ifdef WLAN_BTAMP_FEATURE |
| 2583 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2584 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2585 | (NL80211_IFTYPE_AP == type)|| |
| 2586 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2587 | { |
| 2588 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2589 | // stop AMP traffic |
| 2590 | status = WLANBAP_StopAmp(); |
| 2591 | if(VOS_STATUS_SUCCESS != status ) |
| 2592 | { |
| 2593 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2594 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2595 | "%s: Failed to stop AMP", __func__); |
| 2596 | return -EINVAL; |
| 2597 | } |
| 2598 | } |
| 2599 | #endif //WLAN_BTAMP_FEATURE |
| 2600 | /* Reset the current device mode bit mask*/ |
| 2601 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2602 | |
| 2603 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2604 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2605 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2606 | ) |
| 2607 | { |
| 2608 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2609 | pRoamProfile = &pWextState->roamProfile; |
| 2610 | LastBSSType = pRoamProfile->BSSType; |
| 2611 | |
| 2612 | switch (type) |
| 2613 | { |
| 2614 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2615 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2616 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2617 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2618 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2619 | #ifdef WLAN_FEATURE_11AC |
| 2620 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2621 | { |
| 2622 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2623 | } |
| 2624 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2625 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2626 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2627 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2628 | //Check for sub-string p2p to confirm its a p2p interface |
| 2629 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2630 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2631 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2632 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2633 | } |
| 2634 | else |
| 2635 | { |
| 2636 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2637 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2638 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2639 | #ifdef FEATURE_WLAN_TDLS |
| 2640 | /* The open adapter for the p2p shall skip initializations in |
| 2641 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 2642 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 2643 | * tdls_init when the change_iface sets the device mode to |
| 2644 | * WLAN_HDD_P2P_CLIENT. |
| 2645 | */ |
| 2646 | |
| 2647 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 2648 | { |
| 2649 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 2650 | { |
| 2651 | return -EINVAL; |
| 2652 | } |
| 2653 | } |
| 2654 | #endif |
| 2655 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2656 | break; |
| 2657 | case NL80211_IFTYPE_ADHOC: |
| 2658 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2659 | "%s: setting interface Type to ADHOC", __func__); |
| 2660 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2661 | pRoamProfile->phyMode = |
| 2662 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2663 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2664 | wdev->iftype = type; |
| 2665 | break; |
| 2666 | |
| 2667 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2668 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2669 | { |
| 2670 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2671 | "%s: setting interface Type to %s", __func__, |
| 2672 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2673 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2674 | //Cancel any remain on channel for GO mode |
| 2675 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2676 | { |
| 2677 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2678 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2679 | if (NL80211_IFTYPE_AP == type) |
| 2680 | { |
| 2681 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2682 | * address. This will take one HW STA and the max number of clients |
| 2683 | * that can connect to softAP will be reduced by one. so while changing |
| 2684 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2685 | * interface as it is not required in SoftAP mode. |
| 2686 | */ |
| 2687 | |
| 2688 | // Get P2P Adapter |
| 2689 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2690 | |
| 2691 | if (pP2pAdapter) |
| 2692 | { |
| 2693 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2694 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2695 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2696 | } |
| 2697 | } |
| 2698 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2699 | //De-init the adapter. |
| 2700 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2701 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2702 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2703 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2704 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2705 | |
| 2706 | //Disable BMPS and IMPS if enabled |
| 2707 | //before starting Go |
| 2708 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2709 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2710 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2711 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2712 | { |
| 2713 | //Fail to Exit BMPS |
| 2714 | VOS_ASSERT(0); |
| 2715 | } |
| 2716 | } |
| 2717 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2718 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2719 | (pConfig->apRandomBssidEnabled)) |
| 2720 | { |
| 2721 | /* To meet Android requirements create a randomized |
| 2722 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2723 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2724 | ndev->dev_addr[0] = 0x02; |
| 2725 | ndev->dev_addr[1] = 0x1A; |
| 2726 | ndev->dev_addr[2] = 0x11; |
| 2727 | ndev->dev_addr[3] |= 0xF0; |
| 2728 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2729 | VOS_MAC_ADDR_SIZE); |
| 2730 | pr_info("wlan: Generated HotSpot BSSID " |
| 2731 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2732 | ndev->dev_addr[0], |
| 2733 | ndev->dev_addr[1], |
| 2734 | ndev->dev_addr[2], |
| 2735 | ndev->dev_addr[3], |
| 2736 | ndev->dev_addr[4], |
| 2737 | ndev->dev_addr[5]); |
| 2738 | } |
| 2739 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2740 | hdd_set_ap_ops( pAdapter->dev ); |
| 2741 | |
| 2742 | status = hdd_init_ap_mode(pAdapter); |
| 2743 | if(status != VOS_STATUS_SUCCESS) |
| 2744 | { |
| 2745 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2746 | "%s: Error initializing the ap mode", __func__); |
| 2747 | return -EINVAL; |
| 2748 | } |
| 2749 | hdd_set_conparam(1); |
| 2750 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2751 | /*interface type changed update in wiphy structure*/ |
| 2752 | if(wdev) |
| 2753 | { |
| 2754 | wdev->iftype = type; |
| 2755 | pHddCtx->change_iface = type; |
| 2756 | } |
| 2757 | else |
| 2758 | { |
| 2759 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2760 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2761 | return -EINVAL; |
| 2762 | } |
| 2763 | goto done; |
| 2764 | } |
| 2765 | |
| 2766 | default: |
| 2767 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2768 | __func__); |
| 2769 | return -EOPNOTSUPP; |
| 2770 | } |
| 2771 | } |
| 2772 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2773 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2774 | ) |
| 2775 | { |
| 2776 | switch(type) |
| 2777 | { |
| 2778 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2779 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2780 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2781 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2782 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2783 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2784 | //Check for sub-string p2p to confirm its a p2p interface |
| 2785 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2786 | { |
| 2787 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2788 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2789 | } |
| 2790 | else |
| 2791 | { |
| 2792 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2793 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2794 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2795 | hdd_set_conparam(0); |
| 2796 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2797 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2798 | hdd_set_station_ops( pAdapter->dev ); |
| 2799 | status = hdd_init_station_mode( pAdapter ); |
| 2800 | if( VOS_STATUS_SUCCESS != status ) |
| 2801 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2802 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2803 | * This is the right place to enable back bmps_imps() |
| 2804 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 2805 | if (pHddCtx->hdd_wlan_suspended) |
| 2806 | { |
| 2807 | hdd_set_pwrparams(pHddCtx); |
| 2808 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2809 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2810 | goto done; |
| 2811 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2812 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2813 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2814 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2815 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2816 | goto done; |
| 2817 | default: |
| 2818 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2819 | __func__); |
| 2820 | return -EOPNOTSUPP; |
| 2821 | |
| 2822 | } |
| 2823 | |
| 2824 | } |
| 2825 | else |
| 2826 | { |
| 2827 | return -EOPNOTSUPP; |
| 2828 | } |
| 2829 | |
| 2830 | |
| 2831 | if(pRoamProfile) |
| 2832 | { |
| 2833 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2834 | { |
| 2835 | /*interface type changed update in wiphy structure*/ |
| 2836 | wdev->iftype = type; |
| 2837 | |
| 2838 | /*the BSS mode changed, We need to issue disconnect |
| 2839 | if connected or in IBSS disconnect state*/ |
| 2840 | if ( hdd_connGetConnectedBssType( |
| 2841 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2842 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2843 | { |
| 2844 | /*need to issue a disconnect to CSR.*/ |
| 2845 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2846 | if( eHAL_STATUS_SUCCESS == |
| 2847 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2848 | pAdapter->sessionId, |
| 2849 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2850 | { |
| 2851 | wait_for_completion_interruptible_timeout( |
| 2852 | &pAdapter->disconnect_comp_var, |
| 2853 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2854 | } |
| 2855 | } |
| 2856 | } |
| 2857 | } |
| 2858 | |
| 2859 | done: |
| 2860 | /*set bitmask based on updated value*/ |
| 2861 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 2862 | |
| 2863 | /* Only STA mode support TM now |
| 2864 | * all other mode, TM feature should be disabled */ |
| 2865 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 2866 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 2867 | { |
| 2868 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 2869 | } |
| 2870 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2871 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2872 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2873 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2874 | { |
| 2875 | //we are ok to do AMP |
| 2876 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2877 | } |
| 2878 | #endif //WLAN_BTAMP_FEATURE |
| 2879 | EXIT(); |
| 2880 | return 0; |
| 2881 | } |
| 2882 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2883 | #ifdef FEATURE_WLAN_TDLS |
| 2884 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2885 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2886 | { |
| 2887 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2888 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2889 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2890 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2891 | |
| 2892 | ENTER(); |
| 2893 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2894 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2895 | { |
| 2896 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2897 | "Invalid arguments"); |
| 2898 | return -EINVAL; |
| 2899 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2900 | |
| 2901 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2902 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2903 | { |
| 2904 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2905 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2906 | MAC_ADDRESS_STR " Request declined.", |
| 2907 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2908 | return -ENOTSUPP; |
| 2909 | } |
| 2910 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2911 | if (pHddCtx->isLogpInProgress) |
| 2912 | { |
| 2913 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2914 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2915 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2916 | return -EBUSY; |
| 2917 | } |
| 2918 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2919 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2920 | |
| 2921 | if ( NULL == pTdlsPeer ) { |
| 2922 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2923 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2924 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2925 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2926 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2927 | |
| 2928 | /* in add station, we accept existing valid staId if there is */ |
| 2929 | if ((0 == update) && |
| 2930 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2931 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2932 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2933 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2934 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2935 | " link_status %d. staId %d. add station ignored.", |
| 2936 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2937 | return 0; |
| 2938 | } |
| 2939 | /* in change station, we accept only when staId is valid */ |
| 2940 | if ((1 == update) && |
| 2941 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2942 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2943 | { |
| 2944 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2945 | "%s: " MAC_ADDRESS_STR |
| 2946 | " link status %d. staId %d. change station %s.", |
| 2947 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2948 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2949 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2950 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2951 | |
| 2952 | /* 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] | 2953 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2954 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2955 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2956 | "%s: " MAC_ADDRESS_STR |
| 2957 | " TDLS setup is ongoing. Request declined.", |
| 2958 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2959 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2960 | } |
| 2961 | |
| 2962 | /* first to check if we reached to maximum supported TDLS peer. |
| 2963 | TODO: for now, return -EPERM looks working fine, |
| 2964 | but need to check if any other errno fit into this category.*/ |
| 2965 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2966 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2967 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2968 | "%s: " MAC_ADDRESS_STR |
| 2969 | " TDLS Max peer already connected. Request declined.", |
| 2970 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2971 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2972 | } |
| 2973 | else |
| 2974 | { |
| 2975 | hddTdlsPeer_t *pTdlsPeer; |
| 2976 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2977 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2978 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2979 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2980 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2981 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2982 | return -EPERM; |
| 2983 | } |
| 2984 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2985 | if (0 == update) |
| 2986 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2987 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2988 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2989 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2990 | { |
| 2991 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2992 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2993 | if(StaParams->htcap_present) |
| 2994 | { |
| 2995 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2996 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 2997 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2998 | "ht_capa->extended_capabilities: %0x", |
| 2999 | StaParams->HTCap.extendedHtCapInfo); |
| 3000 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3001 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3002 | "params->capability: %0x",StaParams->capability); |
| 3003 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3004 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3005 | if(StaParams->vhtcap_present) |
| 3006 | { |
| 3007 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3008 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 3009 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 3010 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 3011 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3012 | { |
| 3013 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3014 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3015 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 3016 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3017 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 3018 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3019 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3020 | else if ((1 == update) && (NULL == StaParams)) |
| 3021 | { |
| 3022 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3023 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 3024 | return -EPERM; |
| 3025 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3026 | |
| 3027 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 3028 | |
| 3029 | if (!update) |
| 3030 | { |
| 3031 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3032 | pAdapter->sessionId, mac); |
| 3033 | } |
| 3034 | else |
| 3035 | { |
| 3036 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3037 | pAdapter->sessionId, mac, StaParams); |
| 3038 | } |
| 3039 | |
| 3040 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 3041 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 3042 | |
| 3043 | if (!status) |
| 3044 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3045 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3046 | "%s: timeout waiting for tdls add station indication", |
| 3047 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3048 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3049 | } |
| 3050 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 3051 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3052 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3053 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3054 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3055 | } |
| 3056 | |
| 3057 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3058 | |
| 3059 | error: |
| 3060 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 3061 | return -EPERM; |
| 3062 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3063 | } |
| 3064 | #endif |
| 3065 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3066 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 3067 | struct net_device *dev, |
| 3068 | u8 *mac, |
| 3069 | struct station_parameters *params) |
| 3070 | { |
| 3071 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 3072 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3073 | hdd_context_t *pHddCtx; |
| 3074 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3075 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3076 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3077 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3078 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3079 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3080 | ENTER(); |
| 3081 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3082 | if ((NULL == pAdapter)) |
| 3083 | { |
| 3084 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3085 | "invalid adapter "); |
| 3086 | return -EINVAL; |
| 3087 | } |
| 3088 | |
| 3089 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3090 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3091 | |
| 3092 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 3093 | { |
| 3094 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3095 | "invalid HDD state or HDD station context"); |
| 3096 | return -EINVAL; |
| 3097 | } |
| 3098 | |
| 3099 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3100 | { |
| 3101 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3102 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3103 | return -EAGAIN; |
| 3104 | } |
| 3105 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3106 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 3107 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3108 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 3109 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3110 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3111 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3112 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3113 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3114 | WLANTL_STA_AUTHENTICATED); |
| 3115 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3116 | if (status != VOS_STATUS_SUCCESS) |
| 3117 | { |
| 3118 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3119 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3120 | return -EINVAL; |
| 3121 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3122 | } |
| 3123 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3124 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3125 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3126 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3127 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3128 | StaParams.capability = params->capability; |
| 3129 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3130 | StaParams.max_sp = params->max_sp; |
| 3131 | |
| 3132 | if (0 != params->ext_capab_len) |
| 3133 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3134 | sizeof(StaParams.extn_capability)); |
| 3135 | |
| 3136 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3137 | { |
| 3138 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3139 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3140 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3141 | |
| 3142 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3143 | |
| 3144 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3145 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3146 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3147 | * modified to send more rates. |
| 3148 | */ |
| 3149 | |
| 3150 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3151 | */ |
| 3152 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3153 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3154 | |
| 3155 | if (0 != StaParams.supported_rates_len) { |
| 3156 | int i = 0; |
| 3157 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3158 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3159 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3160 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3161 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3162 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3163 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3164 | } |
| 3165 | |
| 3166 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3167 | { |
| 3168 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3169 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3170 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3171 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3172 | if (0 != params->ext_capab_len ) { |
| 3173 | /*Define A Macro : TODO Sunil*/ |
| 3174 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3175 | isBufSta = 1; |
| 3176 | } |
| 3177 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3178 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues, |
| 3179 | params->max_sp, isBufSta); |
| 3180 | if (VOS_STATUS_SUCCESS != status) { |
| 3181 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3182 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3183 | return -EINVAL; |
| 3184 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3185 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3186 | |
| 3187 | if (VOS_STATUS_SUCCESS != status) { |
| 3188 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3189 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3190 | return -EINVAL; |
| 3191 | } |
| 3192 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3193 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3194 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3195 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3196 | return status; |
| 3197 | } |
| 3198 | |
| 3199 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3200 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3201 | * This function is used to initialize the key information |
| 3202 | */ |
| 3203 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3204 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3205 | struct net_device *ndev, |
| 3206 | u8 key_index, bool pairwise, |
| 3207 | const u8 *mac_addr, |
| 3208 | struct key_params *params |
| 3209 | ) |
| 3210 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3211 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3212 | struct net_device *ndev, |
| 3213 | u8 key_index, const u8 *mac_addr, |
| 3214 | struct key_params *params |
| 3215 | ) |
| 3216 | #endif |
| 3217 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3218 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3219 | tCsrRoamSetKey setKey; |
| 3220 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3221 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3222 | v_U32_t roamId= 0xFF; |
| 3223 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3224 | hdd_hostapd_state_t *pHostapdState; |
| 3225 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3226 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3227 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3228 | |
| 3229 | ENTER(); |
| 3230 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3231 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3232 | status = wlan_hdd_validate_context(pHddCtx); |
| 3233 | |
| 3234 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3235 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3236 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3237 | "%s: HDD context is not valid", __func__); |
| 3238 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3239 | } |
| 3240 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3241 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3242 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3243 | |
| 3244 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3245 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3246 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3247 | key_index); |
| 3248 | |
| 3249 | return -EINVAL; |
| 3250 | } |
| 3251 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3252 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3253 | { |
| 3254 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3255 | params->key_len); |
| 3256 | |
| 3257 | return -EINVAL; |
| 3258 | } |
| 3259 | |
| 3260 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3261 | "%s: called with key index = %d & key length %d", |
| 3262 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3263 | |
| 3264 | /*extract key idx, key len and key*/ |
| 3265 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3266 | setKey.keyId = key_index; |
| 3267 | setKey.keyLength = params->key_len; |
| 3268 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3269 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3270 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3271 | { |
| 3272 | case WLAN_CIPHER_SUITE_WEP40: |
| 3273 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3274 | break; |
| 3275 | |
| 3276 | case WLAN_CIPHER_SUITE_WEP104: |
| 3277 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3278 | break; |
| 3279 | |
| 3280 | case WLAN_CIPHER_SUITE_TKIP: |
| 3281 | { |
| 3282 | u8 *pKey = &setKey.Key[0]; |
| 3283 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3284 | |
| 3285 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3286 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3287 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3288 | |
| 3289 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3290 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3291 | |--------------|----------|----------| |
| 3292 | <---16bytes---><--8bytes--><--8bytes--> |
| 3293 | |
| 3294 | */ |
| 3295 | /*Sme expects the 32 bytes key to be in the below order |
| 3296 | |
| 3297 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3298 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3299 | |--------------|----------|----------| |
| 3300 | <---16bytes---><--8bytes--><--8bytes--> |
| 3301 | */ |
| 3302 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3303 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3304 | |
| 3305 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3306 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3307 | |
| 3308 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3309 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3310 | |
| 3311 | |
| 3312 | break; |
| 3313 | } |
| 3314 | |
| 3315 | case WLAN_CIPHER_SUITE_CCMP: |
| 3316 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3317 | break; |
| 3318 | |
| 3319 | #ifdef FEATURE_WLAN_WAPI |
| 3320 | case WLAN_CIPHER_SUITE_SMS4: |
| 3321 | { |
| 3322 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3323 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3324 | params->key, params->key_len); |
| 3325 | return 0; |
| 3326 | } |
| 3327 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3328 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3329 | #ifdef FEATURE_WLAN_CCX |
| 3330 | case WLAN_CIPHER_SUITE_KRK: |
| 3331 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3332 | break; |
| 3333 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3334 | |
| 3335 | #ifdef WLAN_FEATURE_11W |
| 3336 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3337 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3338 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3339 | #endif |
| 3340 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3341 | default: |
| 3342 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3343 | __func__, params->cipher); |
| 3344 | return -EOPNOTSUPP; |
| 3345 | } |
| 3346 | |
| 3347 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3348 | __func__, setKey.encType); |
| 3349 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3350 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3351 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3352 | (!pairwise) |
| 3353 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3354 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3355 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3356 | ) |
| 3357 | { |
| 3358 | /* set group key*/ |
| 3359 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3360 | "%s- %d: setting Broadcast key", |
| 3361 | __func__, __LINE__); |
| 3362 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3363 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3364 | } |
| 3365 | else |
| 3366 | { |
| 3367 | /* set pairwise key*/ |
| 3368 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3369 | "%s- %d: setting pairwise key", |
| 3370 | __func__, __LINE__); |
| 3371 | setKey.keyDirection = eSIR_TX_RX; |
| 3372 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3373 | } |
| 3374 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3375 | { |
| 3376 | setKey.keyDirection = eSIR_TX_RX; |
| 3377 | /*Set the group key*/ |
| 3378 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3379 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3380 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3381 | if ( 0 != status ) |
| 3382 | { |
| 3383 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3384 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3385 | return -EINVAL; |
| 3386 | } |
| 3387 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3388 | the PTK after peer joins the IBSS network*/ |
| 3389 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3390 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3391 | return status; |
| 3392 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3393 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3394 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3395 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3396 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3397 | if( pHostapdState->bssState == BSS_START ) |
| 3398 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3399 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3400 | |
| 3401 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3402 | { |
| 3403 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3404 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3405 | __LINE__, status ); |
| 3406 | } |
| 3407 | } |
| 3408 | |
| 3409 | /* Saving WEP keys */ |
| 3410 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3411 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3412 | { |
| 3413 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3414 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3415 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3416 | } |
| 3417 | else |
| 3418 | { |
| 3419 | //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] | 3420 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3421 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3422 | } |
| 3423 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3424 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3425 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3426 | { |
| 3427 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3428 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3429 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3430 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3431 | if (!pairwise) |
| 3432 | #else |
| 3433 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3434 | #endif |
| 3435 | { |
| 3436 | /* set group key*/ |
| 3437 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3438 | { |
| 3439 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3440 | "%s- %d: Perform Set key Complete", |
| 3441 | __func__, __LINE__); |
| 3442 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3443 | } |
| 3444 | } |
| 3445 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3446 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3447 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3448 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3449 | |
| 3450 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3451 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3452 | params->key, params->key_len); |
| 3453 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3454 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3455 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3456 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3457 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3458 | "%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] | 3459 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3460 | setKey.peerMac[2], setKey.peerMac[3], |
| 3461 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3462 | setKey.keyDirection); |
| 3463 | |
| 3464 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3465 | |
| 3466 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3467 | { |
| 3468 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3469 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3470 | __LINE__, vos_status ); |
| 3471 | |
| 3472 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3473 | |
| 3474 | return -EINVAL; |
| 3475 | |
| 3476 | } |
| 3477 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3478 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3479 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3480 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3481 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3482 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3483 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3484 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3485 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3486 | "%s: Update PreAuth Key success", __func__); |
| 3487 | return 0; |
| 3488 | } |
| 3489 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3490 | { |
| 3491 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3492 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3493 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3494 | } |
| 3495 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3496 | |
| 3497 | /* issue set key request to SME*/ |
| 3498 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3499 | pAdapter->sessionId, &setKey, &roamId ); |
| 3500 | |
| 3501 | if ( 0 != status ) |
| 3502 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3503 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3504 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3505 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3506 | return -EINVAL; |
| 3507 | } |
| 3508 | |
| 3509 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3510 | /* in case of IBSS as there was no information available about WEP keys during |
| 3511 | * 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] | 3512 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3513 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3514 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3515 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3516 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3517 | ) |
| 3518 | && |
| 3519 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3520 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3521 | ) |
| 3522 | ) |
| 3523 | { |
| 3524 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3525 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3526 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3527 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3528 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3529 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3530 | setKey.peerMac[2], setKey.peerMac[3], |
| 3531 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3532 | setKey.keyDirection); |
| 3533 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3534 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3535 | pAdapter->sessionId, &setKey, &roamId ); |
| 3536 | |
| 3537 | if ( 0 != status ) |
| 3538 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3539 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3540 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3541 | __func__, status); |
| 3542 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3543 | return -EINVAL; |
| 3544 | } |
| 3545 | } |
| 3546 | } |
| 3547 | |
| 3548 | return 0; |
| 3549 | } |
| 3550 | |
| 3551 | /* |
| 3552 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3553 | * This function is used to get the key information |
| 3554 | */ |
| 3555 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3556 | static int wlan_hdd_cfg80211_get_key( |
| 3557 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3558 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3559 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3560 | const u8 *mac_addr, void *cookie, |
| 3561 | void (*callback)(void *cookie, struct key_params*) |
| 3562 | ) |
| 3563 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3564 | static int wlan_hdd_cfg80211_get_key( |
| 3565 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3566 | struct net_device *ndev, |
| 3567 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3568 | void (*callback)(void *cookie, struct key_params*) |
| 3569 | ) |
| 3570 | #endif |
| 3571 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3572 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3573 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3574 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3575 | struct key_params params; |
| 3576 | |
| 3577 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3578 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3579 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3580 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3581 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3582 | memset(¶ms, 0, sizeof(params)); |
| 3583 | |
| 3584 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3585 | { |
| 3586 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3587 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3588 | |
| 3589 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3590 | { |
| 3591 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3592 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3593 | break; |
| 3594 | |
| 3595 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3596 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3597 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3598 | break; |
| 3599 | |
| 3600 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3601 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3602 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3603 | break; |
| 3604 | |
| 3605 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3606 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3607 | break; |
| 3608 | |
| 3609 | case eCSR_ENCRYPT_TYPE_AES: |
| 3610 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3611 | break; |
| 3612 | |
| 3613 | default: |
| 3614 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3615 | break; |
| 3616 | } |
| 3617 | |
| 3618 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3619 | params.seq_len = 0; |
| 3620 | params.seq = NULL; |
| 3621 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3622 | callback(cookie, ¶ms); |
| 3623 | return 0; |
| 3624 | } |
| 3625 | |
| 3626 | /* |
| 3627 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3628 | * This function is used to delete the key information |
| 3629 | */ |
| 3630 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3631 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3632 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3633 | u8 key_index, |
| 3634 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3635 | const u8 *mac_addr |
| 3636 | ) |
| 3637 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3638 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3639 | struct net_device *ndev, |
| 3640 | u8 key_index, |
| 3641 | const u8 *mac_addr |
| 3642 | ) |
| 3643 | #endif |
| 3644 | { |
| 3645 | int status = 0; |
| 3646 | |
| 3647 | //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] | 3648 | //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] | 3649 | //it is observed that this is invalidating peer |
| 3650 | //key index whenever re-key is done. This is affecting data link. |
| 3651 | //It should be ok to ignore del_key. |
| 3652 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3653 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3654 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3655 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3656 | tCsrRoamSetKey setKey; |
| 3657 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3658 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3659 | ENTER(); |
| 3660 | |
| 3661 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3662 | __func__,pAdapter->device_mode); |
| 3663 | |
| 3664 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3665 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3666 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3667 | key_index); |
| 3668 | |
| 3669 | return -EINVAL; |
| 3670 | } |
| 3671 | |
| 3672 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3673 | setKey.keyId = key_index; |
| 3674 | |
| 3675 | if (mac_addr) |
| 3676 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3677 | else |
| 3678 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3679 | |
| 3680 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3681 | |
| 3682 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3683 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3684 | ) |
| 3685 | { |
| 3686 | |
| 3687 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3688 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3689 | if( pHostapdState->bssState == BSS_START) |
| 3690 | { |
| 3691 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3692 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3693 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3694 | { |
| 3695 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3696 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3697 | __LINE__, status ); |
| 3698 | } |
| 3699 | } |
| 3700 | } |
| 3701 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3702 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3703 | ) |
| 3704 | { |
| 3705 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3706 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3707 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3708 | |
| 3709 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3710 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3711 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3712 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3713 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3714 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3715 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3716 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3717 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3718 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3719 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3720 | if ( 0 != status ) |
| 3721 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3722 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3723 | "%s: sme_RoamSetKey failure, returned %d", |
| 3724 | __func__, status); |
| 3725 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3726 | return -EINVAL; |
| 3727 | } |
| 3728 | } |
| 3729 | } |
| 3730 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3731 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3732 | return status; |
| 3733 | } |
| 3734 | |
| 3735 | /* |
| 3736 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3737 | * This function is used to set the default tx key index |
| 3738 | */ |
| 3739 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3740 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3741 | struct net_device *ndev, |
| 3742 | u8 key_index, |
| 3743 | bool unicast, bool multicast) |
| 3744 | #else |
| 3745 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3746 | struct net_device *ndev, |
| 3747 | u8 key_index) |
| 3748 | #endif |
| 3749 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3750 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3751 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3752 | hdd_wext_state_t *pWextState; |
| 3753 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3754 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3755 | |
| 3756 | ENTER(); |
| 3757 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3758 | if ((NULL == pAdapter)) |
| 3759 | { |
| 3760 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3761 | "invalid adapter"); |
| 3762 | return -EINVAL; |
| 3763 | } |
| 3764 | |
| 3765 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3766 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3767 | |
| 3768 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3769 | { |
| 3770 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3771 | "invalid Wext state or HDD context"); |
| 3772 | return -EINVAL; |
| 3773 | } |
| 3774 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3775 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3776 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3777 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3778 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3779 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3780 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3781 | key_index); |
| 3782 | |
| 3783 | return -EINVAL; |
| 3784 | } |
| 3785 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3786 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3787 | status = wlan_hdd_validate_context(pHddCtx); |
| 3788 | |
| 3789 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3790 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3791 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3792 | "%s: HDD context is not valid", __func__); |
| 3793 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3794 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3795 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3796 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3797 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3798 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3799 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3800 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3801 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3802 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3803 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3804 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3805 | { |
| 3806 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3807 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3809 | tCsrRoamSetKey setKey; |
| 3810 | v_U32_t roamId= 0xFF; |
| 3811 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3812 | |
| 3813 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3814 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3815 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3816 | Keys->defaultIndex = (u8)key_index; |
| 3817 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3818 | setKey.keyId = key_index; |
| 3819 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3820 | |
| 3821 | vos_mem_copy(&setKey.Key[0], |
| 3822 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3823 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3824 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3825 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3826 | |
| 3827 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3828 | &pHddStaCtx->conn_info.bssId[0], |
| 3829 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3830 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3831 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3832 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3833 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3834 | { |
| 3835 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3836 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3837 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3838 | type(104) and switching encryption type to 40*/ |
| 3839 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3840 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3841 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3842 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3843 | } |
| 3844 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3845 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3846 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3847 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3848 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3849 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3850 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3852 | if ( 0 != status ) |
| 3853 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3854 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3855 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3856 | status); |
| 3857 | return -EINVAL; |
| 3858 | } |
| 3859 | } |
| 3860 | } |
| 3861 | |
| 3862 | /* In SoftAp mode setting key direction for default mode */ |
| 3863 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3864 | { |
| 3865 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3866 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3867 | (eCSR_ENCRYPT_TYPE_AES != |
| 3868 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3869 | ) |
| 3870 | { |
| 3871 | /* Saving key direction for default key index to TX default */ |
| 3872 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3873 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3874 | } |
| 3875 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3877 | return status; |
| 3878 | } |
| 3879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3880 | /* |
| 3881 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3882 | * This function is used to inform the BSS details to nl80211 interface. |
| 3883 | */ |
| 3884 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3885 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3886 | { |
| 3887 | struct net_device *dev = pAdapter->dev; |
| 3888 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3889 | struct wiphy *wiphy = wdev->wiphy; |
| 3890 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3891 | int chan_no; |
| 3892 | int ie_length; |
| 3893 | const char *ie; |
| 3894 | unsigned int freq; |
| 3895 | struct ieee80211_channel *chan; |
| 3896 | int rssi = 0; |
| 3897 | struct cfg80211_bss *bss = NULL; |
| 3898 | |
| 3899 | ENTER(); |
| 3900 | |
| 3901 | if( NULL == pBssDesc ) |
| 3902 | { |
| 3903 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3904 | return bss; |
| 3905 | } |
| 3906 | |
| 3907 | chan_no = pBssDesc->channelId; |
| 3908 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3909 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3910 | |
| 3911 | if( NULL == ie ) |
| 3912 | { |
| 3913 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3914 | return bss; |
| 3915 | } |
| 3916 | |
| 3917 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3918 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3919 | { |
| 3920 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3921 | } |
| 3922 | else |
| 3923 | { |
| 3924 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3925 | } |
| 3926 | #else |
| 3927 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3928 | #endif |
| 3929 | |
| 3930 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3931 | |
| 3932 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3933 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3934 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3935 | if (bss == NULL) |
| 3936 | { |
| 3937 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3938 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3939 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3940 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3941 | pBssDesc->capabilityInfo, |
| 3942 | pBssDesc->beaconInterval, ie, ie_length, |
| 3943 | rssi, GFP_KERNEL )); |
| 3944 | } |
| 3945 | else |
| 3946 | { |
| 3947 | return bss; |
| 3948 | } |
| 3949 | } |
| 3950 | |
| 3951 | |
| 3952 | |
| 3953 | /* |
| 3954 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3955 | * This function is used to inform the BSS details to nl80211 interface. |
| 3956 | */ |
| 3957 | struct cfg80211_bss* |
| 3958 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3959 | tSirBssDescription *bss_desc |
| 3960 | ) |
| 3961 | { |
| 3962 | /* |
| 3963 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3964 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3965 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3966 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3967 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3968 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3969 | cfg80211_inform_bss_frame. |
| 3970 | */ |
| 3971 | struct net_device *dev = pAdapter->dev; |
| 3972 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3973 | struct wiphy *wiphy = wdev->wiphy; |
| 3974 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3975 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3976 | qcom_ie_age *qie_age = NULL; |
| 3977 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3978 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3979 | 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] | 3980 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3981 | const char *ie = |
| 3982 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3983 | unsigned int freq; |
| 3984 | struct ieee80211_channel *chan; |
| 3985 | struct ieee80211_mgmt *mgmt = |
| 3986 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 3987 | struct cfg80211_bss *bss_status = NULL; |
| 3988 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 3989 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3990 | #ifdef WLAN_OPEN_SOURCE |
| 3991 | struct timespec ts; |
| 3992 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3993 | |
| 3994 | ENTER(); |
| 3995 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 3996 | if (!mgmt) |
| 3997 | return NULL; |
| 3998 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3999 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4000 | |
| 4001 | #ifdef WLAN_OPEN_SOURCE |
| 4002 | /* Android does not want the timestamp from the frame. |
| 4003 | Instead it wants a monotonic increasing value */ |
| 4004 | get_monotonic_boottime(&ts); |
| 4005 | mgmt->u.probe_resp.timestamp = |
| 4006 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 4007 | #else |
| 4008 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4009 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 4010 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4011 | |
| 4012 | #endif |
| 4013 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4014 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 4015 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4016 | |
| 4017 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4018 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 4019 | /* Assuming this is the last IE, copy at the end */ |
| 4020 | ie_length -=sizeof(qcom_ie_age); |
| 4021 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 4022 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 4023 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 4024 | qie_age->oui_1 = QCOM_OUI1; |
| 4025 | qie_age->oui_2 = QCOM_OUI2; |
| 4026 | qie_age->oui_3 = QCOM_OUI3; |
| 4027 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 4028 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 4029 | #endif |
| 4030 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4031 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 4032 | if (bss_desc->fProbeRsp) |
| 4033 | { |
| 4034 | mgmt->frame_control |= |
| 4035 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 4036 | } |
| 4037 | else |
| 4038 | { |
| 4039 | mgmt->frame_control |= |
| 4040 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 4041 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4042 | |
| 4043 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4044 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4045 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 4046 | { |
| 4047 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4048 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4049 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4050 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 4051 | |
| 4052 | { |
| 4053 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4054 | } |
| 4055 | else |
| 4056 | { |
| 4057 | kfree(mgmt); |
| 4058 | return NULL; |
| 4059 | } |
| 4060 | #else |
| 4061 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4062 | #endif |
| 4063 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4064 | /*when the band is changed on the fly using the GUI, three things are done |
| 4065 | * 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) |
| 4066 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 4067 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 4068 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 4069 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 4070 | * 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 |
| 4071 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 4072 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 4073 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 4074 | * So drop the bss and continue to next bss. |
| 4075 | */ |
| 4076 | if(chan == NULL) |
| 4077 | { |
| 4078 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 4079 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4080 | return NULL; |
| 4081 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4082 | /*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] | 4083 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4084 | * */ |
| 4085 | if (( eConnectionState_Associated == |
| 4086 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4087 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4088 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4089 | WNI_CFG_BSSID_LEN))) |
| 4090 | { |
| 4091 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4092 | rssi = (pAdapter->rssi * 100); |
| 4093 | } |
| 4094 | else |
| 4095 | { |
| 4096 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4097 | } |
| 4098 | |
| 4099 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4100 | frame_len, rssi, GFP_KERNEL); |
| 4101 | kfree(mgmt); |
| 4102 | return bss_status; |
| 4103 | } |
| 4104 | |
| 4105 | /* |
| 4106 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4107 | * This function is used to update the BSS data base of CFG8011 |
| 4108 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4109 | 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] | 4110 | tCsrRoamInfo *pRoamInfo |
| 4111 | ) |
| 4112 | { |
| 4113 | tCsrRoamConnectedProfile roamProfile; |
| 4114 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4115 | struct cfg80211_bss *bss = NULL; |
| 4116 | |
| 4117 | ENTER(); |
| 4118 | |
| 4119 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4120 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4121 | |
| 4122 | if (NULL != roamProfile.pBssDesc) |
| 4123 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4124 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4125 | &roamProfile); |
| 4126 | |
| 4127 | if (NULL == bss) |
| 4128 | { |
| 4129 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4130 | __func__); |
| 4131 | } |
| 4132 | |
| 4133 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4134 | } |
| 4135 | else |
| 4136 | { |
| 4137 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4138 | __func__); |
| 4139 | } |
| 4140 | return bss; |
| 4141 | } |
| 4142 | |
| 4143 | /* |
| 4144 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4145 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4146 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4147 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4148 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4149 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4150 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4151 | tCsrScanResultInfo *pScanResult; |
| 4152 | eHalStatus status = 0; |
| 4153 | tScanResultHandle pResult; |
| 4154 | struct cfg80211_bss *bss_status = NULL; |
| 4155 | |
| 4156 | ENTER(); |
| 4157 | |
| 4158 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4159 | { |
| 4160 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4161 | return -EAGAIN; |
| 4162 | } |
| 4163 | |
| 4164 | /* |
| 4165 | * start getting scan results and populate cgf80211 BSS database |
| 4166 | */ |
| 4167 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4168 | |
| 4169 | /* no scan results */ |
| 4170 | if (NULL == pResult) |
| 4171 | { |
| 4172 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 4173 | return status; |
| 4174 | } |
| 4175 | |
| 4176 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4177 | |
| 4178 | while (pScanResult) |
| 4179 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4180 | /* |
| 4181 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4182 | * entry already exists in bss data base of cfg80211 for that |
| 4183 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4184 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4185 | * mgmt packet as input. As of now there is no possibility to get |
| 4186 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4187 | * ieee80211_mgmt(probe response) and passing to c |
| 4188 | * fg80211_inform_bss_frame. |
| 4189 | * */ |
| 4190 | |
| 4191 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4192 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4193 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4194 | |
| 4195 | if (NULL == bss_status) |
| 4196 | { |
| 4197 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4198 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 4199 | } |
| 4200 | else |
| 4201 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4202 | cfg80211_put_bss( |
| 4203 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 4204 | wiphy, |
| 4205 | #endif |
| 4206 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4207 | } |
| 4208 | |
| 4209 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4210 | } |
| 4211 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4212 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4213 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4214 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4215 | } |
| 4216 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4217 | void |
| 4218 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4219 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4220 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4221 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4222 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 4223 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4224 | } /****** end hddPrintMacAddr() ******/ |
| 4225 | |
| 4226 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4227 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4228 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4229 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4230 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4231 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4232 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4233 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4234 | } /****** end hddPrintPmkId() ******/ |
| 4235 | |
| 4236 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4237 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4238 | |
| 4239 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4240 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4241 | |
| 4242 | #define dump_bssid(bssid) \ |
| 4243 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4244 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4245 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 4246 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4247 | } |
| 4248 | |
| 4249 | #define dump_pmkid(pMac, pmkid) \ |
| 4250 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4251 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4252 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4253 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4254 | } |
| 4255 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4256 | #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] | 4257 | /* |
| 4258 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4259 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4260 | */ |
| 4261 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4262 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4263 | int index, bool preauth ) |
| 4264 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4265 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4266 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4267 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4268 | |
| 4269 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4270 | 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] | 4271 | |
| 4272 | if( NULL == pRoamInfo ) |
| 4273 | { |
| 4274 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4275 | return -EINVAL; |
| 4276 | } |
| 4277 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4278 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4279 | { |
| 4280 | dump_bssid(pRoamInfo->bssid); |
| 4281 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4282 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4283 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4284 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4285 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4286 | } |
| 4287 | #endif //FEATURE_WLAN_LFR |
| 4288 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4289 | /* |
| 4290 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4291 | * scanning callback function, called after finishing scan |
| 4292 | * |
| 4293 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4294 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4295 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4296 | { |
| 4297 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4298 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4299 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4300 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4301 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4302 | struct cfg80211_scan_request *req = NULL; |
| 4303 | int ret = 0; |
| 4304 | |
| 4305 | ENTER(); |
| 4306 | |
| 4307 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4308 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4309 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4310 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4311 | |
| 4312 | //Block on scan req completion variable. Can't wait forever though. |
| 4313 | ret = wait_for_completion_interruptible_timeout( |
| 4314 | &pScanInfo->scan_req_completion_event, |
| 4315 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4316 | if (!ret) |
| 4317 | { |
| 4318 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4319 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4320 | } |
| 4321 | |
| 4322 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4323 | { |
| 4324 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4325 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4326 | } |
| 4327 | |
| 4328 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4329 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4330 | { |
| 4331 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4332 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4333 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4334 | (int) scanId); |
| 4335 | } |
| 4336 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4337 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4338 | pAdapter); |
| 4339 | |
| 4340 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4341 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4342 | |
| 4343 | |
| 4344 | /* If any client wait scan result through WEXT |
| 4345 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4346 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4347 | { |
| 4348 | /* The other scan request waiting for current scan finish |
| 4349 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4350 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4351 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4352 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4353 | } |
| 4354 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4355 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4356 | { |
| 4357 | struct net_device *dev = pAdapter->dev; |
| 4358 | union iwreq_data wrqu; |
| 4359 | int we_event; |
| 4360 | char *msg; |
| 4361 | |
| 4362 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4363 | we_event = SIOCGIWSCAN; |
| 4364 | msg = NULL; |
| 4365 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4366 | } |
| 4367 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4368 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4369 | |
| 4370 | /* Get the Scan Req */ |
| 4371 | req = pAdapter->request; |
| 4372 | |
| 4373 | if (!req) |
| 4374 | { |
| 4375 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4376 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4377 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4378 | } |
| 4379 | |
| 4380 | /* |
| 4381 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4382 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4383 | req->n_ssids = 0; |
| 4384 | req->n_channels = 0; |
| 4385 | req->ie = 0; |
| 4386 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4387 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4388 | /* Scan is no longer pending */ |
| 4389 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4390 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4391 | /* |
| 4392 | * cfg80211_scan_done informing NL80211 about completion |
| 4393 | * of scanning |
| 4394 | */ |
| 4395 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4396 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4397 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4398 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4399 | /* release the wake lock at the end of the scan*/ |
| 4400 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4401 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4402 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4403 | * immediatly after the driver gets connect request(i.e after scan) |
| 4404 | * from supplicant, this result in app's is suspending and not able |
| 4405 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4406 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4407 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4408 | #ifdef FEATURE_WLAN_TDLS |
| 4409 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4410 | #endif |
| 4411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4412 | EXIT(); |
| 4413 | return 0; |
| 4414 | } |
| 4415 | |
| 4416 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4417 | * FUNCTION: hdd_isScanAllowed |
| 4418 | * Go through each adapter and check if scan allowed |
| 4419 | * |
| 4420 | */ |
| 4421 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4422 | { |
| 4423 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4424 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4425 | hdd_adapter_t *pAdapter = NULL; |
| 4426 | VOS_STATUS status = 0; |
| 4427 | v_U8_t staId = 0; |
| 4428 | v_U8_t *staMac = NULL; |
| 4429 | |
Gopichand Nakkala | 8c0386c | 2013-07-09 23:31:37 +0530 | [diff] [blame] | 4430 | if (VOS_TIMER_STATE_RUNNING == |
| 4431 | vos_timer_getCurrentState(&pHddCtx->hdd_p2p_go_conn_is_in_progress)) |
| 4432 | { |
| 4433 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4434 | "%s: Connection is in progress, Do not allow the scan", __func__); |
| 4435 | return VOS_FALSE; |
| 4436 | } |
| 4437 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4438 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4439 | |
| 4440 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4441 | { |
| 4442 | pAdapter = pAdapterNode->pAdapter; |
| 4443 | |
| 4444 | if( pAdapter ) |
| 4445 | { |
| 4446 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4447 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4448 | __func__, pAdapter->device_mode); |
| 4449 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4450 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4451 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4452 | { |
| 4453 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4454 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4455 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4456 | { |
| 4457 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4458 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4459 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4460 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4461 | staMac[0], staMac[1], staMac[2], |
| 4462 | staMac[3], staMac[4], staMac[5]); |
| 4463 | return VOS_FALSE; |
| 4464 | } |
| 4465 | } |
| 4466 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4467 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4468 | { |
| 4469 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4470 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4471 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4472 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4473 | { |
| 4474 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4475 | |
| 4476 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4477 | "%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] | 4478 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4479 | staMac[0], staMac[1], staMac[2], |
| 4480 | staMac[3], staMac[4], staMac[5]); |
| 4481 | return VOS_FALSE; |
| 4482 | } |
| 4483 | } |
| 4484 | } |
| 4485 | } |
| 4486 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4487 | pAdapterNode = pNext; |
| 4488 | } |
| 4489 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4490 | "%s: Scan allowed", __func__); |
| 4491 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4492 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4493 | |
| 4494 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4495 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4496 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4497 | * later, scan dump command can be used to recieve scan results |
| 4498 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4499 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4500 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4501 | struct net_device *dev, |
| 4502 | #endif |
| 4503 | struct cfg80211_scan_request *request) |
| 4504 | { |
| 4505 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4506 | struct net_device *dev = request->wdev->netdev; |
| 4507 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4508 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4509 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4510 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4511 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4512 | tCsrScanRequest scanRequest; |
| 4513 | tANI_U8 *channelList = NULL, i; |
| 4514 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4515 | int status; |
| 4516 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4517 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4518 | |
| 4519 | ENTER(); |
| 4520 | |
| 4521 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4522 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4523 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4524 | status = wlan_hdd_validate_context(pHddCtx); |
| 4525 | |
| 4526 | if (0 != status) |
| 4527 | { |
| 4528 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4529 | "%s: HDD context is not valid", __func__); |
| 4530 | return status; |
| 4531 | } |
| 4532 | |
| 4533 | cfg_param = pHddCtx->cfg_ini; |
| 4534 | pScanInfo = &pHddCtx->scan_info; |
| 4535 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4536 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4537 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4538 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4539 | { |
| 4540 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4541 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4542 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4543 | return -EBUSY; |
| 4544 | } |
| 4545 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4546 | #ifdef WLAN_BTAMP_FEATURE |
| 4547 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4548 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4549 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4550 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4551 | "%s: No scanning when AMP is on", __func__); |
| 4552 | return -EOPNOTSUPP; |
| 4553 | } |
| 4554 | #endif |
| 4555 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4556 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4557 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4558 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4559 | "%s: Not scanning on device_mode = %d", |
| 4560 | __func__, pAdapter->device_mode); |
| 4561 | return -EOPNOTSUPP; |
| 4562 | } |
| 4563 | |
| 4564 | if (TRUE == pScanInfo->mScanPending) |
| 4565 | { |
| 4566 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4567 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4568 | } |
| 4569 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4570 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4571 | //Channel and action frame is pending |
| 4572 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4573 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4574 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4575 | { |
| 4576 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4577 | return -EBUSY; |
| 4578 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4579 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4580 | /* if tdls disagree scan right now, return immediately. |
| 4581 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4582 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4583 | */ |
| 4584 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4585 | wiphy, |
| 4586 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4587 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4588 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4589 | request); |
| 4590 | if(status <= 0) |
| 4591 | { |
| 4592 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4593 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4594 | } |
| 4595 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4596 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4597 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4598 | { |
| 4599 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4600 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4601 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4602 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4603 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4604 | { |
| 4605 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4606 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4607 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4608 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4609 | } |
| 4610 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4611 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4612 | /* Check if scan is allowed at this point of time. |
| 4613 | */ |
| 4614 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4615 | { |
| 4616 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4617 | return -EBUSY; |
| 4618 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4619 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4620 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4621 | |
| 4622 | if (NULL != request) |
| 4623 | { |
| 4624 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4625 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4626 | |
| 4627 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4628 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4629 | * is not aging out the scan results. |
| 4630 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4631 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4632 | { |
| 4633 | request->n_ssids = 0; |
| 4634 | } |
| 4635 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4636 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4637 | { |
| 4638 | tCsrSSIDInfo *SsidInfo; |
| 4639 | int j; |
| 4640 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4641 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4642 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4643 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4644 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4645 | |
| 4646 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4647 | { |
| 4648 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4649 | "memory alloc failed SSIDInfo buffer"); |
| 4650 | return -ENOMEM; |
| 4651 | } |
| 4652 | |
| 4653 | /* copy all the ssid's and their length */ |
| 4654 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4655 | { |
| 4656 | /* get the ssid length */ |
| 4657 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4658 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4659 | SsidInfo->SSID.length); |
| 4660 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4661 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4662 | j, SsidInfo->SSID.ssId); |
| 4663 | } |
| 4664 | /* set the scan type to active */ |
| 4665 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4666 | } |
| 4667 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4668 | { |
| 4669 | /* set the scan type to active */ |
| 4670 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4671 | } |
| 4672 | else |
| 4673 | { |
| 4674 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4675 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4676 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4677 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4678 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4679 | } |
| 4680 | else |
| 4681 | { |
| 4682 | /* set the scan type to active */ |
| 4683 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4684 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4685 | |
| 4686 | /* set min and max channel time to zero */ |
| 4687 | scanRequest.minChnTime = 0; |
| 4688 | scanRequest.maxChnTime = 0; |
| 4689 | } |
| 4690 | |
| 4691 | /* set BSSType to default type */ |
| 4692 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4693 | |
| 4694 | /*TODO: scan the requested channels only*/ |
| 4695 | |
| 4696 | /*Right now scanning all the channels */ |
| 4697 | if( request ) |
| 4698 | { |
| 4699 | if( request->n_channels ) |
| 4700 | { |
| 4701 | channelList = vos_mem_malloc( request->n_channels ); |
| 4702 | if( NULL == channelList ) |
| 4703 | { |
| 4704 | status = -ENOMEM; |
| 4705 | goto free_mem; |
| 4706 | } |
| 4707 | |
| 4708 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4709 | channelList[i] = request->channels[i]->hw_value; |
| 4710 | } |
| 4711 | |
| 4712 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4713 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4714 | |
| 4715 | /* set requestType to full scan */ |
| 4716 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4717 | |
| 4718 | /* 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] | 4719 | * 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] | 4720 | * 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] | 4721 | */ |
| 4722 | |
| 4723 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4724 | * and in that case driver shoudnt flush scan results. If |
| 4725 | * driver flushes the scan results here and unfortunately if |
| 4726 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4727 | * fails which is not desired |
| 4728 | */ |
| 4729 | |
| 4730 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4731 | { |
| 4732 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4733 | pAdapter->sessionId ); |
| 4734 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4735 | |
| 4736 | if( request->ie_len ) |
| 4737 | { |
| 4738 | /* save this for future association (join requires this) */ |
| 4739 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4740 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4741 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4742 | |
| 4743 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4744 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4745 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4746 | ) |
| 4747 | { |
| 4748 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4749 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4750 | } |
| 4751 | |
| 4752 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4753 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4754 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4755 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4756 | request->ie_len); |
| 4757 | if (pP2pIe != NULL) |
| 4758 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4759 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4760 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4761 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4762 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4763 | { |
| 4764 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4765 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4766 | "Go nego completed to Connection is started"); |
| 4767 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4768 | "for 8way Handshake"); |
| 4769 | } |
| 4770 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4771 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4772 | { |
| 4773 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4774 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4775 | "Disconnected state to Connection is started"); |
| 4776 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4777 | "for 4way Handshake"); |
| 4778 | } |
| 4779 | #endif |
| 4780 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4781 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4782 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4783 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4784 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4785 | "%s: This is a P2P Search", __func__); |
| 4786 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4787 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4788 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4789 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4790 | /* set requestType to P2P Discovery */ |
| 4791 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4792 | } |
| 4793 | |
| 4794 | /* |
| 4795 | Skip Dfs Channel in case of P2P Search |
| 4796 | if it is set in ini file |
| 4797 | */ |
| 4798 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4799 | { |
| 4800 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4801 | } |
| 4802 | else |
| 4803 | { |
| 4804 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4805 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4806 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4807 | } |
| 4808 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4809 | } |
| 4810 | } |
| 4811 | |
| 4812 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4813 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4814 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4815 | * address the following issues. |
| 4816 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4817 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4818 | * for long time, this result in apps running at full power for long time. |
| 4819 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4820 | * be stuck in full power because of resume BMPS |
| 4821 | */ |
| 4822 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4823 | |
| 4824 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4825 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4826 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4827 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4828 | if (eHAL_STATUS_SUCCESS != status) |
| 4829 | { |
| 4830 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4831 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4832 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4833 | if(eHAL_STATUS_RESOURCES == status) |
| 4834 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4835 | 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] | 4836 | status = -EBUSY; |
| 4837 | } else { |
| 4838 | status = -EIO; |
| 4839 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4840 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4841 | goto free_mem; |
| 4842 | } |
| 4843 | |
| 4844 | pScanInfo->mScanPending = TRUE; |
| 4845 | pAdapter->request = request; |
| 4846 | pScanInfo->scanId = scanId; |
| 4847 | |
| 4848 | complete(&pScanInfo->scan_req_completion_event); |
| 4849 | |
| 4850 | free_mem: |
| 4851 | if( scanRequest.SSIDs.SSIDList ) |
| 4852 | { |
| 4853 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4854 | } |
| 4855 | |
| 4856 | if( channelList ) |
| 4857 | vos_mem_free( channelList ); |
| 4858 | |
| 4859 | EXIT(); |
| 4860 | |
| 4861 | return status; |
| 4862 | } |
| 4863 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4864 | |
| 4865 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 4866 | { |
| 4867 | v_U8_t iniDot11Mode = |
| 4868 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 4869 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 4870 | |
| 4871 | switch ( iniDot11Mode ) |
| 4872 | { |
| 4873 | case eHDD_DOT11_MODE_AUTO: |
| 4874 | case eHDD_DOT11_MODE_11ac: |
| 4875 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 4876 | #ifdef WLAN_FEATURE_11AC |
| 4877 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 4878 | #else |
| 4879 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4880 | #endif |
| 4881 | break; |
| 4882 | case eHDD_DOT11_MODE_11n: |
| 4883 | case eHDD_DOT11_MODE_11n_ONLY: |
| 4884 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4885 | break; |
| 4886 | default: |
| 4887 | hddDot11Mode = iniDot11Mode; |
| 4888 | break; |
| 4889 | } |
| 4890 | /* This call decides required channel bonding mode */ |
| 4891 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 4892 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 4893 | operationChannel); |
| 4894 | } |
| 4895 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4896 | /* |
| 4897 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4898 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4899 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4900 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4901 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4902 | { |
| 4903 | int status = 0; |
| 4904 | hdd_wext_state_t *pWextState; |
| 4905 | v_U32_t roamId; |
| 4906 | tCsrRoamProfile *pRoamProfile; |
| 4907 | eMib_dot11DesiredBssType connectedBssType; |
| 4908 | eCsrAuthType RSNAuthType; |
| 4909 | |
| 4910 | ENTER(); |
| 4911 | |
| 4912 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4913 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4914 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4915 | { |
| 4916 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4917 | return -EINVAL; |
| 4918 | } |
| 4919 | |
| 4920 | pRoamProfile = &pWextState->roamProfile; |
| 4921 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4922 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4923 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4924 | int ret = 0; |
| 4925 | hdd_station_ctx_t *pHddStaCtx; |
| 4926 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4927 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4928 | |
| 4929 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4930 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4931 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4932 | { |
| 4933 | /* Issue disconnect to CSR */ |
| 4934 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4935 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4936 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4937 | pAdapter->sessionId, |
| 4938 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4939 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4940 | ret = wait_for_completion_interruptible_timeout( |
| 4941 | &pAdapter->disconnect_comp_var, |
| 4942 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4943 | if (0 == ret) |
| 4944 | { |
| 4945 | VOS_ASSERT(0); |
| 4946 | } |
| 4947 | } |
| 4948 | } |
| 4949 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4950 | { |
| 4951 | ret = wait_for_completion_interruptible_timeout( |
| 4952 | &pAdapter->disconnect_comp_var, |
| 4953 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4954 | if (0 == ret) |
| 4955 | { |
| 4956 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4957 | } |
| 4958 | } |
| 4959 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4960 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4961 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4962 | { |
| 4963 | /*QoS not enabled in cfg file*/ |
| 4964 | pRoamProfile->uapsd_mask = 0; |
| 4965 | } |
| 4966 | else |
| 4967 | { |
| 4968 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4969 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4970 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4971 | } |
| 4972 | |
| 4973 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4974 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4975 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4976 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4977 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4978 | ssid, ssid_len); |
| 4979 | |
| 4980 | if (bssid) |
| 4981 | { |
| 4982 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4983 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4984 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4985 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4986 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4987 | case of join failure we should send valid BSSID to supplicant |
| 4988 | */ |
| 4989 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4990 | WNI_CFG_BSSID_LEN); |
| 4991 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 4992 | else |
| 4993 | { |
| 4994 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 4995 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4996 | |
| 4997 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 4998 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4999 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5000 | /*set gen ie*/ |
| 5001 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 5002 | /*set auth*/ |
| 5003 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 5004 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5005 | #ifdef FEATURE_WLAN_WAPI |
| 5006 | if (pAdapter->wapi_info.nWapiMode) |
| 5007 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5008 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5009 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 5010 | { |
| 5011 | case WAPI_AUTH_MODE_PSK: |
| 5012 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5013 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5014 | pAdapter->wapi_info.wapiAuthMode); |
| 5015 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5016 | break; |
| 5017 | } |
| 5018 | case WAPI_AUTH_MODE_CERT: |
| 5019 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5020 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5021 | pAdapter->wapi_info.wapiAuthMode); |
| 5022 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5023 | break; |
| 5024 | } |
| 5025 | } // End of switch |
| 5026 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 5027 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 5028 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5029 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5030 | pRoamProfile->AuthType.numEntries = 1; |
| 5031 | pRoamProfile->EncryptionType.numEntries = 1; |
| 5032 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5033 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 5034 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5035 | } |
| 5036 | } |
| 5037 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5038 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5039 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5040 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5041 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5042 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5043 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 5044 | sizeof (tSirGtkOffloadParams)); |
| 5045 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5046 | } |
| 5047 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5048 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 5049 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5050 | if( operatingChannel ) |
| 5051 | { |
| 5052 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 5053 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5054 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5055 | else |
| 5056 | { |
| 5057 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5058 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5059 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5060 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 5061 | { |
| 5062 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 5063 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5064 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 5065 | * 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] | 5066 | * 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] | 5067 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5068 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 5069 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5070 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5071 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5072 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 5073 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5074 | |
| 5075 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5076 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 5077 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5078 | if ((eHAL_STATUS_SUCCESS != status) && |
| 5079 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5080 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5081 | |
| 5082 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5083 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 5084 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 5085 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5086 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5087 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5088 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5089 | |
| 5090 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5091 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5093 | } |
| 5094 | else |
| 5095 | { |
| 5096 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 5097 | return -EINVAL; |
| 5098 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5099 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5100 | return status; |
| 5101 | } |
| 5102 | |
| 5103 | /* |
| 5104 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 5105 | * This function is used to set the authentication type (OPEN/SHARED). |
| 5106 | * |
| 5107 | */ |
| 5108 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 5109 | enum nl80211_auth_type auth_type) |
| 5110 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5111 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5112 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5113 | |
| 5114 | ENTER(); |
| 5115 | |
| 5116 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5117 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5118 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5119 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5120 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5121 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 5122 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5123 | break; |
| 5124 | |
| 5125 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5126 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5127 | case NL80211_AUTHTYPE_FT: |
| 5128 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5129 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5130 | "%s: set authentication type to OPEN", __func__); |
| 5131 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5132 | break; |
| 5133 | |
| 5134 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5135 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5136 | "%s: set authentication type to SHARED", __func__); |
| 5137 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5138 | break; |
| 5139 | #ifdef FEATURE_WLAN_CCX |
| 5140 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5141 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5142 | "%s: set authentication type to CCKM WPA", __func__); |
| 5143 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5144 | break; |
| 5145 | #endif |
| 5146 | |
| 5147 | |
| 5148 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5149 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5150 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5151 | auth_type); |
| 5152 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5153 | return -EINVAL; |
| 5154 | } |
| 5155 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5156 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5157 | pHddStaCtx->conn_info.authType; |
| 5158 | return 0; |
| 5159 | } |
| 5160 | |
| 5161 | /* |
| 5162 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5163 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5164 | * |
| 5165 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5166 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5167 | u32 key_mgmt |
| 5168 | ) |
| 5169 | { |
| 5170 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5171 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5172 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5173 | /*set key mgmt type*/ |
| 5174 | switch(key_mgmt) |
| 5175 | { |
| 5176 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5177 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5178 | case WLAN_AKM_SUITE_FT_PSK: |
| 5179 | #endif |
| 5180 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5181 | __func__); |
| 5182 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5183 | break; |
| 5184 | |
| 5185 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5186 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5187 | case WLAN_AKM_SUITE_FT_8021X: |
| 5188 | #endif |
| 5189 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5190 | __func__); |
| 5191 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5192 | break; |
| 5193 | #ifdef FEATURE_WLAN_CCX |
| 5194 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5195 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5196 | case WLAN_AKM_SUITE_CCKM: |
| 5197 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5198 | __func__); |
| 5199 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5200 | break; |
| 5201 | #endif |
| 5202 | |
| 5203 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5204 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5205 | __func__, key_mgmt); |
| 5206 | return -EINVAL; |
| 5207 | |
| 5208 | } |
| 5209 | return 0; |
| 5210 | } |
| 5211 | |
| 5212 | /* |
| 5213 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5214 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5215 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5216 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5217 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5218 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5219 | bool ucast |
| 5220 | ) |
| 5221 | { |
| 5222 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5223 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5224 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5225 | |
| 5226 | ENTER(); |
| 5227 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5228 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5229 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5230 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5231 | __func__, cipher); |
| 5232 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5233 | } |
| 5234 | else |
| 5235 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5236 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5237 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5238 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5239 | { |
| 5240 | case IW_AUTH_CIPHER_NONE: |
| 5241 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5242 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5243 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5244 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5245 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5246 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5247 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5248 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5249 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5250 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5251 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5252 | case WLAN_CIPHER_SUITE_TKIP: |
| 5253 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5254 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5255 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5256 | case WLAN_CIPHER_SUITE_CCMP: |
| 5257 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5258 | break; |
| 5259 | #ifdef FEATURE_WLAN_WAPI |
| 5260 | case WLAN_CIPHER_SUITE_SMS4: |
| 5261 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5262 | break; |
| 5263 | #endif |
| 5264 | |
| 5265 | #ifdef FEATURE_WLAN_CCX |
| 5266 | case WLAN_CIPHER_SUITE_KRK: |
| 5267 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5268 | break; |
| 5269 | #endif |
| 5270 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5271 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5272 | __func__, cipher); |
| 5273 | return -EOPNOTSUPP; |
| 5274 | } |
| 5275 | } |
| 5276 | |
| 5277 | if (ucast) |
| 5278 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5279 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5280 | __func__, encryptionType); |
| 5281 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5282 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5283 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5284 | encryptionType; |
| 5285 | } |
| 5286 | else |
| 5287 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5288 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5289 | __func__, encryptionType); |
| 5290 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5291 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5292 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5293 | } |
| 5294 | |
| 5295 | return 0; |
| 5296 | } |
| 5297 | |
| 5298 | |
| 5299 | /* |
| 5300 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5301 | * This function is used to parse WPA/RSN IE's. |
| 5302 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5303 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5304 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5305 | size_t ie_len |
| 5306 | ) |
| 5307 | { |
| 5308 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5309 | u8 *genie = ie; |
| 5310 | v_U16_t remLen = ie_len; |
| 5311 | #ifdef FEATURE_WLAN_WAPI |
| 5312 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5313 | u16 *tmp; |
| 5314 | v_U16_t akmsuiteCount; |
| 5315 | int *akmlist; |
| 5316 | #endif |
| 5317 | ENTER(); |
| 5318 | |
| 5319 | /* clear previous assocAddIE */ |
| 5320 | pWextState->assocAddIE.length = 0; |
| 5321 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5322 | |
| 5323 | while (remLen >= 2) |
| 5324 | { |
| 5325 | v_U16_t eLen = 0; |
| 5326 | v_U8_t elementId; |
| 5327 | elementId = *genie++; |
| 5328 | eLen = *genie++; |
| 5329 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5330 | |
| 5331 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5332 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5333 | |
| 5334 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5335 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5336 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5337 | 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] | 5338 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5339 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5340 | "%s: Invalid WPA IE", __func__); |
| 5341 | return -EINVAL; |
| 5342 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5343 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5344 | { |
| 5345 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5346 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5347 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5348 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5349 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5350 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5351 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5352 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5353 | VOS_ASSERT(0); |
| 5354 | return -ENOMEM; |
| 5355 | } |
| 5356 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5357 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5358 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5359 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5360 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5361 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5362 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5363 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5364 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5365 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5366 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5367 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5368 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5369 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5370 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5371 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5372 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5373 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5374 | /*Consider P2P IE, only for P2P Client */ |
| 5375 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5376 | { |
| 5377 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5378 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5379 | __func__, eLen + 2); |
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 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5382 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5383 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5384 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5385 | VOS_ASSERT(0); |
| 5386 | return -ENOMEM; |
| 5387 | } |
| 5388 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5389 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5390 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5391 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5392 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5393 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5394 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5395 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5396 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5397 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5398 | /*Consider WFD IE, only for P2P Client */ |
| 5399 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5400 | { |
| 5401 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5402 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5403 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5404 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5405 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5406 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5407 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5408 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5409 | VOS_ASSERT(0); |
| 5410 | return -ENOMEM; |
| 5411 | } |
| 5412 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5413 | // WPS IE + P2P IE + WFD IE |
| 5414 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5415 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5416 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5417 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5418 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5419 | } |
| 5420 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5421 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5422 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5423 | HS20_OUI_TYPE_SIZE)) ) |
| 5424 | { |
| 5425 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5426 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5427 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5428 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5429 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5430 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5431 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5432 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5433 | VOS_ASSERT(0); |
| 5434 | return -ENOMEM; |
| 5435 | } |
| 5436 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5437 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5438 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5439 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5440 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5441 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5442 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5443 | break; |
| 5444 | case DOT11F_EID_RSN: |
| 5445 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5446 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5447 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5448 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5449 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5450 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5451 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5452 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5453 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5454 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5455 | 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] | 5456 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5457 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5458 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5459 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5460 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5461 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5462 | VOS_ASSERT(0); |
| 5463 | return -ENOMEM; |
| 5464 | } |
| 5465 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5466 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5467 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5468 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5469 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5470 | break; |
| 5471 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5472 | #ifdef FEATURE_WLAN_WAPI |
| 5473 | case WLAN_EID_WAPI: |
| 5474 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5475 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5476 | pAdapter->wapi_info.nWapiMode); |
| 5477 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5478 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5479 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5480 | tmp = tmp + 1; |
| 5481 | akmlist = (int *)(tmp); |
| 5482 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5483 | { |
| 5484 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5485 | } |
| 5486 | else |
| 5487 | { |
| 5488 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5489 | VOS_ASSERT(0); |
| 5490 | return -EINVAL; |
| 5491 | } |
| 5492 | |
| 5493 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5494 | { |
| 5495 | 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] | 5496 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5497 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5498 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5499 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5500 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5501 | 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] | 5502 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5503 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5504 | } |
| 5505 | break; |
| 5506 | #endif |
| 5507 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5508 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5509 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5510 | /* when Unknown IE is received we should break and continue |
| 5511 | * to the next IE in the buffer instead we were returning |
| 5512 | * so changing this to break */ |
| 5513 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5514 | } |
| 5515 | genie += eLen; |
| 5516 | remLen -= eLen; |
| 5517 | } |
| 5518 | EXIT(); |
| 5519 | return 0; |
| 5520 | } |
| 5521 | |
| 5522 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5523 | * FUNCTION: hdd_isWPAIEPresent |
| 5524 | * Parse the received IE to find the WPA IE |
| 5525 | * |
| 5526 | */ |
| 5527 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5528 | { |
| 5529 | v_U8_t eLen = 0; |
| 5530 | v_U16_t remLen = ie_len; |
| 5531 | v_U8_t elementId = 0; |
| 5532 | |
| 5533 | while (remLen >= 2) |
| 5534 | { |
| 5535 | elementId = *ie++; |
| 5536 | eLen = *ie++; |
| 5537 | remLen -= 2; |
| 5538 | if (eLen > remLen) |
| 5539 | { |
| 5540 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5541 | "%s: IE length is wrong %d", __func__, eLen); |
| 5542 | return FALSE; |
| 5543 | } |
| 5544 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5545 | { |
| 5546 | /* OUI - 0x00 0X50 0XF2 |
| 5547 | WPA Information Element - 0x01 |
| 5548 | WPA version - 0x01*/ |
| 5549 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5550 | return TRUE; |
| 5551 | } |
| 5552 | ie += eLen; |
| 5553 | remLen -= eLen; |
| 5554 | } |
| 5555 | return FALSE; |
| 5556 | } |
| 5557 | |
| 5558 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5559 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5560 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5561 | * parameters during connect operation. |
| 5562 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5563 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5564 | struct cfg80211_connect_params *req |
| 5565 | ) |
| 5566 | { |
| 5567 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5568 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5569 | ENTER(); |
| 5570 | |
| 5571 | /*set wpa version*/ |
| 5572 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5573 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5574 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5575 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 5576 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5577 | { |
| 5578 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5579 | } |
| 5580 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5581 | { |
| 5582 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5583 | } |
| 5584 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5585 | |
| 5586 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5587 | pWextState->wpaVersion); |
| 5588 | |
| 5589 | /*set authentication type*/ |
| 5590 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5591 | |
| 5592 | if (0 > status) |
| 5593 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5594 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5595 | "%s: failed to set authentication type ", __func__); |
| 5596 | return status; |
| 5597 | } |
| 5598 | |
| 5599 | /*set key mgmt type*/ |
| 5600 | if (req->crypto.n_akm_suites) |
| 5601 | { |
| 5602 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5603 | if (0 > status) |
| 5604 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5605 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5606 | __func__); |
| 5607 | return status; |
| 5608 | } |
| 5609 | } |
| 5610 | |
| 5611 | /*set pairwise cipher type*/ |
| 5612 | if (req->crypto.n_ciphers_pairwise) |
| 5613 | { |
| 5614 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5615 | req->crypto.ciphers_pairwise[0], true); |
| 5616 | if (0 > status) |
| 5617 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5618 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5619 | "%s: failed to set unicast cipher type", __func__); |
| 5620 | return status; |
| 5621 | } |
| 5622 | } |
| 5623 | else |
| 5624 | { |
| 5625 | /*Reset previous cipher suite to none*/ |
| 5626 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5627 | if (0 > status) |
| 5628 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5629 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5630 | "%s: failed to set unicast cipher type", __func__); |
| 5631 | return status; |
| 5632 | } |
| 5633 | } |
| 5634 | |
| 5635 | /*set group cipher type*/ |
| 5636 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5637 | false); |
| 5638 | |
| 5639 | if (0 > status) |
| 5640 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5641 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5642 | __func__); |
| 5643 | return status; |
| 5644 | } |
| 5645 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5646 | #ifdef WLAN_FEATURE_11W |
| 5647 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5648 | #endif |
| 5649 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5650 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5651 | if (req->ie_len) |
| 5652 | { |
| 5653 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5654 | if ( 0 > status) |
| 5655 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5656 | 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] | 5657 | __func__); |
| 5658 | return status; |
| 5659 | } |
| 5660 | } |
| 5661 | |
| 5662 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5663 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5664 | { |
| 5665 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5666 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5667 | ) |
| 5668 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5669 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5670 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5671 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5672 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5673 | __func__); |
| 5674 | return -EOPNOTSUPP; |
| 5675 | } |
| 5676 | else |
| 5677 | { |
| 5678 | u8 key_len = req->key_len; |
| 5679 | u8 key_idx = req->key_idx; |
| 5680 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5681 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5682 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5683 | ) |
| 5684 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5685 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5686 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5687 | __func__, key_idx, key_len); |
| 5688 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5689 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5690 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5691 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5692 | (u8)key_len; |
| 5693 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5694 | } |
| 5695 | } |
| 5696 | } |
| 5697 | } |
| 5698 | |
| 5699 | return status; |
| 5700 | } |
| 5701 | |
| 5702 | /* |
| 5703 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5704 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5705 | * parameters during connect operation. |
| 5706 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5707 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5708 | struct net_device *ndev, |
| 5709 | struct cfg80211_connect_params *req |
| 5710 | ) |
| 5711 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5712 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5713 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5714 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5715 | hdd_context_t *pHddCtx = NULL; |
| 5716 | |
| 5717 | ENTER(); |
| 5718 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5719 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5720 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5721 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5722 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5723 | status = wlan_hdd_validate_context(pHddCtx); |
| 5724 | |
| 5725 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5726 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5727 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5728 | "%s: HDD context is not valid", __func__); |
| 5729 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5730 | } |
| 5731 | |
| 5732 | #ifdef WLAN_BTAMP_FEATURE |
| 5733 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5734 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5735 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5736 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5737 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5738 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5739 | } |
| 5740 | #endif |
| 5741 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5742 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5743 | |
| 5744 | if ( 0 > status) |
| 5745 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5746 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5747 | __func__); |
| 5748 | return status; |
| 5749 | } |
| 5750 | |
| 5751 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5752 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5753 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5754 | (vos_concurrent_sessions_running())) |
| 5755 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5756 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5757 | } |
| 5758 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5759 | if ( req->channel ) |
| 5760 | { |
| 5761 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5762 | req->ssid_len, req->bssid, |
| 5763 | req->channel->hw_value); |
| 5764 | } |
| 5765 | else |
| 5766 | { |
| 5767 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5768 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5769 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5770 | |
| 5771 | if (0 > status) |
| 5772 | { |
| 5773 | //ReEnable BMPS if disabled |
| 5774 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5775 | (NULL != pHddCtx)) |
| 5776 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5777 | if (pHddCtx->hdd_wlan_suspended) |
| 5778 | { |
| 5779 | hdd_set_pwrparams(pHddCtx); |
| 5780 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5781 | //ReEnable Bmps and Imps back |
| 5782 | hdd_enable_bmps_imps(pHddCtx); |
| 5783 | } |
| 5784 | |
| 5785 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5786 | return status; |
| 5787 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5788 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5789 | EXIT(); |
| 5790 | return status; |
| 5791 | } |
| 5792 | |
| 5793 | |
| 5794 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5795 | * FUNCTION: wlan_hdd_disconnect |
| 5796 | * This function is used to issue a disconnect request to SME |
| 5797 | */ |
| 5798 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 5799 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5800 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5801 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5802 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5803 | |
| 5804 | status = wlan_hdd_validate_context(pHddCtx); |
| 5805 | |
| 5806 | if (0 != status) |
| 5807 | { |
| 5808 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5809 | "%s: HDD context is not valid", __func__); |
| 5810 | return status; |
| 5811 | } |
| 5812 | |
| 5813 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5814 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5815 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5816 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5817 | /*issue disconnect*/ |
| 5818 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5819 | pAdapter->sessionId, reason); |
| 5820 | |
| 5821 | if ( 0 != status ) |
| 5822 | { |
| 5823 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5824 | "%s csrRoamDisconnect failure, returned %d \n", |
| 5825 | __func__, (int)status ); |
| 5826 | return -EINVAL; |
| 5827 | } |
| 5828 | wait_for_completion_interruptible_timeout( |
| 5829 | &pAdapter->disconnect_comp_var, |
| 5830 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5831 | /*stop tx queues*/ |
| 5832 | netif_tx_disable(pAdapter->dev); |
| 5833 | netif_carrier_off(pAdapter->dev); |
| 5834 | return status; |
| 5835 | } |
| 5836 | |
| 5837 | |
| 5838 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5839 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5840 | * This function is used to issue a disconnect request to SME |
| 5841 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5842 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5843 | struct net_device *dev, |
| 5844 | u16 reason |
| 5845 | ) |
| 5846 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5847 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5848 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5849 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5850 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5851 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5852 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5853 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5854 | tANI_U8 staIdx; |
| 5855 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5856 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5858 | |
| 5859 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5860 | __func__,pAdapter->device_mode); |
| 5861 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5862 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5863 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5864 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5865 | status = wlan_hdd_validate_context(pHddCtx); |
| 5866 | |
| 5867 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5868 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5869 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5870 | "%s: HDD context is not valid", __func__); |
| 5871 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5872 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5873 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5874 | if (NULL != pRoamProfile) |
| 5875 | { |
| 5876 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5877 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5878 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5879 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5880 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5881 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5882 | switch(reason) |
| 5883 | { |
| 5884 | case WLAN_REASON_MIC_FAILURE: |
| 5885 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5886 | break; |
| 5887 | |
| 5888 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5889 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5890 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5891 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5892 | break; |
| 5893 | |
| 5894 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5895 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5896 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5897 | break; |
| 5898 | |
| 5899 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5900 | default: |
| 5901 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5902 | break; |
| 5903 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5904 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5905 | pScanInfo = &pHddCtx->scan_info; |
| 5906 | if (pScanInfo->mScanPending) |
| 5907 | { |
| 5908 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 5909 | "Aborting Scan"); |
| 5910 | hdd_abort_mac_scan(pHddCtx); |
| 5911 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5912 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5913 | #ifdef FEATURE_WLAN_TDLS |
| 5914 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5915 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5916 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5917 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5918 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5919 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5920 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5921 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5922 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5923 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5924 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5925 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5926 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5927 | pAdapter->sessionId, |
| 5928 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5929 | } |
| 5930 | } |
| 5931 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5932 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 5933 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5934 | { |
| 5935 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5936 | "%s wlan_hdd_disconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5937 | __func__, (int)status ); |
| 5938 | return -EINVAL; |
| 5939 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5940 | } |
| 5941 | } |
| 5942 | else |
| 5943 | { |
| 5944 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5945 | } |
| 5946 | |
| 5947 | return status; |
| 5948 | } |
| 5949 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5950 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5951 | /* |
| 5952 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5953 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5954 | * settings in IBSS mode. |
| 5955 | */ |
| 5956 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5957 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5958 | struct cfg80211_ibss_params *params |
| 5959 | ) |
| 5960 | { |
| 5961 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5962 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5963 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5964 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5965 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5966 | ENTER(); |
| 5967 | |
| 5968 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5969 | |
| 5970 | if (params->ie_len && ( NULL != params->ie) ) |
| 5971 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5972 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5973 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5974 | { |
| 5975 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5976 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5977 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5978 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5979 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5980 | tDot11fIEWPA dot11WPAIE; |
| 5981 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5982 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5983 | |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5984 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5985 | params->ie_len, DOT11F_EID_WPA); |
| 5986 | if ( NULL != ie ) |
| 5987 | { |
| 5988 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5989 | // Unpack the WPA IE |
| 5990 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 5991 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 5992 | &ie[2+4], |
| 5993 | ie[1] - 4, |
| 5994 | &dot11WPAIE); |
| 5995 | /*Extract the multicast cipher, the encType for unicast |
| 5996 | cipher for wpa-none is none*/ |
| 5997 | encryptionType = |
| 5998 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 5999 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6000 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6001 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6002 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 6003 | |
| 6004 | if (0 > status) |
| 6005 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6006 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6007 | __func__); |
| 6008 | return status; |
| 6009 | } |
| 6010 | } |
| 6011 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6012 | pWextState->roamProfile.AuthType.authType[0] = |
| 6013 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6014 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6015 | |
| 6016 | if (params->privacy) |
| 6017 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6018 | /* Security enabled IBSS, At this time there is no information available |
| 6019 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6020 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6021 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6022 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6023 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6024 | *enable privacy bit in beacons */ |
| 6025 | |
| 6026 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 6027 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6028 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6029 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6030 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 6031 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 6032 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6033 | return status; |
| 6034 | } |
| 6035 | |
| 6036 | /* |
| 6037 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6038 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6039 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6040 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6041 | struct net_device *dev, |
| 6042 | struct cfg80211_ibss_params *params |
| 6043 | ) |
| 6044 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6045 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6046 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6047 | tCsrRoamProfile *pRoamProfile; |
| 6048 | int status; |
| 6049 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6050 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6051 | |
| 6052 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6053 | |
| 6054 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6055 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6056 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6057 | status = wlan_hdd_validate_context(pHddCtx); |
| 6058 | |
| 6059 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6060 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6061 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6062 | "%s: HDD context is not valid", __func__); |
| 6063 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6064 | } |
| 6065 | |
| 6066 | if (NULL == pWextState) |
| 6067 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6068 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6069 | __func__); |
| 6070 | return -EIO; |
| 6071 | } |
| 6072 | |
| 6073 | pRoamProfile = &pWextState->roamProfile; |
| 6074 | |
| 6075 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 6076 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6077 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6078 | "%s Interface type is not set to IBSS \n", __func__); |
| 6079 | return -EINVAL; |
| 6080 | } |
| 6081 | |
| 6082 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6083 | if (NULL != |
| 6084 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6085 | params->chandef.chan) |
| 6086 | #else |
| 6087 | params->channel) |
| 6088 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6089 | { |
| 6090 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6091 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6092 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6093 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6094 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6095 | |
| 6096 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6097 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6098 | ieee80211_frequency_to_channel( |
| 6099 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6100 | params->chandef.chan->center_freq); |
| 6101 | #else |
| 6102 | params->channel->center_freq); |
| 6103 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6104 | |
| 6105 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 6106 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6107 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6108 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 6109 | __func__); |
| 6110 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6111 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6112 | |
| 6113 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6114 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6115 | if (channelNum == validChan[indx]) |
| 6116 | { |
| 6117 | break; |
| 6118 | } |
| 6119 | } |
| 6120 | if (indx >= numChans) |
| 6121 | { |
| 6122 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6123 | __func__, channelNum); |
| 6124 | return -EINVAL; |
| 6125 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6126 | /* Set the Operational Channel */ |
| 6127 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 6128 | channelNum); |
| 6129 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 6130 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6131 | pRoamProfile->ChannelInfo.ChannelList = |
| 6132 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6133 | } |
| 6134 | |
| 6135 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6136 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6137 | if (status < 0) |
| 6138 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6139 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6140 | __func__); |
| 6141 | return status; |
| 6142 | } |
| 6143 | |
| 6144 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6145 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6146 | params->ssid_len, params->bssid, |
| 6147 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6148 | |
| 6149 | if (0 > status) |
| 6150 | { |
| 6151 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6152 | return status; |
| 6153 | } |
| 6154 | |
| 6155 | return 0; |
| 6156 | } |
| 6157 | |
| 6158 | /* |
| 6159 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6160 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6161 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6162 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6163 | struct net_device *dev |
| 6164 | ) |
| 6165 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6166 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6167 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6168 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6169 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6170 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6171 | |
| 6172 | ENTER(); |
| 6173 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6174 | status = wlan_hdd_validate_context(pHddCtx); |
| 6175 | |
| 6176 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6177 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6178 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6179 | "%s: HDD context is not valid", __func__); |
| 6180 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6181 | } |
| 6182 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6183 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6184 | if (NULL == pWextState) |
| 6185 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6186 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6187 | __func__); |
| 6188 | return -EIO; |
| 6189 | } |
| 6190 | |
| 6191 | pRoamProfile = &pWextState->roamProfile; |
| 6192 | |
| 6193 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6194 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6195 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6196 | 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] | 6197 | __func__); |
| 6198 | return -EINVAL; |
| 6199 | } |
| 6200 | |
| 6201 | /* Issue Disconnect request */ |
| 6202 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6203 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6204 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6205 | |
| 6206 | return 0; |
| 6207 | } |
| 6208 | |
| 6209 | /* |
| 6210 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6211 | * This function is used to set the phy parameters |
| 6212 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6213 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6214 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6215 | u32 changed) |
| 6216 | { |
| 6217 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6218 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6219 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6220 | |
| 6221 | ENTER(); |
| 6222 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6223 | status = wlan_hdd_validate_context(pHddCtx); |
| 6224 | |
| 6225 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6226 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6227 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6228 | "%s: HDD context is not valid", __func__); |
| 6229 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6230 | } |
| 6231 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6232 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6233 | { |
| 6234 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6235 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6236 | wiphy->rts_threshold; |
| 6237 | |
| 6238 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6239 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6240 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6241 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6242 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6243 | __func__, rts_threshold); |
| 6244 | return -EINVAL; |
| 6245 | } |
| 6246 | |
| 6247 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6248 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6249 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6250 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6251 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6252 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6253 | __func__, rts_threshold); |
| 6254 | return -EIO; |
| 6255 | } |
| 6256 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6257 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6258 | rts_threshold); |
| 6259 | } |
| 6260 | |
| 6261 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6262 | { |
| 6263 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6264 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6265 | wiphy->frag_threshold; |
| 6266 | |
| 6267 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6268 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6269 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6270 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6271 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6272 | frag_threshold); |
| 6273 | return -EINVAL; |
| 6274 | } |
| 6275 | |
| 6276 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6277 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6278 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6279 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6280 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6281 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6282 | __func__, frag_threshold); |
| 6283 | return -EIO; |
| 6284 | } |
| 6285 | |
| 6286 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6287 | frag_threshold); |
| 6288 | } |
| 6289 | |
| 6290 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6291 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6292 | { |
| 6293 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6294 | wiphy->retry_short : |
| 6295 | wiphy->retry_long; |
| 6296 | |
| 6297 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6298 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6299 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6300 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6301 | __func__, retry_value); |
| 6302 | return -EINVAL; |
| 6303 | } |
| 6304 | |
| 6305 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6306 | { |
| 6307 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6308 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6309 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6310 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6311 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6312 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6313 | __func__, retry_value); |
| 6314 | return -EIO; |
| 6315 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6316 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6317 | __func__, retry_value); |
| 6318 | } |
| 6319 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6320 | { |
| 6321 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6322 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6323 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6324 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6325 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6326 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6327 | __func__, retry_value); |
| 6328 | return -EIO; |
| 6329 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6330 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6331 | __func__, retry_value); |
| 6332 | } |
| 6333 | } |
| 6334 | |
| 6335 | return 0; |
| 6336 | } |
| 6337 | |
| 6338 | /* |
| 6339 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6340 | * This function is used to set the txpower |
| 6341 | */ |
| 6342 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6343 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6344 | struct wireless_dev *wdev, |
| 6345 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6346 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6347 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6348 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6349 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6350 | #endif |
| 6351 | int dbm) |
| 6352 | { |
| 6353 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6354 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6355 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6356 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6357 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6358 | |
| 6359 | ENTER(); |
| 6360 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6361 | status = wlan_hdd_validate_context(pHddCtx); |
| 6362 | |
| 6363 | if (0 != status) |
| 6364 | { |
| 6365 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6366 | "%s: HDD context is not valid", __func__); |
| 6367 | return status; |
| 6368 | } |
| 6369 | |
| 6370 | hHal = pHddCtx->hHal; |
| 6371 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6372 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6373 | dbm, ccmCfgSetCallback, |
| 6374 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6375 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6376 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6377 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6378 | return -EIO; |
| 6379 | } |
| 6380 | |
| 6381 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6382 | dbm); |
| 6383 | |
| 6384 | switch(type) |
| 6385 | { |
| 6386 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6387 | /* Fall through */ |
| 6388 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6389 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6390 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6391 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6392 | __func__); |
| 6393 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6394 | } |
| 6395 | break; |
| 6396 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6397 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6398 | __func__); |
| 6399 | return -EOPNOTSUPP; |
| 6400 | break; |
| 6401 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6402 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6403 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6404 | return -EIO; |
| 6405 | } |
| 6406 | |
| 6407 | return 0; |
| 6408 | } |
| 6409 | |
| 6410 | /* |
| 6411 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6412 | * This function is used to read the txpower |
| 6413 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6414 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 6415 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6416 | struct wireless_dev *wdev, |
| 6417 | #endif |
| 6418 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6419 | { |
| 6420 | |
| 6421 | hdd_adapter_t *pAdapter; |
| 6422 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6423 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6424 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6425 | ENTER(); |
| 6426 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6427 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6428 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6429 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6430 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6431 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6432 | "%s: HDD context is not valid", __func__); |
| 6433 | *dbm = 0; |
| 6434 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6435 | } |
| 6436 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6437 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6438 | if (NULL == pAdapter) |
| 6439 | { |
| 6440 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6441 | return -ENOENT; |
| 6442 | } |
| 6443 | |
| 6444 | wlan_hdd_get_classAstats(pAdapter); |
| 6445 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6446 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6447 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6448 | return 0; |
| 6449 | } |
| 6450 | |
| 6451 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6452 | u8* mac, struct station_info *sinfo) |
| 6453 | { |
| 6454 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6455 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6456 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6457 | tANI_U8 rate_flags; |
| 6458 | |
| 6459 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6460 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6461 | |
| 6462 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6463 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6464 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6465 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6466 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6467 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6468 | tANI_U16 maxRate = 0; |
| 6469 | tANI_U16 myRate; |
| 6470 | tANI_U16 currentRate = 0; |
| 6471 | tANI_U8 maxSpeedMCS = 0; |
| 6472 | tANI_U8 maxMCSIdx = 0; |
| 6473 | tANI_U8 rateFlag = 1; |
| 6474 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6475 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6476 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6477 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6478 | #ifdef WLAN_FEATURE_11AC |
| 6479 | tANI_U32 vht_mcs_map; |
| 6480 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6481 | #endif /* WLAN_FEATURE_11AC */ |
| 6482 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6483 | ENTER(); |
| 6484 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6485 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6486 | (0 == ssidlen)) |
| 6487 | { |
| 6488 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6489 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6490 | /*To keep GUI happy*/ |
| 6491 | return 0; |
| 6492 | } |
| 6493 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6494 | status = wlan_hdd_validate_context(pHddCtx); |
| 6495 | |
| 6496 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6497 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6498 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6499 | "%s: HDD context is not valid", __func__); |
| 6500 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6501 | } |
| 6502 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6503 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6504 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6505 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6506 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6507 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6508 | |
| 6509 | //convert to the UI units of 100kbps |
| 6510 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6511 | |
| 6512 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6513 | 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] | 6514 | sinfo->signal, |
| 6515 | pCfg->reportMaxLinkSpeed, |
| 6516 | myRate, |
| 6517 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6518 | (int) pCfg->linkSpeedRssiMid, |
| 6519 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6520 | (int) rate_flags, |
| 6521 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6522 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6523 | |
| 6524 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6525 | { |
| 6526 | // we do not want to necessarily report the current speed |
| 6527 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6528 | { |
| 6529 | // report the max possible speed |
| 6530 | rssidx = 0; |
| 6531 | } |
| 6532 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6533 | { |
| 6534 | // report the max possible speed with RSSI scaling |
| 6535 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6536 | { |
| 6537 | // report the max possible speed |
| 6538 | rssidx = 0; |
| 6539 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6540 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6541 | { |
| 6542 | // report middle speed |
| 6543 | rssidx = 1; |
| 6544 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6545 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6546 | { |
| 6547 | // report middle speed |
| 6548 | rssidx = 2; |
| 6549 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6550 | else |
| 6551 | { |
| 6552 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6553 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6554 | } |
| 6555 | } |
| 6556 | else |
| 6557 | { |
| 6558 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6559 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6560 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6561 | __func__, pCfg->reportMaxLinkSpeed); |
| 6562 | rssidx = 0; |
| 6563 | } |
| 6564 | |
| 6565 | maxRate = 0; |
| 6566 | |
| 6567 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6568 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6569 | OperationalRates, &ORLeng)) |
| 6570 | { |
| 6571 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6572 | /*To keep GUI happy*/ |
| 6573 | return 0; |
| 6574 | } |
| 6575 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6576 | for (i = 0; i < ORLeng; i++) |
| 6577 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6578 | 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] | 6579 | { |
| 6580 | /* Validate Rate Set */ |
| 6581 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6582 | { |
| 6583 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6584 | break; |
| 6585 | } |
| 6586 | } |
| 6587 | /* Update MAX rate */ |
| 6588 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6589 | } |
| 6590 | |
| 6591 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6592 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6593 | ExtendedRates, &ERLeng)) |
| 6594 | { |
| 6595 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6596 | /*To keep GUI happy*/ |
| 6597 | return 0; |
| 6598 | } |
| 6599 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6600 | for (i = 0; i < ERLeng; i++) |
| 6601 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6602 | 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] | 6603 | { |
| 6604 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6605 | { |
| 6606 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6607 | break; |
| 6608 | } |
| 6609 | } |
| 6610 | /* Update MAX rate */ |
| 6611 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6612 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6613 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6614 | rates or if we are always reporting max speed or if we have |
| 6615 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6616 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6617 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6618 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6619 | MCSRates, &MCSLeng)) |
| 6620 | { |
| 6621 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6622 | /*To keep GUI happy*/ |
| 6623 | return 0; |
| 6624 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6625 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6626 | #ifdef WLAN_FEATURE_11AC |
| 6627 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6628 | 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] | 6629 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6630 | 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] | 6631 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6632 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6633 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6634 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6635 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6636 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6637 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6638 | maxMCSIdx = 7; |
| 6639 | } |
| 6640 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6641 | { |
| 6642 | maxMCSIdx = 8; |
| 6643 | } |
| 6644 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6645 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6646 | //VHT20 is supporting 0~8 |
| 6647 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6648 | maxMCSIdx = 8; |
| 6649 | else |
| 6650 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6651 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6652 | |
| 6653 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6654 | { |
| 6655 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6656 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6657 | } |
| 6658 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6659 | { |
| 6660 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6661 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6662 | } |
| 6663 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6664 | { |
| 6665 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6666 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6667 | } |
| 6668 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6669 | maxSpeedMCS = 1; |
| 6670 | if (currentRate > maxRate) |
| 6671 | { |
| 6672 | maxRate = currentRate; |
| 6673 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6674 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6675 | } |
| 6676 | else |
| 6677 | #endif /* WLAN_FEATURE_11AC */ |
| 6678 | { |
| 6679 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6680 | { |
| 6681 | rateFlag |= 1; |
| 6682 | } |
| 6683 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6684 | { |
| 6685 | rateFlag |= 2; |
| 6686 | } |
| 6687 | |
| 6688 | for (i = 0; i < MCSLeng; i++) |
| 6689 | { |
| 6690 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6691 | for (j = 0; j < temp; j++) |
| 6692 | { |
| 6693 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6694 | { |
| 6695 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6696 | break; |
| 6697 | } |
| 6698 | } |
| 6699 | if ((j < temp) && (currentRate > maxRate)) |
| 6700 | { |
| 6701 | maxRate = currentRate; |
| 6702 | maxSpeedMCS = 1; |
| 6703 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6704 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6705 | } |
| 6706 | } |
| 6707 | } |
| 6708 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6709 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6710 | { |
| 6711 | maxRate = myRate; |
| 6712 | maxSpeedMCS = 1; |
| 6713 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6714 | } |
| 6715 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6716 | // 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] | 6717 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6718 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6719 | { |
| 6720 | maxRate = myRate; |
| 6721 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6722 | { |
| 6723 | maxSpeedMCS = 0; |
| 6724 | } |
| 6725 | else |
| 6726 | { |
| 6727 | maxSpeedMCS = 1; |
| 6728 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6729 | } |
| 6730 | } |
| 6731 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6732 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6733 | { |
| 6734 | sinfo->txrate.legacy = maxRate; |
| 6735 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6736 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6737 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6738 | } |
| 6739 | else |
| 6740 | { |
| 6741 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6742 | #ifdef WLAN_FEATURE_11AC |
| 6743 | sinfo->txrate.nss = 1; |
| 6744 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6745 | { |
| 6746 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6747 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6748 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6749 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6750 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6751 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6752 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6753 | } |
| 6754 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6755 | { |
| 6756 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6757 | } |
| 6758 | #endif /* WLAN_FEATURE_11AC */ |
| 6759 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6760 | { |
| 6761 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6762 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6763 | { |
| 6764 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6765 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6766 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6767 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6768 | { |
| 6769 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6770 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6771 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6772 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6773 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6774 | sinfo->txrate.mcs, |
| 6775 | sinfo->txrate.flags ); |
| 6776 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6777 | } |
| 6778 | } |
| 6779 | else |
| 6780 | { |
| 6781 | // report current rate instead of max rate |
| 6782 | |
| 6783 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6784 | { |
| 6785 | //provide to the UI in units of 100kbps |
| 6786 | sinfo->txrate.legacy = myRate; |
| 6787 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6788 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6789 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6790 | } |
| 6791 | else |
| 6792 | { |
| 6793 | //must be MCS |
| 6794 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6795 | #ifdef WLAN_FEATURE_11AC |
| 6796 | sinfo->txrate.nss = 1; |
| 6797 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6798 | { |
| 6799 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6800 | } |
| 6801 | else |
| 6802 | #endif /* WLAN_FEATURE_11AC */ |
| 6803 | { |
| 6804 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6805 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6806 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6807 | { |
| 6808 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6809 | } |
| 6810 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6811 | { |
| 6812 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6813 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6814 | #ifdef WLAN_FEATURE_11AC |
| 6815 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6816 | { |
| 6817 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6818 | } |
| 6819 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6820 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6821 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6822 | sinfo->txrate.mcs, |
| 6823 | sinfo->txrate.flags ); |
| 6824 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6825 | } |
| 6826 | } |
| 6827 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6828 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6829 | sinfo->tx_packets = |
| 6830 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6831 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6832 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6833 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6834 | |
| 6835 | sinfo->tx_retries = |
| 6836 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6837 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6838 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6839 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6840 | |
| 6841 | sinfo->tx_failed = |
| 6842 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6843 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6844 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6845 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6846 | |
| 6847 | sinfo->filled |= |
| 6848 | STATION_INFO_TX_PACKETS | |
| 6849 | STATION_INFO_TX_RETRIES | |
| 6850 | STATION_INFO_TX_FAILED; |
| 6851 | |
| 6852 | EXIT(); |
| 6853 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6854 | } |
| 6855 | |
| 6856 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 6857 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6858 | { |
| 6859 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6860 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6861 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6862 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6863 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6864 | ENTER(); |
| 6865 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6866 | if (NULL == pAdapter) |
| 6867 | { |
| 6868 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6869 | return -ENODEV; |
| 6870 | } |
| 6871 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6872 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6873 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6874 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6875 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6876 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6877 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6878 | "%s: HDD context is not valid", __func__); |
| 6879 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6880 | } |
| 6881 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6882 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6883 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6884 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6885 | (eConnectionState_Associated == |
| 6886 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6887 | { |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 6888 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6889 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6890 | { |
| 6891 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6892 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6893 | __func__, vos_status); |
| 6894 | } |
| 6895 | } |
| 6896 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6897 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6898 | *on successful execution of the function call |
| 6899 | *we are oppositely mapped w.r.t mode in the driver |
| 6900 | **/ |
| 6901 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6902 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6903 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6904 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6905 | { |
| 6906 | return -EINVAL; |
| 6907 | } |
| 6908 | return 0; |
| 6909 | } |
| 6910 | |
| 6911 | |
| 6912 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6913 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6914 | struct net_device *netdev, |
| 6915 | u8 key_index) |
| 6916 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6917 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6918 | return 0; |
| 6919 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6920 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6921 | |
| 6922 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6923 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6924 | struct net_device *dev, |
| 6925 | struct ieee80211_txq_params *params) |
| 6926 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6927 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6928 | return 0; |
| 6929 | } |
| 6930 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6931 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6932 | struct ieee80211_txq_params *params) |
| 6933 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6934 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6935 | return 0; |
| 6936 | } |
| 6937 | #endif //LINUX_VERSION_CODE |
| 6938 | |
| 6939 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6940 | struct net_device *dev, u8 *mac) |
| 6941 | { |
| 6942 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6943 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6944 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6945 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6946 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6947 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6948 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6949 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6950 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6951 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6952 | return -EINVAL; |
| 6953 | } |
| 6954 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6955 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6956 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6957 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6958 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6959 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6960 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6961 | "%s: HDD context is not valid", __func__); |
| 6962 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6963 | } |
| 6964 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6965 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6966 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6967 | ) |
| 6968 | { |
| 6969 | if( NULL == mac ) |
| 6970 | { |
| 6971 | v_U16_t i; |
| 6972 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6973 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 6974 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 6975 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6976 | { |
| 6977 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6978 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6979 | "%s: Delete STA with MAC::" |
| 6980 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6981 | __func__, |
| 6982 | macAddr[0], macAddr[1], macAddr[2], |
| 6983 | macAddr[3], macAddr[4], macAddr[5]); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 6984 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6985 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6986 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6987 | } |
| 6988 | } |
| 6989 | } |
| 6990 | else |
| 6991 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6992 | |
| 6993 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6994 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6995 | { |
| 6996 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6997 | "%s: Skip this DEL STA as this is not used::" |
| 6998 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6999 | __func__, |
| 7000 | mac[0], mac[1], mac[2], |
| 7001 | mac[3], mac[4], mac[5]); |
| 7002 | return -ENOENT; |
| 7003 | } |
| 7004 | |
| 7005 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 7006 | { |
| 7007 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7008 | "%s: Skip this DEL STA as deauth is in progress::" |
| 7009 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7010 | __func__, |
| 7011 | mac[0], mac[1], mac[2], |
| 7012 | mac[3], mac[4], mac[5]); |
| 7013 | return -ENOENT; |
| 7014 | } |
| 7015 | |
| 7016 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 7017 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7018 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7019 | "%s: Delete STA with MAC::" |
| 7020 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7021 | __func__, |
| 7022 | mac[0], mac[1], mac[2], |
| 7023 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7024 | |
| 7025 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 7026 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7027 | { |
| 7028 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 7029 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7030 | "%s: STA removal failed for ::" |
| 7031 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7032 | __func__, |
| 7033 | mac[0], mac[1], mac[2], |
| 7034 | mac[3], mac[4], mac[5]); |
| 7035 | return -ENOENT; |
| 7036 | } |
| 7037 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7038 | } |
| 7039 | } |
| 7040 | |
| 7041 | EXIT(); |
| 7042 | |
| 7043 | return 0; |
| 7044 | } |
| 7045 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7046 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 7047 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 7048 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7049 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7050 | #ifdef FEATURE_WLAN_TDLS |
| 7051 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7052 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7053 | mask = params->sta_flags_mask; |
| 7054 | |
| 7055 | set = params->sta_flags_set; |
| 7056 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7057 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7059 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 7060 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 7061 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7062 | |
| 7063 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7064 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7065 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7066 | } |
| 7067 | } |
| 7068 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7069 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7070 | } |
| 7071 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7072 | |
| 7073 | #ifdef FEATURE_WLAN_LFR |
| 7074 | 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] | 7075 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7076 | { |
| 7077 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 7078 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7079 | static tANI_U32 i; // HDD Local Cache index |
| 7080 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7081 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7082 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7083 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7084 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7085 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7086 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7087 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7088 | ENTER(); |
| 7089 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7090 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7091 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7092 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7093 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7094 | return -EINVAL; |
| 7095 | } |
| 7096 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7097 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7098 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7099 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7100 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7101 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7102 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7103 | "%s: HDD context is not valid", __func__); |
| 7104 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7105 | } |
| 7106 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7107 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7108 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7109 | |
| 7110 | for (j = 0; j < i; j++) |
| 7111 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7112 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7113 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 7114 | { |
| 7115 | /* BSSID matched previous entry. Overwrite it. */ |
| 7116 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7117 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7118 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7119 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7120 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7121 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7122 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7123 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7124 | dump_bssid(pmksa->bssid); |
| 7125 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7126 | break; |
| 7127 | } |
| 7128 | } |
| 7129 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7130 | /* Check we compared all entries,if then take the first slot now */ |
| 7131 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 7132 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7133 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7134 | { |
| 7135 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 7136 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 7137 | pmksa->bssid, ETHER_ADDR_LEN); |
| 7138 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 7139 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7140 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7141 | 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] | 7142 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7143 | dump_bssid(pmksa->bssid); |
| 7144 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7145 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7146 | // 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] | 7147 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7148 | } |
| 7149 | |
| 7150 | |
| 7151 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7152 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7153 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7154 | 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] | 7155 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7156 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7157 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7158 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7159 | i ); |
| 7160 | return 0; |
| 7161 | } |
| 7162 | |
| 7163 | |
| 7164 | 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] | 7165 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7166 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7167 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7168 | // TODO: Implement this later. |
| 7169 | return 0; |
| 7170 | } |
| 7171 | |
| 7172 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 7173 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7174 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7175 | // TODO: Implement this later. |
| 7176 | return 0; |
| 7177 | } |
| 7178 | #endif |
| 7179 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7180 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7181 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7182 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 7183 | { |
| 7184 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7185 | hdd_station_ctx_t *pHddStaCtx; |
| 7186 | |
| 7187 | if (NULL == pAdapter) |
| 7188 | { |
| 7189 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 7190 | return -ENODEV; |
| 7191 | } |
| 7192 | |
| 7193 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7194 | |
| 7195 | // Added for debug on reception of Re-assoc Req. |
| 7196 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 7197 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7198 | 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] | 7199 | ftie->ie_len); |
| 7200 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 7201 | } |
| 7202 | |
| 7203 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7204 | 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] | 7205 | ftie->ie_len); |
| 7206 | #endif |
| 7207 | |
| 7208 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7209 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 7210 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7211 | ftie->ie_len); |
| 7212 | return 0; |
| 7213 | } |
| 7214 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7215 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7216 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7217 | |
| 7218 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 7219 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7220 | { |
| 7221 | int ret; |
| 7222 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 7223 | hdd_context_t *pHddCtx; |
| 7224 | |
| 7225 | if (NULL == pAdapter) |
| 7226 | { |
| 7227 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7228 | "%s: HDD adapter is Null", __func__); |
| 7229 | return ; |
| 7230 | } |
| 7231 | |
| 7232 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7233 | if (NULL == pHddCtx) |
| 7234 | { |
| 7235 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7236 | "%s: HDD context is Null!!!", __func__); |
| 7237 | return ; |
| 7238 | } |
| 7239 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7240 | spin_lock(&pHddCtx->schedScan_lock); |
| 7241 | if (TRUE == pHddCtx->isWiphySuspended) |
| 7242 | { |
| 7243 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 7244 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7245 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7246 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 7247 | return ; |
| 7248 | } |
| 7249 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7250 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7251 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7252 | |
| 7253 | if (0 > ret) |
| 7254 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7255 | |
| 7256 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7257 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7258 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7259 | } |
| 7260 | |
| 7261 | /* |
| 7262 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7263 | * NL interface to enable PNO |
| 7264 | */ |
| 7265 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7266 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7267 | { |
| 7268 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7269 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7270 | hdd_context_t *pHddCtx; |
| 7271 | tHalHandle hHal; |
| 7272 | v_U32_t i, indx, num_ch; |
| 7273 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7274 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7275 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7276 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7277 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7278 | |
| 7279 | if (NULL == pAdapter) |
| 7280 | { |
| 7281 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7282 | "%s: HDD adapter is Null", __func__); |
| 7283 | return -ENODEV; |
| 7284 | } |
| 7285 | |
| 7286 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7287 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7288 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7289 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7290 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7292 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7293 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7294 | } |
| 7295 | |
| 7296 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7297 | if (NULL == hHal) |
| 7298 | { |
| 7299 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7300 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7301 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7302 | } |
| 7303 | |
| 7304 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7305 | if (NULL == pPnoRequest) |
| 7306 | { |
| 7307 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7308 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7309 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7310 | } |
| 7311 | |
| 7312 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 7313 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 7314 | |
| 7315 | if (( !pPnoRequest->ucNetworksCount ) || |
| 7316 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 7317 | { |
| 7318 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7319 | "Network input is not correct"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7320 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7321 | goto error; |
| 7322 | } |
| 7323 | |
| 7324 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 7325 | { |
| 7326 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7327 | "Incorrect number of channels"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7328 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7329 | goto error; |
| 7330 | } |
| 7331 | |
| 7332 | /* Framework provides one set of channels(all) |
| 7333 | * common for all saved profile */ |
| 7334 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 7335 | channels_allowed, &num_channels_allowed)) |
| 7336 | { |
| 7337 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7338 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7339 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7340 | goto error; |
| 7341 | } |
| 7342 | /* Checking each channel against allowed channel list */ |
| 7343 | num_ch = 0; |
| 7344 | for (i = 0; i < request->n_channels; i++) |
| 7345 | { |
| 7346 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 7347 | { |
| 7348 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 7349 | { |
| 7350 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 7351 | break ; |
| 7352 | } |
| 7353 | } |
| 7354 | } |
| 7355 | |
| 7356 | /* Filling per profile params */ |
| 7357 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 7358 | { |
| 7359 | pPnoRequest->aNetworks[i].ssId.length = |
| 7360 | request->match_sets[i].ssid.ssid_len; |
| 7361 | |
| 7362 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 7363 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 7364 | { |
| 7365 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7366 | "SSID Len %d is not correct for network %d", |
| 7367 | pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7368 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7369 | goto error; |
| 7370 | } |
| 7371 | |
| 7372 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 7373 | request->match_sets[i].ssid.ssid, |
| 7374 | request->match_sets[i].ssid.ssid_len); |
| 7375 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 7376 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 7377 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 7378 | |
| 7379 | /*Copying list of valid channel into request */ |
| 7380 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 7381 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 7382 | |
| 7383 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 7384 | } |
| 7385 | |
| 7386 | /* framework provides interval in ms */ |
| 7387 | pPnoRequest->scanTimers.ucScanTimersCount = 1; |
| 7388 | pPnoRequest->scanTimers.aTimerValues[0].uTimerValue = |
| 7389 | (request->interval)/1000; |
| 7390 | pPnoRequest->scanTimers.aTimerValues[0].uTimerRepeat = 0; |
| 7391 | pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND; |
| 7392 | |
| 7393 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7394 | pPnoRequest, pAdapter->sessionId, |
| 7395 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 7396 | if (eHAL_STATUS_SUCCESS != status) |
| 7397 | { |
| 7398 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7399 | "Failed to enable PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7400 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7401 | goto error; |
| 7402 | } |
| 7403 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7404 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7405 | "PNO scanRequest offloaded"); |
| 7406 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7407 | error: |
| 7408 | vos_mem_free(pPnoRequest); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7409 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7410 | } |
| 7411 | |
| 7412 | /* |
| 7413 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 7414 | * NL interface to disable PNO |
| 7415 | */ |
| 7416 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 7417 | struct net_device *dev) |
| 7418 | { |
| 7419 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7420 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7421 | hdd_context_t *pHddCtx; |
| 7422 | tHalHandle hHal; |
| 7423 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7424 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7425 | |
| 7426 | ENTER(); |
| 7427 | |
| 7428 | if (NULL == pAdapter) |
| 7429 | { |
| 7430 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7431 | "%s: HDD adapter is Null", __func__); |
| 7432 | return -ENODEV; |
| 7433 | } |
| 7434 | |
| 7435 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7436 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7437 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7438 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7439 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7440 | "%s: HDD context is Null", __func__); |
| 7441 | return -ENODEV; |
| 7442 | } |
| 7443 | |
| 7444 | /* The return 0 is intentional when isLogpInProgress and |
| 7445 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 7446 | * failure in sched_scan_stop , especially for a case where the unload |
| 7447 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 7448 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 7449 | * success. If it returns a failure , then its next invocation due to the |
| 7450 | * clean up of the second interface will have the dev pointer corresponding |
| 7451 | * to the first one leading to a crash. |
| 7452 | */ |
| 7453 | if (pHddCtx->isLogpInProgress) |
| 7454 | { |
| 7455 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7456 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7457 | return ret; |
| 7458 | } |
| 7459 | |
| 7460 | if (pHddCtx->isLoadUnloadInProgress) |
| 7461 | { |
| 7462 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7463 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 7464 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7465 | } |
| 7466 | |
| 7467 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7468 | if (NULL == hHal) |
| 7469 | { |
| 7470 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7471 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7472 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7473 | } |
| 7474 | |
| 7475 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7476 | if (NULL == pPnoRequest) |
| 7477 | { |
| 7478 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7479 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7480 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7481 | } |
| 7482 | |
| 7483 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 7484 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 7485 | pPnoRequest->ucNetworksCount = 0; |
| 7486 | |
| 7487 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 7488 | pAdapter->sessionId, |
| 7489 | NULL, pAdapter); |
| 7490 | if (eHAL_STATUS_SUCCESS != status) |
| 7491 | { |
| 7492 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7493 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7494 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7495 | } |
| 7496 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7497 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7498 | "%s: PNO scan disabled", __func__); |
| 7499 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7500 | vos_mem_free(pPnoRequest); |
| 7501 | |
| 7502 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7503 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7504 | } |
| 7505 | |
| 7506 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 7507 | |
| 7508 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7509 | #ifdef FEATURE_WLAN_TDLS |
| 7510 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 7511 | u8 *peer, u8 action_code, u8 dialog_token, |
| 7512 | u16 status_code, const u8 *buf, size_t len) |
| 7513 | { |
| 7514 | |
| 7515 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7516 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7517 | u8 peerMac[6]; |
| 7518 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7519 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7520 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7521 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7522 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7523 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7524 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7526 | "Invalid arguments"); |
| 7527 | return -EINVAL; |
| 7528 | } |
| 7529 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7530 | if (pHddCtx->isLogpInProgress) |
| 7531 | { |
| 7532 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7533 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7534 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7535 | return -EBUSY; |
| 7536 | } |
| 7537 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7538 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7539 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7540 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7541 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7542 | MAC_ADDRESS_STR " action %d declined.", |
| 7543 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7544 | return -ENOTSUPP; |
| 7545 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7546 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7547 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 7548 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 7549 | { |
| 7550 | /* if tdls_mode is disabled to respond to peer's request */ |
| 7551 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 7552 | { |
| 7553 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7554 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7555 | " TDLS mode is disabled. action %d declined.", |
| 7556 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7557 | |
| 7558 | return -ENOTSUPP; |
| 7559 | } |
| 7560 | } |
| 7561 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7562 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 7563 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 7564 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7565 | { |
| 7566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7567 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7568 | " TDLS setup is ongoing. action %d declined.", |
| 7569 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7570 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7571 | } |
| 7572 | } |
| 7573 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7574 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 7575 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7576 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7577 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7578 | { |
| 7579 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 7580 | we return error code at 'add_station()'. Hence we have this |
| 7581 | check again in addtion to add_station(). |
| 7582 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7583 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7584 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7585 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7586 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7587 | " TDLS Max peer already connected. action %d declined.", |
| 7588 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7589 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7590 | } |
| 7591 | else |
| 7592 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7593 | /* maximum reached. tweak to send error code to peer and return |
| 7594 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7595 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7596 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7597 | "%s: " MAC_ADDRESS_STR |
| 7598 | " TDLS Max peer already connected send response status %d", |
| 7599 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7600 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7601 | /* fall through to send setup resp with failure status |
| 7602 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7603 | } |
| 7604 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7605 | else |
| 7606 | { |
| 7607 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7608 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7609 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7610 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7611 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7612 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 7613 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7614 | return -EPERM; |
| 7615 | } |
| 7616 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7617 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7618 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7619 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7620 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7621 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7622 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 7623 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 7624 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7625 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7626 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7627 | /*Except teardown responder will not be used so just make 0*/ |
| 7628 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7629 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7630 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7631 | |
| 7632 | hddTdlsPeer_t *pTdlsPeer; |
| 7633 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 7634 | |
| 7635 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 7636 | responder = pTdlsPeer->is_responder; |
| 7637 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7638 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7639 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7640 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 7641 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 7642 | dialog_token, status_code, len); |
| 7643 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7644 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7645 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7646 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7647 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 7648 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7649 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7650 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 7651 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7652 | { |
| 7653 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 7654 | { |
| 7655 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7656 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7657 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7658 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7659 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 7660 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7661 | } |
| 7662 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7663 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7664 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7665 | { |
| 7666 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7667 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7668 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7669 | return -EBUSY; |
| 7670 | } |
| 7671 | |
| 7672 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7673 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7674 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7675 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7676 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7677 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7678 | if (VOS_STATUS_SUCCESS != status) |
| 7679 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7680 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7681 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7682 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7683 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7684 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7685 | } |
| 7686 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7687 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7688 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7689 | |
| 7690 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7691 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7692 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7693 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7694 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7695 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7696 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7697 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7698 | } |
| 7699 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7700 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7701 | { |
| 7702 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7703 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7704 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7705 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7706 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7707 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7708 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7709 | } |
| 7710 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7711 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7712 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7713 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7714 | |
| 7715 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7716 | error: |
| 7717 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7718 | because we already know that this transaction will be failed, |
| 7719 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7720 | to be safe, do not change the state mahine. |
| 7721 | */ |
| 7722 | if(max_sta_failed == 0 && |
| 7723 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7724 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7725 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7726 | } |
| 7727 | |
| 7728 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7729 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7730 | { |
| 7731 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7732 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7733 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7734 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7735 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7736 | tANI_U8 staIdx; |
| 7737 | #endif |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7738 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7739 | const char *tdls_oper_str[]= { |
| 7740 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7741 | "NL80211_TDLS_SETUP", |
| 7742 | "NL80211_TDLS_TEARDOWN", |
| 7743 | "NL80211_TDLS_ENABLE_LINK", |
| 7744 | "NL80211_TDLS_DISABLE_LINK", |
Gopichand Nakkala | 29d0019 | 2013-06-20 19:03:52 +0530 | [diff] [blame] | 7745 | "NL80211_TDLS_UNKNOWN_OPER"}; |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7746 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7747 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7748 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7749 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7750 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7751 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7752 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7753 | return -EINVAL; |
| 7754 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7755 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7756 | status = wlan_hdd_validate_context(pHddCtx); |
| 7757 | |
| 7758 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7759 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7760 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7761 | "%s: HDD context is not valid", __func__); |
| 7762 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7763 | } |
| 7764 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7765 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7766 | |
| 7767 | if ( NULL == pTdlsPeer ) { |
| 7768 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7769 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7770 | return -EINVAL; |
| 7771 | } |
| 7772 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7773 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7774 | if((int)oper > 4) |
| 7775 | oper = 5; |
| 7776 | |
| 7777 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7778 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7779 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7780 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7781 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7782 | |
| 7783 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7784 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7785 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7786 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7787 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7788 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7789 | return -ENOTSUPP; |
| 7790 | } |
| 7791 | |
| 7792 | switch (oper) { |
| 7793 | case NL80211_TDLS_ENABLE_LINK: |
| 7794 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7795 | VOS_STATUS status; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7796 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7797 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7798 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7799 | { |
| 7800 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7801 | MAC_ADDRESS_STR " failed", |
| 7802 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7803 | return -EINVAL; |
| 7804 | } |
| 7805 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7806 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7807 | { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7808 | long ret; |
| 7809 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7810 | if (0 != wlan_hdd_tdls_get_link_establish_params(pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 7811 | return -EINVAL; |
| 7812 | } |
| 7813 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
| 7814 | |
| 7815 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7816 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 7817 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 7818 | * register with the TL on after the response for this operation |
| 7819 | * is received . |
| 7820 | */ |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7821 | ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_link_establish_req_comp, |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7822 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7823 | if (ret <= 0) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7824 | { |
| 7825 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7826 | "%s: Link Establish Request Faled Status %ld", |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7827 | __func__, ret); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7828 | return -EINVAL; |
| 7829 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7830 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 7831 | /* Mark TDLS client Authenticated .*/ |
| 7832 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 7833 | pTdlsPeer->staId, |
| 7834 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7835 | if (VOS_STATUS_SUCCESS == status) |
| 7836 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7837 | if (pTdlsPeer->is_responder == 0) |
| 7838 | { |
| 7839 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7840 | |
| 7841 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7842 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7843 | WAIT_TIME_TDLS_INITIATOR); |
| 7844 | /* suspend initiator TX until it receives direct packet from the |
| 7845 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7846 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7847 | &staId, NULL); |
| 7848 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7849 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7850 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7851 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7852 | |
| 7853 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 7854 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 7855 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7856 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 7857 | int ac; |
| 7858 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 7859 | WLANTL_AC_VI, |
| 7860 | WLANTL_AC_BK, |
| 7861 | WLANTL_AC_BE }; |
| 7862 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 7863 | for(ac=0; ac < 4; ac++) |
| 7864 | { |
| 7865 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7866 | pTdlsPeer->staId, ucAc[ac], |
| 7867 | tlTid[ac], tlTid[ac], 0, 0, |
| 7868 | WLANTL_BI_DIR ); |
| 7869 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7870 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7871 | } |
| 7872 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7873 | } |
| 7874 | break; |
| 7875 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7876 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7877 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7878 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7879 | long status; |
| 7880 | |
| 7881 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7882 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7883 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7884 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7885 | |
| 7886 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7887 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7888 | if (status <= 0) |
| 7889 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7890 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7891 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7892 | "%s: Del station failed status %ld", |
| 7893 | __func__, status); |
| 7894 | return -EPERM; |
| 7895 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7896 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7897 | } |
| 7898 | else |
| 7899 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7900 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7901 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7902 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7903 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7904 | if (pHddTdlsCtx->defer_link_lost_indication) |
| 7905 | { |
| 7906 | if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) && |
| 7907 | (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0)) |
| 7908 | { |
| 7909 | status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7910 | if ( 0 != status) |
| 7911 | { |
| 7912 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7913 | "%s wlan_hdd_disconnect failure, returned %d \n", |
| 7914 | __func__, (int)status ); |
| 7915 | return -EINVAL; |
| 7916 | } |
| 7917 | } |
| 7918 | } |
| 7919 | #endif |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7920 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7921 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7922 | case NL80211_TDLS_TEARDOWN: |
| 7923 | case NL80211_TDLS_SETUP: |
| 7924 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7925 | /* We don't support in-driver setup/teardown/discovery */ |
| 7926 | return -ENOTSUPP; |
| 7927 | default: |
| 7928 | return -ENOTSUPP; |
| 7929 | } |
| 7930 | return 0; |
| 7931 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7932 | |
| 7933 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7934 | struct net_device *dev, u8 *peer) |
| 7935 | { |
| 7936 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7937 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7938 | |
| 7939 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7940 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7941 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7942 | #endif |
| 7943 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7944 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7945 | /* |
| 7946 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7947 | * Callback rountine called upon receiving response for |
| 7948 | * get offload info |
| 7949 | */ |
| 7950 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7951 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7952 | { |
| 7953 | |
| 7954 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7955 | tANI_U8 tempReplayCounter[8]; |
| 7956 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7957 | |
| 7958 | ENTER(); |
| 7959 | |
| 7960 | if (NULL == pAdapter) |
| 7961 | { |
| 7962 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7963 | "%s: HDD adapter is Null", __func__); |
| 7964 | return ; |
| 7965 | } |
| 7966 | |
| 7967 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7968 | { |
| 7969 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7970 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7971 | return ; |
| 7972 | } |
| 7973 | |
| 7974 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7975 | { |
| 7976 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7977 | "%s: wlan Failed to get replay counter value", |
| 7978 | __func__); |
| 7979 | return ; |
| 7980 | } |
| 7981 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7982 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7983 | /* Update replay counter */ |
| 7984 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 7985 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7986 | |
| 7987 | { |
| 7988 | /* changing from little to big endian since supplicant |
| 7989 | * works on big endian format |
| 7990 | */ |
| 7991 | int i; |
| 7992 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7993 | |
| 7994 | for (i = 0; i < 8; i++) |
| 7995 | { |
| 7996 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 7997 | } |
| 7998 | } |
| 7999 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8000 | /* Update replay counter to NL */ |
| 8001 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8002 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8003 | } |
| 8004 | |
| 8005 | /* |
| 8006 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 8007 | * This function is used to offload GTK rekeying job to the firmware. |
| 8008 | */ |
| 8009 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 8010 | struct cfg80211_gtk_rekey_data *data) |
| 8011 | { |
| 8012 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8013 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8014 | hdd_station_ctx_t *pHddStaCtx; |
| 8015 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8016 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8017 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8018 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8019 | |
| 8020 | ENTER(); |
| 8021 | |
| 8022 | if (NULL == pAdapter) |
| 8023 | { |
| 8024 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8025 | "%s: HDD adapter is Null", __func__); |
| 8026 | return -ENODEV; |
| 8027 | } |
| 8028 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8029 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8030 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8031 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8032 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8033 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8034 | "%s: HDD context is not valid", __func__); |
| 8035 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8036 | } |
| 8037 | |
| 8038 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8039 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8040 | if (NULL == hHal) |
| 8041 | { |
| 8042 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8043 | "%s: HAL context is Null!!!", __func__); |
| 8044 | return -EAGAIN; |
| 8045 | } |
| 8046 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8047 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 8048 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 8049 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 8050 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8051 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8052 | { |
| 8053 | /* changing from big to little endian since driver |
| 8054 | * works on little endian format |
| 8055 | */ |
| 8056 | tANI_U8 *p = |
| 8057 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 8058 | int i; |
| 8059 | |
| 8060 | for (i = 0; i < 8; i++) |
| 8061 | { |
| 8062 | p[7-i] = data->replay_ctr[i]; |
| 8063 | } |
| 8064 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8065 | |
| 8066 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 8067 | { |
| 8068 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8069 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 8070 | sizeof (tSirGtkOffloadParams)); |
| 8071 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8072 | pAdapter->sessionId); |
| 8073 | |
| 8074 | if (eHAL_STATUS_SUCCESS != status) |
| 8075 | { |
| 8076 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8077 | "%s: sme_SetGTKOffload failed, returned %d", |
| 8078 | __func__, status); |
| 8079 | return status; |
| 8080 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8081 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8082 | "%s: sme_SetGTKOffload successfull", __func__); |
| 8083 | } |
| 8084 | else |
| 8085 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8086 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8087 | "%s: wlan not suspended GTKOffload request is stored", |
| 8088 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8089 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8090 | |
| 8091 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8092 | } |
| 8093 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 8094 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8095 | /* |
| 8096 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 8097 | * This function is used to set access control policy |
| 8098 | */ |
| 8099 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 8100 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 8101 | { |
| 8102 | int i; |
| 8103 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8104 | hdd_hostapd_state_t *pHostapdState; |
| 8105 | tsap_Config_t *pConfig; |
| 8106 | v_CONTEXT_t pVosContext = NULL; |
| 8107 | hdd_context_t *pHddCtx; |
| 8108 | int status; |
| 8109 | |
| 8110 | ENTER(); |
| 8111 | |
| 8112 | if (NULL == pAdapter) |
| 8113 | { |
| 8114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8115 | "%s: HDD adapter is Null", __func__); |
| 8116 | return -ENODEV; |
| 8117 | } |
| 8118 | |
| 8119 | if (NULL == params) |
| 8120 | { |
| 8121 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8122 | "%s: params is Null", __func__); |
| 8123 | return -EINVAL; |
| 8124 | } |
| 8125 | |
| 8126 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8127 | status = wlan_hdd_validate_context(pHddCtx); |
| 8128 | |
| 8129 | if (0 != status) |
| 8130 | { |
| 8131 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8132 | "%s: HDD context is not valid", __func__); |
| 8133 | return status; |
| 8134 | } |
| 8135 | |
| 8136 | pVosContext = pHddCtx->pvosContext; |
| 8137 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8138 | |
| 8139 | if (NULL == pHostapdState) |
| 8140 | { |
| 8141 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8142 | "%s: pHostapdState is Null", __func__); |
| 8143 | return -EINVAL; |
| 8144 | } |
| 8145 | |
| 8146 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 8147 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 8148 | |
| 8149 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 8150 | { |
| 8151 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 8152 | |
| 8153 | /* default value */ |
| 8154 | pConfig->num_accept_mac = 0; |
| 8155 | pConfig->num_deny_mac = 0; |
| 8156 | |
| 8157 | /** |
| 8158 | * access control policy |
| 8159 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 8160 | * listed in hostapd.deny file. |
| 8161 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 8162 | * listed in hostapd.accept file. |
| 8163 | */ |
| 8164 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 8165 | { |
| 8166 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 8167 | } |
| 8168 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 8169 | { |
| 8170 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 8171 | } |
| 8172 | else |
| 8173 | { |
| 8174 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8175 | "%s:Acl Policy : %d is not supported", |
| 8176 | __func__, params->acl_policy); |
| 8177 | return -ENOTSUPP; |
| 8178 | } |
| 8179 | |
| 8180 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 8181 | { |
| 8182 | pConfig->num_accept_mac = params->n_acl_entries; |
| 8183 | for (i = 0; i < params->n_acl_entries; i++) |
| 8184 | { |
| 8185 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8186 | "** Add ACL MAC entry %i in WhiletList :" |
| 8187 | MAC_ADDRESS_STR, i, |
| 8188 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8189 | |
| 8190 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 8191 | sizeof(qcmacaddr)); |
| 8192 | } |
| 8193 | } |
| 8194 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 8195 | { |
| 8196 | pConfig->num_deny_mac = params->n_acl_entries; |
| 8197 | for (i = 0; i < params->n_acl_entries; i++) |
| 8198 | { |
| 8199 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8200 | "** Add ACL MAC entry %i in BlackList :" |
| 8201 | MAC_ADDRESS_STR, i, |
| 8202 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8203 | |
| 8204 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 8205 | sizeof(qcmacaddr)); |
| 8206 | } |
| 8207 | } |
| 8208 | |
| 8209 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 8210 | { |
| 8211 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8212 | "%s: SAP Set Mac Acl fail", __func__); |
| 8213 | return -EINVAL; |
| 8214 | } |
| 8215 | } |
| 8216 | else |
| 8217 | { |
| 8218 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8219 | "%s: Invalid device_mode = %d", |
| 8220 | __func__, pAdapter->device_mode); |
| 8221 | return -EINVAL; |
| 8222 | } |
| 8223 | |
| 8224 | return 0; |
| 8225 | } |
| 8226 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8227 | #ifdef WLAN_NL80211_TESTMODE |
| 8228 | #ifdef FEATURE_WLAN_LPHB |
| 8229 | static void wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler |
| 8230 | ( |
| 8231 | void *pAdapter, |
| 8232 | void *indCont |
| 8233 | ) |
| 8234 | { |
| 8235 | tSirLPHBTimeoutInd *lphbTimeoutInd; |
| 8236 | struct sk_buff *skb; |
| 8237 | |
| 8238 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8239 | "LPHB wait timeout indication arrived"); |
| 8240 | |
| 8241 | if (NULL == indCont) |
| 8242 | { |
| 8243 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8244 | "LPHB timeout, invalid argument"); |
| 8245 | return; |
| 8246 | } |
| 8247 | |
| 8248 | lphbTimeoutInd = (tSirLPHBTimeoutInd *)indCont; |
| 8249 | skb = cfg80211_testmode_alloc_event_skb( |
| 8250 | ((hdd_adapter_t *)pAdapter)->wdev.wiphy, |
| 8251 | sizeof(tSirLPHBTimeoutInd), |
| 8252 | GFP_ATOMIC); |
| 8253 | if (!skb) |
| 8254 | { |
| 8255 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8256 | "LPHB timeout, NL buffer alloc fail"); |
| 8257 | return; |
| 8258 | } |
| 8259 | |
| 8260 | NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB); |
| 8261 | NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbTimeoutInd->protocolType); |
| 8262 | NLA_PUT(skb, WLAN_HDD_TM_ATTR_DATA, |
| 8263 | sizeof(tSirLPHBTimeoutInd), lphbTimeoutInd); |
| 8264 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 8265 | return; |
| 8266 | |
| 8267 | nla_put_failure: |
| 8268 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8269 | "NLA Put fail"); |
| 8270 | kfree_skb(skb); |
| 8271 | |
| 8272 | return; |
| 8273 | } |
| 8274 | #endif /* FEATURE_WLAN_LPHB */ |
| 8275 | |
| 8276 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 8277 | { |
| 8278 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 8279 | int err = 0; |
| 8280 | #ifdef FEATURE_WLAN_LPHB |
| 8281 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8282 | #endif /* FEATURE_WLAN_LPHB */ |
| 8283 | |
| 8284 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 8285 | if (err) |
| 8286 | { |
| 8287 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8288 | "%s Testmode INV ATTR", __func__); |
| 8289 | return err; |
| 8290 | } |
| 8291 | |
| 8292 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 8293 | { |
| 8294 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8295 | "%s Testmode INV CMD", __func__); |
| 8296 | return -EINVAL; |
| 8297 | } |
| 8298 | |
| 8299 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 8300 | { |
| 8301 | #ifdef FEATURE_WLAN_LPHB |
| 8302 | /* Low Power Heartbeat configuration request */ |
| 8303 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 8304 | { |
| 8305 | int buf_len; |
| 8306 | void *buf; |
| 8307 | tSirLPHBReq *hb_params = NULL; |
| 8308 | |
| 8309 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 8310 | { |
| 8311 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8312 | "%s Testmode INV DATA", __func__); |
| 8313 | return -EINVAL; |
| 8314 | } |
| 8315 | |
| 8316 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 8317 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 8318 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 8319 | if (NULL == hb_params) |
| 8320 | { |
| 8321 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8322 | "%s Request Buffer Alloc Fail", __func__); |
| 8323 | return -EINVAL; |
| 8324 | } |
| 8325 | |
| 8326 | vos_mem_copy(hb_params, buf, buf_len); |
| 8327 | |
| 8328 | /* LPHB enable and disable request will send to FW |
| 8329 | * when host suspend and resume |
| 8330 | * host suspend -> enable LPHB |
| 8331 | * host resume -> disable LPHB |
| 8332 | * if host is not suspend, cache into HDD context |
| 8333 | * and when host goes to suspend, send request to FW */ |
| 8334 | if ((LPHB_SET_EN_PARAMS_INDID == hb_params->cmd) && |
| 8335 | (!pHddCtx->hdd_wlan_suspended)) |
| 8336 | { |
| 8337 | /* Feature enable command cache into HDD context, |
| 8338 | * if WLAN is not suspend |
| 8339 | * When WLAN goes into suspend, send enable command to FW */ |
| 8340 | pHddCtx->lphbEnableReq.enable = |
| 8341 | hb_params->params.lphbEnableReq.enable; |
| 8342 | pHddCtx->lphbEnableReq.item = |
| 8343 | hb_params->params.lphbEnableReq.item; |
| 8344 | pHddCtx->lphbEnableReq.session = |
| 8345 | hb_params->params.lphbEnableReq.session; |
| 8346 | vos_mem_free(hb_params); |
| 8347 | } |
| 8348 | else |
| 8349 | { |
| 8350 | eHalStatus smeStatus; |
| 8351 | |
| 8352 | /* If WLAN is suspend state, send enable command immediately */ |
| 8353 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 8354 | hb_params, |
| 8355 | wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler); |
| 8356 | if (eHAL_STATUS_SUCCESS != smeStatus) |
| 8357 | { |
| 8358 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8359 | "LPHB Config Fail, disable"); |
| 8360 | pHddCtx->lphbEnableReq.enable = 0; |
| 8361 | vos_mem_free(hb_params); |
| 8362 | } |
| 8363 | } |
| 8364 | return 0; |
| 8365 | } |
| 8366 | #endif /* FEATURE_WLAN_LPHB */ |
| 8367 | default: |
| 8368 | return -EOPNOTSUPP; |
| 8369 | } |
| 8370 | |
| 8371 | return err; |
| 8372 | } |
| 8373 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 8374 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8375 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 8376 | struct net_device *dev, |
| 8377 | int idx, struct survey_info *survey) |
| 8378 | { |
| 8379 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8380 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8381 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8382 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8383 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8384 | v_S7_t snr,rssi; |
| 8385 | int status, i, j, filled = 0; |
| 8386 | |
| 8387 | ENTER(); |
| 8388 | |
| 8389 | |
| 8390 | if (NULL == pAdapter) |
| 8391 | { |
| 8392 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8393 | "%s: HDD adapter is Null", __func__); |
| 8394 | return -ENODEV; |
| 8395 | } |
| 8396 | |
| 8397 | if (NULL == wiphy) |
| 8398 | { |
| 8399 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8400 | "%s: wiphy is Null", __func__); |
| 8401 | return -ENODEV; |
| 8402 | } |
| 8403 | |
| 8404 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8405 | status = wlan_hdd_validate_context(pHddCtx); |
| 8406 | |
| 8407 | if (0 != status) |
| 8408 | { |
| 8409 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8410 | "%s: HDD context is not valid", __func__); |
| 8411 | return status; |
| 8412 | } |
| 8413 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8414 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8415 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8416 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8417 | 0 != pAdapter->survey_idx || |
| 8418 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8419 | { |
| 8420 | /* The survey dump ops when implemented completely is expected to |
| 8421 | * return a survey of all channels and the ops is called by the |
| 8422 | * kernel with incremental values of the argument 'idx' till it |
| 8423 | * returns -ENONET. But we can only support the survey for the |
| 8424 | * operating channel for now. survey_idx is used to track |
| 8425 | * that the ops is called only once and then return -ENONET for |
| 8426 | * the next iteration |
| 8427 | */ |
| 8428 | pAdapter->survey_idx = 0; |
| 8429 | return -ENONET; |
| 8430 | } |
| 8431 | |
| 8432 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8433 | |
| 8434 | wlan_hdd_get_snr(pAdapter, &snr); |
| 8435 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 8436 | |
| 8437 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 8438 | hdd_wlan_get_freq(channel, &freq); |
| 8439 | |
| 8440 | |
| 8441 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 8442 | { |
| 8443 | if (NULL == wiphy->bands[i]) |
| 8444 | { |
| 8445 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 8446 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 8447 | continue; |
| 8448 | } |
| 8449 | |
| 8450 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 8451 | { |
| 8452 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 8453 | |
| 8454 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 8455 | { |
| 8456 | survey->channel = &band->channels[j]; |
| 8457 | /* The Rx BDs contain SNR values in dB for the received frames |
| 8458 | * while the supplicant expects noise. So we calculate and |
| 8459 | * return the value of noise (dBm) |
| 8460 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 8461 | */ |
| 8462 | survey->noise = rssi - snr; |
| 8463 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 8464 | filled = 1; |
| 8465 | } |
| 8466 | } |
| 8467 | } |
| 8468 | |
| 8469 | if (filled) |
| 8470 | pAdapter->survey_idx = 1; |
| 8471 | else |
| 8472 | { |
| 8473 | pAdapter->survey_idx = 0; |
| 8474 | return -ENONET; |
| 8475 | } |
| 8476 | |
| 8477 | return 0; |
| 8478 | } |
| 8479 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8480 | /* |
| 8481 | * FUNCTION: wlan_hdd_cfg80211_resume_wlan |
| 8482 | * this is called when cfg80211 driver resume |
| 8483 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 8484 | */ |
| 8485 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 8486 | { |
| 8487 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8488 | hdd_adapter_t *pAdapter; |
| 8489 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 8490 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 8491 | |
| 8492 | ENTER(); |
| 8493 | |
| 8494 | if ( NULL == pHddCtx ) |
| 8495 | { |
| 8496 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8497 | "%s: HddCtx validation failed", __func__); |
| 8498 | return 0; |
| 8499 | } |
| 8500 | |
| 8501 | if (pHddCtx->isLogpInProgress) |
| 8502 | { |
| 8503 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8504 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8505 | return 0; |
| 8506 | } |
| 8507 | |
| 8508 | if (pHddCtx->isLoadUnloadInProgress) |
| 8509 | { |
| 8510 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8511 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 8512 | return 0; |
| 8513 | } |
| 8514 | |
| 8515 | spin_lock(&pHddCtx->schedScan_lock); |
| 8516 | pHddCtx->isWiphySuspended = FALSE; |
| 8517 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 8518 | { |
| 8519 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8520 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8521 | "%s: Return resume is not due to PNO indication", __func__); |
| 8522 | return 0; |
| 8523 | } |
| 8524 | // Reset flag to avoid updatating cfg80211 data old results again |
| 8525 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 8526 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8527 | |
| 8528 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8529 | |
| 8530 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 8531 | { |
| 8532 | pAdapter = pAdapterNode->pAdapter; |
| 8533 | if ( (NULL != pAdapter) && |
| 8534 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 8535 | { |
| 8536 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
| 8537 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 8538 | "%s: NO SCAN result", __func__); |
| 8539 | else |
| 8540 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
| 8541 | |
| 8542 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8543 | "%s : cfg80211 scan result database updated", __func__); |
| 8544 | |
| 8545 | return 0; |
| 8546 | |
| 8547 | } |
| 8548 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8549 | pAdapterNode = pNext; |
| 8550 | } |
| 8551 | |
| 8552 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8553 | "%s: Failed to find Adapter", __func__); |
| 8554 | return 0; |
| 8555 | } |
| 8556 | |
| 8557 | /* |
| 8558 | * FUNCTION: wlan_hdd_cfg80211_suspend_wlan |
| 8559 | * this is called when cfg80211 driver suspends |
| 8560 | */ |
| 8561 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 8562 | struct cfg80211_wowlan *wow) |
| 8563 | { |
| 8564 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8565 | |
| 8566 | ENTER(); |
| 8567 | if (NULL == pHddCtx) |
| 8568 | { |
| 8569 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8570 | "%s: HddCtx validation failed", __func__); |
| 8571 | return 0; |
| 8572 | } |
| 8573 | |
| 8574 | pHddCtx->isWiphySuspended = TRUE; |
| 8575 | |
| 8576 | EXIT(); |
| 8577 | |
| 8578 | return 0; |
| 8579 | } |
| 8580 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8581 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8582 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8583 | { |
| 8584 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 8585 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 8586 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 8587 | .change_station = wlan_hdd_change_station, |
| 8588 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 8589 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 8590 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 8591 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8592 | #else |
| 8593 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 8594 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 8595 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8596 | #endif |
| 8597 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 8598 | .add_key = wlan_hdd_cfg80211_add_key, |
| 8599 | .get_key = wlan_hdd_cfg80211_get_key, |
| 8600 | .del_key = wlan_hdd_cfg80211_del_key, |
| 8601 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8602 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8603 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8604 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8605 | .scan = wlan_hdd_cfg80211_scan, |
| 8606 | .connect = wlan_hdd_cfg80211_connect, |
| 8607 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 8608 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 8609 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 8610 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 8611 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 8612 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8613 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 8614 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 8615 | .mgmt_tx = wlan_hdd_action, |
| 8616 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 8617 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 8618 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 8619 | .set_txq_params = wlan_hdd_set_txq_params, |
| 8620 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8621 | .get_station = wlan_hdd_cfg80211_get_station, |
| 8622 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 8623 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8624 | .add_station = wlan_hdd_cfg80211_add_station, |
| 8625 | #ifdef FEATURE_WLAN_LFR |
| 8626 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 8627 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 8628 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 8629 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8630 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 8631 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 8632 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8633 | #ifdef FEATURE_WLAN_TDLS |
| 8634 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 8635 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 8636 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8637 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8638 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 8639 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8640 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8641 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 8642 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 8643 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8644 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 8645 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8646 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8647 | #ifdef WLAN_NL80211_TESTMODE |
| 8648 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 8649 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8650 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8651 | }; |
| 8652 | |