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 | { |
Madan Mohan Koyyalamudi | 99ba358 | 2013-05-16 12:52:48 +0530 | [diff] [blame] | 648 | /* This will disable updating of NL channels from passive to |
| 649 | * active if a beacon is received on passive channel. */ |
| 650 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 651 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
| 652 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 653 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 654 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 655 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 656 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 657 | | WIPHY_FLAG_OFFCHAN_TX; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 658 | #endif |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 659 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 660 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 661 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 662 | || pCfg->isFastRoamIniFeatureEnabled |
| 663 | #endif |
| 664 | #ifdef FEATURE_WLAN_CCX |
| 665 | || pCfg->isCcxIniFeatureEnabled |
| 666 | #endif |
| 667 | ) |
| 668 | { |
| 669 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 670 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 671 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 672 | #ifdef FEATURE_WLAN_TDLS |
| 673 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 674 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 675 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 676 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 677 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 678 | wiphy->max_sched_scan_ssids = MAX_SCAN_SSID; |
| 679 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 680 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 681 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 682 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 683 | driver can still register regulatory callback and |
| 684 | it will get CRDA setting in wiphy->band[], but |
| 685 | driver need to determine what to do with both |
| 686 | regulatory settings */ |
| 687 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 688 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 689 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 690 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 691 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 692 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 693 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 694 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 695 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 696 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 697 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 698 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 699 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 700 | | BIT(NL80211_IFTYPE_AP); |
| 701 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 702 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 703 | if( pCfg->enableMCC ) |
| 704 | { |
| 705 | /* Currently, supports up to two channels */ |
| 706 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 707 | |
| 708 | if( !pCfg->allowMCCGODiffBI ) |
| 709 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 710 | |
| 711 | } |
| 712 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 713 | wiphy->n_iface_combinations = 1; |
| 714 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 715 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 716 | /* Before registering we need to update the ht capabilitied based |
| 717 | * on ini values*/ |
| 718 | if( !pCfg->ShortGI20MhzEnable ) |
| 719 | { |
| 720 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 721 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 722 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 723 | } |
| 724 | |
| 725 | if( !pCfg->ShortGI40MhzEnable ) |
| 726 | { |
| 727 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 728 | } |
| 729 | |
| 730 | if( !pCfg->nChannelBondingMode5GHz ) |
| 731 | { |
| 732 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 733 | } |
| 734 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 735 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 736 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 737 | |
| 738 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 739 | { |
| 740 | |
| 741 | if (NULL == wiphy->bands[i]) |
| 742 | { |
| 743 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 744 | __func__, i); |
| 745 | continue; |
| 746 | } |
| 747 | |
| 748 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 749 | { |
| 750 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 751 | |
| 752 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 753 | { |
| 754 | // Enable social channels for P2P |
| 755 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 756 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 757 | else |
| 758 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 759 | continue; |
| 760 | } |
| 761 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 762 | { |
| 763 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 764 | continue; |
| 765 | } |
| 766 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 767 | } |
| 768 | /*Initialise the supported cipher suite details*/ |
| 769 | wiphy->cipher_suites = hdd_cipher_suites; |
| 770 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 771 | |
| 772 | /*signal strength in mBm (100*dBm) */ |
| 773 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 774 | |
| 775 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 776 | wiphy->max_remain_on_channel_duration = 1000; |
| 777 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 778 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 779 | EXIT(); |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | /* In this function we are registering wiphy. */ |
| 784 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 785 | { |
| 786 | ENTER(); |
| 787 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 788 | if (0 > wiphy_register(wiphy)) |
| 789 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 790 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 791 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 792 | return -EIO; |
| 793 | } |
| 794 | |
| 795 | EXIT(); |
| 796 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 797 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 798 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 799 | /* In this function we will try to get default country code from crda. |
| 800 | If the gCrdaDefaultCountryCode is configured in ini file, |
| 801 | we will try to call user space crda to get the regulatory settings for |
| 802 | 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] | 803 | 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] | 804 | */ |
| 805 | int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg) |
| 806 | { |
| 807 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Madan Mohan Koyyalamudi | 113ac74 | 2013-08-06 22:45:43 +0530 | [diff] [blame] | 808 | int status; |
| 809 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 810 | if (memcmp(pCfg->crdaDefaultCountryCode, |
| 811 | CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0) |
| 812 | { |
Madan Mohan Koyyalamudi | 113ac74 | 2013-08-06 22:45:43 +0530 | [diff] [blame] | 813 | INIT_COMPLETION(pHddCtx->driver_crda_req); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 814 | regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode); |
Madan Mohan Koyyalamudi | 113ac74 | 2013-08-06 22:45:43 +0530 | [diff] [blame] | 815 | status = wait_for_completion_interruptible_timeout( |
| 816 | &pHddCtx->driver_crda_req, |
| 817 | msecs_to_jiffies(CRDA_WAIT_TIME)); |
| 818 | if (!status) |
| 819 | { |
| 820 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: timeout waiting for CRDA REQ", |
| 821 | __func__); |
| 822 | } |
| 823 | |
Yunsen Wang | e3ba1fb | 2013-04-05 15:04:43 -0700 | [diff] [blame] | 824 | /* if the country is not found from current regulatory.bin, |
| 825 | fall back to world domain */ |
| 826 | if (is_crda_regulatory_entry_valid() == VOS_FALSE) |
| 827 | crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 828 | } |
| 829 | return 0; |
| 830 | } |
| 831 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 832 | /* In this function we are updating channel list when, |
| 833 | regulatory domain is FCC and country code is US. |
| 834 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 835 | As per FCC smart phone is not a indoor device. |
| 836 | GO should not opeate on indoor channels */ |
| 837 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 838 | { |
| 839 | int j; |
| 840 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 841 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 842 | //Default counrtycode from NV at the time of wiphy initialization. |
| 843 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 844 | &defaultCountryCode[0])) |
| 845 | { |
| 846 | hddLog(LOGE, FL("%s Failed to get default country code from NV")); |
| 847 | } |
| 848 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 849 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 850 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 851 | { |
| 852 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 853 | return; |
| 854 | } |
| 855 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 856 | { |
| 857 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 858 | // Mark UNII -1 band channel as passive |
| 859 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 860 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 865 | /* In this function we will do all post VOS start initialization. |
| 866 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 867 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 868 | */ |
| 869 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 870 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 871 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 872 | /* Register for all P2P action, public action etc frames */ |
| 873 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 874 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 875 | ENTER(); |
| 876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 877 | /* Right now we are registering these frame when driver is getting |
| 878 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 879 | frame register ops, we will move this code as a part of that */ |
| 880 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 881 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 882 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 883 | |
| 884 | /* GAS Initial Response */ |
| 885 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 886 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 887 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 888 | /* GAS Comeback Request */ |
| 889 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 890 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 891 | |
| 892 | /* GAS Comeback Response */ |
| 893 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 894 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 895 | |
| 896 | /* P2P Public Action */ |
| 897 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 898 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 899 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 900 | |
| 901 | /* P2P Action */ |
| 902 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 903 | (v_U8_t*)P2P_ACTION_FRAME, |
| 904 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 905 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 906 | /* WNM BSS Transition Request frame */ |
| 907 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 908 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 909 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 910 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 911 | #ifdef WLAN_FEATURE_11W |
| 912 | /* SA Query Response Action Frame */ |
| 913 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 914 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 915 | SA_QUERY_FRAME_RSP_SIZE ); |
| 916 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 920 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 921 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 922 | /* Register for all P2P action, public action etc frames */ |
| 923 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 924 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 925 | ENTER(); |
| 926 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 927 | /* Right now we are registering these frame when driver is getting |
| 928 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 929 | frame register ops, we will move this code as a part of that */ |
| 930 | /* GAS Initial Request */ |
| 931 | |
| 932 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 933 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 934 | |
| 935 | /* GAS Initial Response */ |
| 936 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 937 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 938 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 939 | /* GAS Comeback Request */ |
| 940 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 941 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 942 | |
| 943 | /* GAS Comeback Response */ |
| 944 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 945 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 946 | |
| 947 | /* P2P Public Action */ |
| 948 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 949 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 950 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 951 | |
| 952 | /* P2P Action */ |
| 953 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 954 | (v_U8_t*)P2P_ACTION_FRAME, |
| 955 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 956 | |
| 957 | #ifdef WLAN_FEATURE_11W |
| 958 | /* SA Query Response Action Frame */ |
| 959 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 960 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 961 | SA_QUERY_FRAME_RSP_SIZE ); |
| 962 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | #ifdef FEATURE_WLAN_WAPI |
| 966 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 967 | const u8 *mac_addr, u8 *key , int key_Len) |
| 968 | { |
| 969 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 970 | tCsrRoamSetKey setKey; |
| 971 | v_BOOL_t isConnected = TRUE; |
| 972 | int status = 0; |
| 973 | v_U32_t roamId= 0xFF; |
| 974 | tANI_U8 *pKeyPtr = NULL; |
| 975 | int n = 0; |
| 976 | |
| 977 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 978 | __func__,pAdapter->device_mode); |
| 979 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 980 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 981 | setKey.keyId = key_index; // Store Key ID |
| 982 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 983 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 984 | setKey.paeRole = 0 ; // the PAE role |
| 985 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 986 | { |
| 987 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 988 | } |
| 989 | else |
| 990 | { |
| 991 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 992 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 993 | } |
| 994 | setKey.keyLength = key_Len; |
| 995 | pKeyPtr = setKey.Key; |
| 996 | memcpy( pKeyPtr, key, key_Len); |
| 997 | |
| 998 | hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x", |
| 999 | __func__, key_Len); |
| 1000 | for (n = 0 ; n < key_Len; n++) |
| 1001 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 1002 | __func__,n,setKey.Key[n]); |
| 1003 | |
| 1004 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 1005 | if ( isConnected ) |
| 1006 | { |
| 1007 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1008 | pAdapter->sessionId, &setKey, &roamId ); |
| 1009 | } |
| 1010 | if ( status != 0 ) |
| 1011 | { |
| 1012 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1013 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 1014 | __LINE__, status ); |
| 1015 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 1016 | } |
| 1017 | } |
| 1018 | #endif /* FEATURE_WLAN_WAPI*/ |
| 1019 | |
| 1020 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1021 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1022 | beacon_data_t **ppBeacon, |
| 1023 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1024 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1025 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1026 | beacon_data_t **ppBeacon, |
| 1027 | struct cfg80211_beacon_data *params, |
| 1028 | int dtim_period) |
| 1029 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1030 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1031 | int size; |
| 1032 | beacon_data_t *beacon = NULL; |
| 1033 | beacon_data_t *old = NULL; |
| 1034 | int head_len,tail_len; |
| 1035 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1036 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1037 | if (params->head && !params->head_len) |
| 1038 | return -EINVAL; |
| 1039 | |
| 1040 | old = pAdapter->sessionCtx.ap.beacon; |
| 1041 | |
| 1042 | if (!params->head && !old) |
| 1043 | return -EINVAL; |
| 1044 | |
| 1045 | if (params->tail && !params->tail_len) |
| 1046 | return -EINVAL; |
| 1047 | |
| 1048 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 1049 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 1050 | if (!params->dtim_period) |
| 1051 | return -EINVAL; |
| 1052 | #endif |
| 1053 | |
| 1054 | if(params->head) |
| 1055 | head_len = params->head_len; |
| 1056 | else |
| 1057 | head_len = old->head_len; |
| 1058 | |
| 1059 | if(params->tail || !old) |
| 1060 | tail_len = params->tail_len; |
| 1061 | else |
| 1062 | tail_len = old->tail_len; |
| 1063 | |
| 1064 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 1065 | |
| 1066 | beacon = kzalloc(size, GFP_KERNEL); |
| 1067 | |
| 1068 | if( beacon == NULL ) |
| 1069 | return -ENOMEM; |
| 1070 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1071 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1072 | if(params->dtim_period || !old ) |
| 1073 | beacon->dtim_period = params->dtim_period; |
| 1074 | else |
| 1075 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1076 | #else |
| 1077 | if(dtim_period || !old ) |
| 1078 | beacon->dtim_period = dtim_period; |
| 1079 | else |
| 1080 | beacon->dtim_period = old->dtim_period; |
| 1081 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1082 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1083 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 1084 | beacon->tail = beacon->head + head_len; |
| 1085 | beacon->head_len = head_len; |
| 1086 | beacon->tail_len = tail_len; |
| 1087 | |
| 1088 | if(params->head) { |
| 1089 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1090 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1091 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1092 | if(old) |
| 1093 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1094 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1095 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1096 | if(params->tail) { |
| 1097 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1098 | } |
| 1099 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1100 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1101 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1102 | } |
| 1103 | |
| 1104 | *ppBeacon = beacon; |
| 1105 | |
| 1106 | kfree(old); |
| 1107 | |
| 1108 | return 0; |
| 1109 | |
| 1110 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1111 | |
| 1112 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1113 | { |
| 1114 | int left = length; |
| 1115 | v_U8_t *ptr = pIes; |
| 1116 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1117 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1118 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1119 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1120 | elem_id = ptr[0]; |
| 1121 | elem_len = ptr[1]; |
| 1122 | left -= 2; |
| 1123 | if(elem_len > left) |
| 1124 | { |
| 1125 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1126 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1127 | eid,elem_len,left); |
| 1128 | return NULL; |
| 1129 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1130 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1131 | { |
| 1132 | return ptr; |
| 1133 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1134 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1135 | left -= elem_len; |
| 1136 | ptr += (elem_len + 2); |
| 1137 | } |
| 1138 | return NULL; |
| 1139 | } |
| 1140 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1141 | /* Check if rate is 11g rate or not */ |
| 1142 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1143 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 1144 | 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] | 1145 | u8 i; |
| 1146 | for (i = 0; i < 8; i++) |
| 1147 | { |
| 1148 | if(rate == gRateArray[i]) |
| 1149 | return TRUE; |
| 1150 | } |
| 1151 | return FALSE; |
| 1152 | } |
| 1153 | |
| 1154 | /* Check for 11g rate and set proper 11g only mode */ |
| 1155 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1156 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1157 | { |
| 1158 | u8 i, num_rates = pIe[0]; |
| 1159 | |
| 1160 | pIe += 1; |
| 1161 | for ( i = 0; i < num_rates; i++) |
| 1162 | { |
| 1163 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1164 | { |
| 1165 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1166 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1167 | if (pIe[i] & BASIC_RATE_MASK) |
| 1168 | { |
| 1169 | /* If we have 11g rate as basic rate, it means mode |
| 1170 | is 11g only mode. |
| 1171 | */ |
| 1172 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1173 | *pCheckRatesfor11g = FALSE; |
| 1174 | } |
| 1175 | } |
| 1176 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1177 | { |
| 1178 | *require_ht = TRUE; |
| 1179 | } |
| 1180 | } |
| 1181 | return; |
| 1182 | } |
| 1183 | |
| 1184 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1185 | { |
| 1186 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1187 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1188 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1189 | u8 checkRatesfor11g = TRUE; |
| 1190 | u8 require_ht = FALSE; |
| 1191 | u8 *pIe=NULL; |
| 1192 | |
| 1193 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1194 | |
| 1195 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1196 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1197 | if (pIe != NULL) |
| 1198 | { |
| 1199 | pIe += 1; |
| 1200 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1201 | &pConfig->SapHw_mode); |
| 1202 | } |
| 1203 | |
| 1204 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1205 | WLAN_EID_EXT_SUPP_RATES); |
| 1206 | if (pIe != NULL) |
| 1207 | { |
| 1208 | |
| 1209 | pIe += 1; |
| 1210 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1211 | &pConfig->SapHw_mode); |
| 1212 | } |
| 1213 | |
| 1214 | if( pConfig->channel > 14 ) |
| 1215 | { |
| 1216 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1217 | } |
| 1218 | |
| 1219 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1220 | WLAN_EID_HT_CAPABILITY); |
| 1221 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1222 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1223 | { |
| 1224 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1225 | if(require_ht) |
| 1226 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1227 | } |
| 1228 | } |
| 1229 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1230 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1231 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1232 | { |
| 1233 | v_U8_t ielen = 0; |
| 1234 | v_U8_t *pIe = NULL; |
| 1235 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1236 | |
| 1237 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1238 | pBeacon->tail, pBeacon->tail_len); |
| 1239 | |
| 1240 | if (pIe) |
| 1241 | { |
| 1242 | ielen = pIe[1] + 2; |
| 1243 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1244 | { |
| 1245 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1246 | } |
| 1247 | else |
| 1248 | { |
| 1249 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1250 | return -EINVAL; |
| 1251 | } |
| 1252 | *total_ielen += ielen; |
| 1253 | } |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1257 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1258 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1259 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1260 | #else |
| 1261 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1262 | struct cfg80211_beacon_data *params) |
| 1263 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1264 | { |
| 1265 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1266 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1267 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1268 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1269 | |
| 1270 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1271 | |
| 1272 | if(genie == NULL) { |
| 1273 | |
| 1274 | return -ENOMEM; |
| 1275 | } |
| 1276 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1277 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1278 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1279 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1280 | ret = -EINVAL; |
| 1281 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1285 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1286 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1287 | { |
| 1288 | ret = -EINVAL; |
| 1289 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1290 | } |
| 1291 | #endif |
| 1292 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1293 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1294 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1295 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1296 | ret = -EINVAL; |
| 1297 | goto done; |
| 1298 | } |
| 1299 | |
| 1300 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1301 | { |
| 1302 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1303 | &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1304 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1305 | ret = -EINVAL; |
| 1306 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1307 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1308 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1309 | |
| 1310 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1311 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1312 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1313 | { |
| 1314 | hddLog(LOGE, |
| 1315 | "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] | 1316 | ret = -EINVAL; |
| 1317 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1321 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1322 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1323 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1324 | ==eHAL_STATUS_FAILURE) |
| 1325 | { |
| 1326 | hddLog(LOGE, |
| 1327 | "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] | 1328 | ret = -EINVAL; |
| 1329 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | // Added for ProResp IE |
| 1333 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1334 | { |
| 1335 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1336 | u8 probe_rsp_ie_len[3] = {0}; |
| 1337 | u8 counter = 0; |
| 1338 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1339 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1340 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1341 | Store More then 255 bytes into One Variable. |
| 1342 | */ |
| 1343 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1344 | { |
| 1345 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1346 | { |
| 1347 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1348 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1349 | } |
| 1350 | else |
| 1351 | { |
| 1352 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1353 | rem_probe_resp_ie_len = 0; |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | rem_probe_resp_ie_len = 0; |
| 1358 | |
| 1359 | if (probe_rsp_ie_len[0] > 0) |
| 1360 | { |
| 1361 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1362 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1363 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1364 | probe_rsp_ie_len[0], NULL, |
| 1365 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1366 | { |
| 1367 | hddLog(LOGE, |
| 1368 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1369 | ret = -EINVAL; |
| 1370 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1371 | } |
| 1372 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1373 | } |
| 1374 | |
| 1375 | if (probe_rsp_ie_len[1] > 0) |
| 1376 | { |
| 1377 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1378 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1379 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1380 | probe_rsp_ie_len[1], NULL, |
| 1381 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1382 | { |
| 1383 | hddLog(LOGE, |
| 1384 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1385 | ret = -EINVAL; |
| 1386 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1387 | } |
| 1388 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1389 | } |
| 1390 | |
| 1391 | if (probe_rsp_ie_len[2] > 0) |
| 1392 | { |
| 1393 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1394 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1395 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1396 | probe_rsp_ie_len[2], NULL, |
| 1397 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1398 | { |
| 1399 | hddLog(LOGE, |
| 1400 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1401 | ret = -EINVAL; |
| 1402 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1403 | } |
| 1404 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1405 | } |
| 1406 | |
| 1407 | if (probe_rsp_ie_len[1] == 0 ) |
| 1408 | { |
| 1409 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1410 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1411 | eANI_BOOLEAN_FALSE) ) |
| 1412 | { |
| 1413 | hddLog(LOGE, |
| 1414 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n"); |
| 1415 | } |
| 1416 | } |
| 1417 | |
| 1418 | if (probe_rsp_ie_len[2] == 0 ) |
| 1419 | { |
| 1420 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1421 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1422 | eANI_BOOLEAN_FALSE) ) |
| 1423 | { |
| 1424 | hddLog(LOGE, |
| 1425 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n"); |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1430 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1431 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1432 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1433 | == eHAL_STATUS_FAILURE) |
| 1434 | { |
| 1435 | hddLog(LOGE, |
| 1436 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1437 | ret = -EINVAL; |
| 1438 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1439 | } |
| 1440 | } |
| 1441 | else |
| 1442 | { |
| 1443 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1444 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1445 | |
| 1446 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1447 | "%s: No Probe Response IE received in set beacon", |
| 1448 | __func__); |
| 1449 | } |
| 1450 | |
| 1451 | // Added for AssocResp IE |
| 1452 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1453 | { |
| 1454 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1455 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1456 | params->assocresp_ies_len, NULL, |
| 1457 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1458 | { |
| 1459 | hddLog(LOGE, |
| 1460 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1461 | ret = -EINVAL; |
| 1462 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1463 | } |
| 1464 | |
| 1465 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1466 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1467 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1468 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1469 | == eHAL_STATUS_FAILURE) |
| 1470 | { |
| 1471 | hddLog(LOGE, |
| 1472 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1473 | ret = -EINVAL; |
| 1474 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1475 | } |
| 1476 | } |
| 1477 | else |
| 1478 | { |
| 1479 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1480 | "%s: No Assoc Response IE received in set beacon", |
| 1481 | __func__); |
| 1482 | |
| 1483 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1484 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1485 | eANI_BOOLEAN_FALSE) ) |
| 1486 | { |
| 1487 | hddLog(LOGE, |
| 1488 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 1489 | } |
| 1490 | } |
| 1491 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1492 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1493 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1494 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1495 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1496 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1497 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1498 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1499 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1500 | * wlan_hdd_cfg80211_set_channel() |
| 1501 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1502 | * channel list. |
| 1503 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 1504 | 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] | 1505 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1506 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1507 | v_U32_t num_ch = 0; |
| 1508 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1509 | u32 indx = 0; |
| 1510 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1511 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1512 | 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] | 1513 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1514 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1515 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1516 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1517 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1518 | /* Validate the channel */ |
| 1519 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
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 | if ( channel == rfChannels[count].channelNum ) |
| 1522 | { |
| 1523 | fValidChannel = TRUE; |
| 1524 | break; |
| 1525 | } |
| 1526 | } |
| 1527 | if (fValidChannel != TRUE) |
| 1528 | { |
| 1529 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1530 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1531 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1532 | } |
| 1533 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1534 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1535 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1536 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1537 | valid_ch, &num_ch)) |
| 1538 | { |
| 1539 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1540 | "%s: failed to get valid channel list", __func__); |
| 1541 | return VOS_STATUS_E_FAILURE; |
| 1542 | } |
| 1543 | for (indx = 0; indx < num_ch; indx++) |
| 1544 | { |
| 1545 | if (channel == valid_ch[indx]) |
| 1546 | { |
| 1547 | break; |
| 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | if (indx >= num_ch) |
| 1552 | { |
| 1553 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1554 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1555 | return VOS_STATUS_E_FAILURE; |
| 1556 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1557 | } |
| 1558 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1559 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1560 | } |
| 1561 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1562 | /** |
| 1563 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1564 | * This function is used to set the channel number |
| 1565 | */ |
| 1566 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1567 | struct ieee80211_channel *chan, |
| 1568 | enum nl80211_channel_type channel_type |
| 1569 | ) |
| 1570 | { |
| 1571 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1572 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1573 | hdd_adapter_t *pAdapter = NULL; |
| 1574 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1575 | hdd_context_t *pHddCtx; |
| 1576 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1577 | |
| 1578 | ENTER(); |
| 1579 | |
| 1580 | if( NULL == dev ) |
| 1581 | { |
| 1582 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1583 | "%s: Called with dev = NULL.\n", __func__); |
| 1584 | return -ENODEV; |
| 1585 | } |
| 1586 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1587 | |
| 1588 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1589 | "%s: device_mode = %d freq = %d \n",__func__, |
| 1590 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1591 | |
| 1592 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1593 | status = wlan_hdd_validate_context(pHddCtx); |
| 1594 | |
| 1595 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1596 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1597 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1598 | "%s: HDD context is not valid", __func__); |
| 1599 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1600 | } |
| 1601 | |
| 1602 | /* |
| 1603 | * Do freq to chan conversion |
| 1604 | * TODO: for 11a |
| 1605 | */ |
| 1606 | |
| 1607 | channel = ieee80211_frequency_to_channel(freq); |
| 1608 | |
| 1609 | /* Check freq range */ |
| 1610 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1611 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1612 | { |
| 1613 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1614 | "%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1615 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1616 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1617 | return -EINVAL; |
| 1618 | } |
| 1619 | |
| 1620 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1621 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1622 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1623 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1624 | { |
| 1625 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1626 | { |
| 1627 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1628 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1629 | return -EINVAL; |
| 1630 | } |
| 1631 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1632 | "%s: set channel to [%d] for device mode =%d", |
| 1633 | __func__, channel,pAdapter->device_mode); |
| 1634 | } |
| 1635 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1636 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1637 | ) |
| 1638 | { |
| 1639 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1640 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1641 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1642 | |
| 1643 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1644 | { |
| 1645 | /* Link is up then return cant set channel*/ |
| 1646 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1647 | "%s: IBSS Associated, can't set the channel\n", __func__); |
| 1648 | return -EINVAL; |
| 1649 | } |
| 1650 | |
| 1651 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1652 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1653 | pRoamProfile->ChannelInfo.ChannelList = |
| 1654 | &pHddStaCtx->conn_info.operationChannel; |
| 1655 | } |
| 1656 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1657 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1658 | ) |
| 1659 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1660 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1661 | { |
| 1662 | if(VOS_STATUS_SUCCESS != |
| 1663 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1664 | { |
| 1665 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1666 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1667 | return -EINVAL; |
| 1668 | } |
| 1669 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1670 | } |
| 1671 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1672 | { |
| 1673 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1674 | |
| 1675 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1676 | channel set by supplicant |
| 1677 | */ |
| 1678 | if ( cfg_param->apAutoChannelSelection ) |
| 1679 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1680 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1681 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1682 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1683 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1684 | __func__, pAdapter->device_mode); |
| 1685 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1686 | else |
| 1687 | { |
| 1688 | if(VOS_STATUS_SUCCESS != |
| 1689 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1690 | { |
| 1691 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1692 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1693 | return -EINVAL; |
| 1694 | } |
| 1695 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1696 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1697 | } |
| 1698 | } |
| 1699 | else |
| 1700 | { |
| 1701 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1702 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1703 | return -EINVAL; |
| 1704 | } |
| 1705 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1706 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1707 | } |
| 1708 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1709 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1710 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1711 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1712 | #else |
| 1713 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1714 | struct cfg80211_beacon_data *params, |
| 1715 | const u8 *ssid, size_t ssid_len, |
| 1716 | enum nl80211_hidden_ssid hidden_ssid) |
| 1717 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1718 | { |
| 1719 | tsap_Config_t *pConfig; |
| 1720 | beacon_data_t *pBeacon = NULL; |
| 1721 | struct ieee80211_mgmt *pMgmt_frame; |
| 1722 | v_U8_t *pIe=NULL; |
| 1723 | v_U16_t capab_info; |
| 1724 | eCsrAuthType RSNAuthType; |
| 1725 | eCsrEncryptionType RSNEncryptType; |
| 1726 | eCsrEncryptionType mcRSNEncryptType; |
| 1727 | int status = VOS_STATUS_SUCCESS; |
| 1728 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1729 | hdd_hostapd_state_t *pHostapdState; |
| 1730 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1731 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1732 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1733 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1734 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1735 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1736 | |
| 1737 | ENTER(); |
| 1738 | |
| 1739 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1740 | |
| 1741 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1742 | |
| 1743 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1744 | |
| 1745 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1746 | |
| 1747 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1748 | |
| 1749 | //channel is already set in the set_channel Call back |
| 1750 | //pConfig->channel = pCommitConfig->channel; |
| 1751 | |
| 1752 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1753 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1754 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1755 | |
| 1756 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1757 | |
| 1758 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1759 | pConfig->dtim_period); |
| 1760 | |
| 1761 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1762 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1763 | { |
| 1764 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1765 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1766 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1767 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1768 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1769 | pConfig->ieee80211d = 1; |
| 1770 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1771 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1772 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1773 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1774 | else |
| 1775 | { |
| 1776 | pConfig->ieee80211d = 0; |
| 1777 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1778 | /* |
| 1779 | * If auto channel is configured i.e. channel is 0, |
| 1780 | * so skip channel validation. |
| 1781 | */ |
| 1782 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1783 | { |
| 1784 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1785 | { |
| 1786 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1787 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1788 | return -EINVAL; |
| 1789 | } |
| 1790 | } |
| 1791 | else |
| 1792 | { |
| 1793 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1794 | { |
| 1795 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1796 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1797 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1798 | } |
| 1799 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1800 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1801 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1802 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1803 | { |
| 1804 | pConfig->ieee80211d = 0; |
| 1805 | } |
| 1806 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1807 | |
| 1808 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1809 | |
| 1810 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1811 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1812 | |
| 1813 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1814 | |
| 1815 | /*Set wps station to configured*/ |
| 1816 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1817 | |
| 1818 | if(pIe) |
| 1819 | { |
| 1820 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1821 | { |
| 1822 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1823 | return -EINVAL; |
| 1824 | } |
| 1825 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1826 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1827 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1828 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1829 | * WPS state |
| 1830 | */ |
| 1831 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1832 | { |
| 1833 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1834 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1835 | { |
| 1836 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1837 | } |
| 1838 | } |
| 1839 | } |
| 1840 | else |
| 1841 | { |
| 1842 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1843 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1844 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1845 | |
| 1846 | pConfig->RSNWPAReqIELength = 0; |
| 1847 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1848 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1849 | WLAN_EID_RSN); |
| 1850 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1851 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1852 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1853 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1854 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1855 | /* The actual processing may eventually be more extensive than |
| 1856 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1857 | * by the app. |
| 1858 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1859 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1860 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1861 | &RSNEncryptType, |
| 1862 | &mcRSNEncryptType, |
| 1863 | &RSNAuthType, |
| 1864 | pConfig->pRSNWPAReqIE[1]+2, |
| 1865 | pConfig->pRSNWPAReqIE ); |
| 1866 | |
| 1867 | if( VOS_STATUS_SUCCESS == status ) |
| 1868 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1869 | /* Now copy over all the security attributes you have |
| 1870 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1871 | * */ |
| 1872 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1873 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1874 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1875 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1876 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1877 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1878 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1879 | } |
| 1880 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1881 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1882 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1883 | pBeacon->tail, pBeacon->tail_len); |
| 1884 | |
| 1885 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1886 | { |
| 1887 | if (pConfig->pRSNWPAReqIE) |
| 1888 | { |
| 1889 | /*Mixed mode WPA/WPA2*/ |
| 1890 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1891 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1892 | } |
| 1893 | else |
| 1894 | { |
| 1895 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1896 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1897 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1898 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1899 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1900 | &RSNEncryptType, |
| 1901 | &mcRSNEncryptType, |
| 1902 | &RSNAuthType, |
| 1903 | pConfig->pRSNWPAReqIE[1]+2, |
| 1904 | pConfig->pRSNWPAReqIE ); |
| 1905 | |
| 1906 | if( VOS_STATUS_SUCCESS == status ) |
| 1907 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1908 | /* Now copy over all the security attributes you have |
| 1909 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1910 | * */ |
| 1911 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1912 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1913 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1914 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1915 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1916 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1917 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1918 | } |
| 1919 | } |
| 1920 | } |
| 1921 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1922 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1923 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1924 | return -EINVAL; |
| 1925 | } |
| 1926 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1927 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1928 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1929 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1930 | if (params->ssid != NULL) |
| 1931 | { |
| 1932 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1933 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1934 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1935 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1936 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1937 | #else |
| 1938 | if (ssid != NULL) |
| 1939 | { |
| 1940 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1941 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1942 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1943 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1944 | } |
| 1945 | #endif |
| 1946 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1947 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1948 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1949 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1950 | /* default value */ |
| 1951 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1952 | pConfig->num_accept_mac = 0; |
| 1953 | pConfig->num_deny_mac = 0; |
| 1954 | |
| 1955 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1956 | pBeacon->tail, pBeacon->tail_len); |
| 1957 | |
| 1958 | /* pIe for black list is following form: |
| 1959 | type : 1 byte |
| 1960 | length : 1 byte |
| 1961 | OUI : 4 bytes |
| 1962 | acl type : 1 byte |
| 1963 | no of mac addr in black list: 1 byte |
| 1964 | 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] | 1965 | */ |
| 1966 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1967 | { |
| 1968 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1969 | pConfig->num_deny_mac = pIe[7]; |
| 1970 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1971 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1972 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 1973 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1974 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1975 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1976 | { |
| 1977 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1978 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1979 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1980 | } |
| 1981 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1982 | pBeacon->tail, pBeacon->tail_len); |
| 1983 | |
| 1984 | /* pIe for white list is following form: |
| 1985 | type : 1 byte |
| 1986 | length : 1 byte |
| 1987 | OUI : 4 bytes |
| 1988 | acl type : 1 byte |
| 1989 | no of mac addr in white list: 1 byte |
| 1990 | 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] | 1991 | */ |
| 1992 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1993 | { |
| 1994 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1995 | pConfig->num_accept_mac = pIe[7]; |
| 1996 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 1997 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1998 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 1999 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2000 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2001 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 2002 | { |
| 2003 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2004 | acl_entry++; |
| 2005 | } |
| 2006 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2007 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2008 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 2009 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2010 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2011 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 2012 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 2013 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 2014 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 2015 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2016 | (((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] | 2017 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 2018 | ((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] | 2019 | { |
| 2020 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 2021 | |
| 2022 | /* Disable VHT support in 2.4 GHz band */ |
| 2023 | if (pConfig->channel <= 14 && |
| 2024 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE) |
| 2025 | { |
| 2026 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 2027 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2028 | } |
| 2029 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2030 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 2031 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 2032 | { |
| 2033 | sme_SelectCBMode(hHal, |
| 2034 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 2035 | pConfig->channel); |
| 2036 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2037 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 2038 | pConfig->ht_capab = |
| 2039 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 2040 | |
| 2041 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 2042 | { |
| 2043 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 2044 | return -EINVAL; |
| 2045 | } |
| 2046 | |
| 2047 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2048 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2049 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 2050 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2051 | pConfig->obssProtEnabled = |
| 2052 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2053 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2054 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2055 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2056 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2057 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 2058 | (int)pConfig->channel); |
| 2059 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2060 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 2061 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2062 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2063 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2064 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 2065 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 2066 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2067 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2068 | { |
| 2069 | //Bss already started. just return. |
| 2070 | //TODO Probably it should update some beacon params. |
| 2071 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 2072 | EXIT(); |
| 2073 | return 0; |
| 2074 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2075 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2076 | pConfig->persona = pHostapdAdapter->device_mode; |
| 2077 | |
| 2078 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 2079 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 2080 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 2081 | { |
| 2082 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 2083 | return -EINVAL; |
| 2084 | } |
| 2085 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2086 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2087 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2088 | |
| 2089 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2090 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2091 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2092 | { |
| 2093 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2094 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2095 | VOS_ASSERT(0); |
| 2096 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2097 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2098 | //Succesfully started Bss update the state bit. |
| 2099 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2100 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2101 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2102 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2103 | { |
| 2104 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2105 | { |
| 2106 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2107 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2108 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2109 | } |
| 2110 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2111 | { |
| 2112 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2113 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2114 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2115 | } |
| 2116 | } |
| 2117 | #endif |
| 2118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2119 | pHostapdState->bCommit = TRUE; |
| 2120 | EXIT(); |
| 2121 | |
| 2122 | return 0; |
| 2123 | } |
| 2124 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2125 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2126 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2127 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2128 | struct beacon_parameters *params) |
| 2129 | { |
| 2130 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2131 | hdd_context_t *pHddCtx; |
| 2132 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2133 | |
| 2134 | ENTER(); |
| 2135 | |
| 2136 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 2137 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2138 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2139 | status = wlan_hdd_validate_context(pHddCtx); |
| 2140 | |
| 2141 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2142 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2143 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2144 | "%s: HDD context is not valid", __func__); |
| 2145 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2146 | } |
| 2147 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2148 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2149 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2150 | ) |
| 2151 | { |
| 2152 | beacon_data_t *old,*new; |
| 2153 | |
| 2154 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2155 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2156 | if (old) |
| 2157 | return -EALREADY; |
| 2158 | |
| 2159 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2160 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2161 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2162 | { |
| 2163 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2164 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 2165 | return -EINVAL; |
| 2166 | } |
| 2167 | |
| 2168 | pAdapter->sessionCtx.ap.beacon = new; |
| 2169 | |
| 2170 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2171 | } |
| 2172 | |
| 2173 | EXIT(); |
| 2174 | return status; |
| 2175 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2176 | |
| 2177 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2178 | struct net_device *dev, |
| 2179 | struct beacon_parameters *params) |
| 2180 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2181 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2182 | hdd_context_t *pHddCtx; |
| 2183 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2184 | |
| 2185 | ENTER(); |
| 2186 | |
| 2187 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2188 | __func__,pAdapter->device_mode); |
| 2189 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2190 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2191 | status = wlan_hdd_validate_context(pHddCtx); |
| 2192 | |
| 2193 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2194 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2195 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2196 | "%s: HDD context is not valid", __func__); |
| 2197 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2198 | } |
| 2199 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2200 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2201 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2202 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2203 | { |
| 2204 | beacon_data_t *old,*new; |
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 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2208 | if (!old) |
| 2209 | return -ENOENT; |
| 2210 | |
| 2211 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2212 | |
| 2213 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2214 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2215 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2216 | return -EINVAL; |
| 2217 | } |
| 2218 | |
| 2219 | pAdapter->sessionCtx.ap.beacon = new; |
| 2220 | |
| 2221 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2222 | } |
| 2223 | |
| 2224 | EXIT(); |
| 2225 | return status; |
| 2226 | } |
| 2227 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2228 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2229 | |
| 2230 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2231 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2232 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2233 | #else |
| 2234 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2235 | struct net_device *dev) |
| 2236 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2237 | { |
| 2238 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2239 | hdd_context_t *pHddCtx = NULL; |
| 2240 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2241 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2242 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2243 | |
| 2244 | ENTER(); |
| 2245 | |
| 2246 | if (NULL == pAdapter) |
| 2247 | { |
| 2248 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2249 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2250 | return -ENODEV; |
| 2251 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2252 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2253 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2254 | status = wlan_hdd_validate_context(pHddCtx); |
| 2255 | |
| 2256 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2257 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2258 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2259 | "%s: HDD context is not valid", __func__); |
| 2260 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2261 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2262 | |
| 2263 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2264 | if (NULL == staAdapter) |
| 2265 | { |
| 2266 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2267 | if (NULL == staAdapter) |
| 2268 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2269 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2270 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2271 | return -ENODEV; |
| 2272 | } |
| 2273 | } |
| 2274 | |
| 2275 | pScanInfo = &pHddCtx->scan_info; |
| 2276 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2277 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2278 | __func__,pAdapter->device_mode); |
| 2279 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2280 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2281 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2282 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame^] | 2283 | hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2284 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2285 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2286 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2287 | if (!status) |
| 2288 | { |
| 2289 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2290 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2291 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2292 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2293 | return 0; |
| 2294 | } |
| 2295 | } |
| 2296 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2297 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2298 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2299 | ) |
| 2300 | { |
| 2301 | beacon_data_t *old; |
| 2302 | |
| 2303 | old = pAdapter->sessionCtx.ap.beacon; |
| 2304 | |
| 2305 | if (!old) |
| 2306 | return -ENOENT; |
| 2307 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2308 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2309 | |
| 2310 | mutex_lock(&pHddCtx->sap_lock); |
| 2311 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2312 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2313 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2314 | { |
| 2315 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2316 | |
| 2317 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2318 | |
| 2319 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2320 | { |
| 2321 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2322 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2323 | VOS_ASSERT(0); |
| 2324 | } |
| 2325 | } |
| 2326 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2327 | } |
| 2328 | mutex_unlock(&pHddCtx->sap_lock); |
| 2329 | |
| 2330 | if(status != VOS_STATUS_SUCCESS) |
| 2331 | { |
| 2332 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2333 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2334 | return -EINVAL; |
| 2335 | } |
| 2336 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2337 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2338 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2339 | ==eHAL_STATUS_FAILURE) |
| 2340 | { |
| 2341 | hddLog(LOGE, |
| 2342 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2343 | } |
| 2344 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2345 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2346 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2347 | eANI_BOOLEAN_FALSE) ) |
| 2348 | { |
| 2349 | hddLog(LOGE, |
| 2350 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2351 | } |
| 2352 | |
| 2353 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2354 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2355 | |
| 2356 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2357 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2358 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2359 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2360 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2361 | { |
| 2362 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2363 | "GO got removed"); |
| 2364 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2365 | } |
| 2366 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2367 | } |
| 2368 | EXIT(); |
| 2369 | return status; |
| 2370 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2371 | |
| 2372 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2373 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2374 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2375 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2376 | struct cfg80211_ap_settings *params) |
| 2377 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2378 | hdd_adapter_t *pAdapter; |
| 2379 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2380 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2381 | |
| 2382 | ENTER(); |
| 2383 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2384 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2385 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2386 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2387 | "%s: Device is Null", __func__); |
| 2388 | return -ENODEV; |
| 2389 | } |
| 2390 | |
| 2391 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2392 | if (NULL == pAdapter) |
| 2393 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2394 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2395 | "%s: HDD adapter is Null", __func__); |
| 2396 | return -ENODEV; |
| 2397 | } |
| 2398 | |
| 2399 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2400 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2401 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2402 | "%s: HDD adapter magic is invalid", __func__); |
| 2403 | return -ENODEV; |
| 2404 | } |
| 2405 | |
| 2406 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2407 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2408 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2409 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2410 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2411 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2412 | "%s: HDD context is not valid", __func__); |
| 2413 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2414 | } |
| 2415 | |
| 2416 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2417 | __func__, pAdapter->device_mode); |
| 2418 | |
| 2419 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2420 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2421 | ) |
| 2422 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2423 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2424 | |
| 2425 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2426 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2427 | if (old) |
| 2428 | return -EALREADY; |
| 2429 | |
| 2430 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2431 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2432 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2433 | { |
| 2434 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2435 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2436 | return -EINVAL; |
| 2437 | } |
| 2438 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2439 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2440 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 2441 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2442 | params->channel, params->channel_type); |
| 2443 | #else |
| 2444 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 2445 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2446 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2447 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2448 | params->ssid_len, params->hidden_ssid); |
Gopichand Nakkala | 8c0386c | 2013-07-09 23:31:37 +0530 | [diff] [blame] | 2449 | if (0 == status) |
| 2450 | { |
| 2451 | hdd_start_p2p_go_connection_in_progress_timer(pAdapter); |
| 2452 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2453 | } |
| 2454 | |
| 2455 | EXIT(); |
| 2456 | return status; |
| 2457 | } |
| 2458 | |
| 2459 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2460 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2461 | struct net_device *dev, |
| 2462 | struct cfg80211_beacon_data *params) |
| 2463 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2464 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2465 | hdd_context_t *pHddCtx; |
| 2466 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2467 | |
| 2468 | ENTER(); |
| 2469 | |
| 2470 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2471 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2472 | |
| 2473 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2474 | status = wlan_hdd_validate_context(pHddCtx); |
| 2475 | |
| 2476 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2477 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2478 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2479 | "%s: HDD context is not valid", __func__); |
| 2480 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2481 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2482 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2483 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2484 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2485 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2486 | { |
| 2487 | beacon_data_t *old,*new; |
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 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2490 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2491 | if (!old) |
| 2492 | return -ENOENT; |
| 2493 | |
| 2494 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2495 | |
| 2496 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2497 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2498 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2499 | return -EINVAL; |
| 2500 | } |
| 2501 | |
| 2502 | pAdapter->sessionCtx.ap.beacon = new; |
| 2503 | |
| 2504 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2505 | } |
| 2506 | |
| 2507 | EXIT(); |
| 2508 | return status; |
| 2509 | } |
| 2510 | |
| 2511 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2513 | |
| 2514 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2515 | struct net_device *dev, |
| 2516 | struct bss_parameters *params) |
| 2517 | { |
| 2518 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2519 | |
| 2520 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2522 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2523 | __func__,pAdapter->device_mode); |
| 2524 | |
| 2525 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2526 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2527 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2528 | { |
| 2529 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2530 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2531 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2532 | { |
| 2533 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2534 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2535 | } |
| 2536 | |
| 2537 | EXIT(); |
| 2538 | return 0; |
| 2539 | } |
| 2540 | |
| 2541 | /* |
| 2542 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2543 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2544 | */ |
| 2545 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2546 | struct net_device *ndev, |
| 2547 | enum nl80211_iftype type, |
| 2548 | u32 *flags, |
| 2549 | struct vif_params *params |
| 2550 | ) |
| 2551 | { |
| 2552 | struct wireless_dev *wdev; |
| 2553 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2554 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2555 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2556 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2557 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2558 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2559 | eMib_dot11DesiredBssType connectedBssType; |
| 2560 | VOS_STATUS status; |
| 2561 | |
| 2562 | ENTER(); |
| 2563 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2564 | status = wlan_hdd_validate_context(pHddCtx); |
| 2565 | |
| 2566 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2567 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2568 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2569 | "%s: HDD context is not valid", __func__); |
| 2570 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2571 | } |
| 2572 | |
| 2573 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2574 | __func__, pAdapter->device_mode); |
| 2575 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2576 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2577 | wdev = ndev->ieee80211_ptr; |
| 2578 | |
| 2579 | #ifdef WLAN_BTAMP_FEATURE |
| 2580 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2581 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2582 | (NL80211_IFTYPE_AP == type)|| |
| 2583 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2584 | { |
| 2585 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2586 | // stop AMP traffic |
| 2587 | status = WLANBAP_StopAmp(); |
| 2588 | if(VOS_STATUS_SUCCESS != status ) |
| 2589 | { |
| 2590 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2591 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2592 | "%s: Failed to stop AMP", __func__); |
| 2593 | return -EINVAL; |
| 2594 | } |
| 2595 | } |
| 2596 | #endif //WLAN_BTAMP_FEATURE |
| 2597 | /* Reset the current device mode bit mask*/ |
| 2598 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2599 | |
| 2600 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2601 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2602 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2603 | ) |
| 2604 | { |
| 2605 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2606 | pRoamProfile = &pWextState->roamProfile; |
| 2607 | LastBSSType = pRoamProfile->BSSType; |
| 2608 | |
| 2609 | switch (type) |
| 2610 | { |
| 2611 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2612 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2613 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2614 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2615 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2616 | #ifdef WLAN_FEATURE_11AC |
| 2617 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2618 | { |
| 2619 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2620 | } |
| 2621 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2622 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2623 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2624 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2625 | //Check for sub-string p2p to confirm its a p2p interface |
| 2626 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2627 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2628 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2629 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2630 | } |
| 2631 | else |
| 2632 | { |
| 2633 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2634 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2635 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2636 | #ifdef FEATURE_WLAN_TDLS |
| 2637 | /* The open adapter for the p2p shall skip initializations in |
| 2638 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 2639 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 2640 | * tdls_init when the change_iface sets the device mode to |
| 2641 | * WLAN_HDD_P2P_CLIENT. |
| 2642 | */ |
| 2643 | |
| 2644 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 2645 | { |
| 2646 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 2647 | { |
| 2648 | return -EINVAL; |
| 2649 | } |
| 2650 | } |
| 2651 | #endif |
| 2652 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2653 | break; |
| 2654 | case NL80211_IFTYPE_ADHOC: |
| 2655 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2656 | "%s: setting interface Type to ADHOC", __func__); |
| 2657 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2658 | pRoamProfile->phyMode = |
| 2659 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2660 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2661 | wdev->iftype = type; |
| 2662 | break; |
| 2663 | |
| 2664 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2665 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2666 | { |
| 2667 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2668 | "%s: setting interface Type to %s", __func__, |
| 2669 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2670 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2671 | //Cancel any remain on channel for GO mode |
| 2672 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2673 | { |
| 2674 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2675 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2676 | if (NL80211_IFTYPE_AP == type) |
| 2677 | { |
| 2678 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2679 | * address. This will take one HW STA and the max number of clients |
| 2680 | * that can connect to softAP will be reduced by one. so while changing |
| 2681 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2682 | * interface as it is not required in SoftAP mode. |
| 2683 | */ |
| 2684 | |
| 2685 | // Get P2P Adapter |
| 2686 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2687 | |
| 2688 | if (pP2pAdapter) |
| 2689 | { |
| 2690 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2691 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2692 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2693 | } |
| 2694 | } |
| 2695 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2696 | //De-init the adapter. |
| 2697 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2698 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2699 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2700 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2701 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2702 | |
| 2703 | //Disable BMPS and IMPS if enabled |
| 2704 | //before starting Go |
| 2705 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2706 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2707 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2708 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2709 | { |
| 2710 | //Fail to Exit BMPS |
| 2711 | VOS_ASSERT(0); |
| 2712 | } |
| 2713 | } |
| 2714 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2715 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2716 | (pConfig->apRandomBssidEnabled)) |
| 2717 | { |
| 2718 | /* To meet Android requirements create a randomized |
| 2719 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2720 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2721 | ndev->dev_addr[0] = 0x02; |
| 2722 | ndev->dev_addr[1] = 0x1A; |
| 2723 | ndev->dev_addr[2] = 0x11; |
| 2724 | ndev->dev_addr[3] |= 0xF0; |
| 2725 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2726 | VOS_MAC_ADDR_SIZE); |
| 2727 | pr_info("wlan: Generated HotSpot BSSID " |
| 2728 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2729 | ndev->dev_addr[0], |
| 2730 | ndev->dev_addr[1], |
| 2731 | ndev->dev_addr[2], |
| 2732 | ndev->dev_addr[3], |
| 2733 | ndev->dev_addr[4], |
| 2734 | ndev->dev_addr[5]); |
| 2735 | } |
| 2736 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2737 | hdd_set_ap_ops( pAdapter->dev ); |
| 2738 | |
| 2739 | status = hdd_init_ap_mode(pAdapter); |
| 2740 | if(status != VOS_STATUS_SUCCESS) |
| 2741 | { |
| 2742 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2743 | "%s: Error initializing the ap mode", __func__); |
| 2744 | return -EINVAL; |
| 2745 | } |
| 2746 | hdd_set_conparam(1); |
| 2747 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2748 | /*interface type changed update in wiphy structure*/ |
| 2749 | if(wdev) |
| 2750 | { |
| 2751 | wdev->iftype = type; |
| 2752 | pHddCtx->change_iface = type; |
| 2753 | } |
| 2754 | else |
| 2755 | { |
| 2756 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2757 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2758 | return -EINVAL; |
| 2759 | } |
| 2760 | goto done; |
| 2761 | } |
| 2762 | |
| 2763 | default: |
| 2764 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2765 | __func__); |
| 2766 | return -EOPNOTSUPP; |
| 2767 | } |
| 2768 | } |
| 2769 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2770 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2771 | ) |
| 2772 | { |
| 2773 | switch(type) |
| 2774 | { |
| 2775 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2776 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2777 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2778 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2779 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2780 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2781 | //Check for sub-string p2p to confirm its a p2p interface |
| 2782 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2783 | { |
| 2784 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2785 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2786 | } |
| 2787 | else |
| 2788 | { |
| 2789 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2790 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2791 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2792 | hdd_set_conparam(0); |
| 2793 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2794 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2795 | hdd_set_station_ops( pAdapter->dev ); |
| 2796 | status = hdd_init_station_mode( pAdapter ); |
| 2797 | if( VOS_STATUS_SUCCESS != status ) |
| 2798 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2799 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2800 | * This is the right place to enable back bmps_imps() |
| 2801 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 2802 | if (pHddCtx->hdd_wlan_suspended) |
| 2803 | { |
| 2804 | hdd_set_pwrparams(pHddCtx); |
| 2805 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2806 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2807 | goto done; |
| 2808 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2809 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2810 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2811 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2812 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2813 | goto done; |
| 2814 | default: |
| 2815 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2816 | __func__); |
| 2817 | return -EOPNOTSUPP; |
| 2818 | |
| 2819 | } |
| 2820 | |
| 2821 | } |
| 2822 | else |
| 2823 | { |
| 2824 | return -EOPNOTSUPP; |
| 2825 | } |
| 2826 | |
| 2827 | |
| 2828 | if(pRoamProfile) |
| 2829 | { |
| 2830 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2831 | { |
| 2832 | /*interface type changed update in wiphy structure*/ |
| 2833 | wdev->iftype = type; |
| 2834 | |
| 2835 | /*the BSS mode changed, We need to issue disconnect |
| 2836 | if connected or in IBSS disconnect state*/ |
| 2837 | if ( hdd_connGetConnectedBssType( |
| 2838 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2839 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2840 | { |
| 2841 | /*need to issue a disconnect to CSR.*/ |
| 2842 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2843 | if( eHAL_STATUS_SUCCESS == |
| 2844 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2845 | pAdapter->sessionId, |
| 2846 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2847 | { |
| 2848 | wait_for_completion_interruptible_timeout( |
| 2849 | &pAdapter->disconnect_comp_var, |
| 2850 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2851 | } |
| 2852 | } |
| 2853 | } |
| 2854 | } |
| 2855 | |
| 2856 | done: |
| 2857 | /*set bitmask based on updated value*/ |
| 2858 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 2859 | |
| 2860 | /* Only STA mode support TM now |
| 2861 | * all other mode, TM feature should be disabled */ |
| 2862 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 2863 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 2864 | { |
| 2865 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 2866 | } |
| 2867 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2868 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2869 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2870 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2871 | { |
| 2872 | //we are ok to do AMP |
| 2873 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2874 | } |
| 2875 | #endif //WLAN_BTAMP_FEATURE |
| 2876 | EXIT(); |
| 2877 | return 0; |
| 2878 | } |
| 2879 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2880 | #ifdef FEATURE_WLAN_TDLS |
| 2881 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2882 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2883 | { |
| 2884 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2885 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2886 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2887 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2888 | |
| 2889 | ENTER(); |
| 2890 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2891 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2892 | { |
| 2893 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2894 | "Invalid arguments"); |
| 2895 | return -EINVAL; |
| 2896 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2897 | |
| 2898 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2899 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2900 | { |
| 2901 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2902 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2903 | MAC_ADDRESS_STR " Request declined.", |
| 2904 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2905 | return -ENOTSUPP; |
| 2906 | } |
| 2907 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2908 | if (pHddCtx->isLogpInProgress) |
| 2909 | { |
| 2910 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2911 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2912 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2913 | return -EBUSY; |
| 2914 | } |
| 2915 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2916 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2917 | |
| 2918 | if ( NULL == pTdlsPeer ) { |
| 2919 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2920 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2921 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2922 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2923 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2924 | |
| 2925 | /* in add station, we accept existing valid staId if there is */ |
| 2926 | if ((0 == update) && |
| 2927 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2928 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2929 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2930 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2931 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2932 | " link_status %d. staId %d. add station ignored.", |
| 2933 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2934 | return 0; |
| 2935 | } |
| 2936 | /* in change station, we accept only when staId is valid */ |
| 2937 | if ((1 == update) && |
| 2938 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2939 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2940 | { |
| 2941 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2942 | "%s: " MAC_ADDRESS_STR |
| 2943 | " link status %d. staId %d. change station %s.", |
| 2944 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2945 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2946 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2947 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2948 | |
| 2949 | /* 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] | 2950 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2951 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2952 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2953 | "%s: " MAC_ADDRESS_STR |
| 2954 | " TDLS setup is ongoing. Request declined.", |
| 2955 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2956 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2957 | } |
| 2958 | |
| 2959 | /* first to check if we reached to maximum supported TDLS peer. |
| 2960 | TODO: for now, return -EPERM looks working fine, |
| 2961 | but need to check if any other errno fit into this category.*/ |
| 2962 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2963 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2964 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2965 | "%s: " MAC_ADDRESS_STR |
| 2966 | " TDLS Max peer already connected. Request declined.", |
| 2967 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2968 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2969 | } |
| 2970 | else |
| 2971 | { |
| 2972 | hddTdlsPeer_t *pTdlsPeer; |
| 2973 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2974 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2975 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2976 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2977 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2978 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2979 | return -EPERM; |
| 2980 | } |
| 2981 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2982 | if (0 == update) |
| 2983 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2984 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2985 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2986 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2987 | { |
| 2988 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2989 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2990 | if(StaParams->htcap_present) |
| 2991 | { |
| 2992 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2993 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 2994 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2995 | "ht_capa->extended_capabilities: %0x", |
| 2996 | StaParams->HTCap.extendedHtCapInfo); |
| 2997 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2998 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2999 | "params->capability: %0x",StaParams->capability); |
| 3000 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3001 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3002 | if(StaParams->vhtcap_present) |
| 3003 | { |
| 3004 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3005 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 3006 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 3007 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 3008 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3009 | { |
| 3010 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3012 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 3013 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3014 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 3015 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3016 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3017 | else if ((1 == update) && (NULL == StaParams)) |
| 3018 | { |
| 3019 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3020 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 3021 | return -EPERM; |
| 3022 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3023 | |
| 3024 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 3025 | |
| 3026 | if (!update) |
| 3027 | { |
| 3028 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3029 | pAdapter->sessionId, mac); |
| 3030 | } |
| 3031 | else |
| 3032 | { |
| 3033 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3034 | pAdapter->sessionId, mac, StaParams); |
| 3035 | } |
| 3036 | |
| 3037 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 3038 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 3039 | |
| 3040 | if (!status) |
| 3041 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3042 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3043 | "%s: timeout waiting for tdls add station indication", |
| 3044 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3045 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3046 | } |
| 3047 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 3048 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3049 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3050 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3051 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3052 | } |
| 3053 | |
| 3054 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3055 | |
| 3056 | error: |
| 3057 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 3058 | return -EPERM; |
| 3059 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3060 | } |
| 3061 | #endif |
| 3062 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3063 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 3064 | struct net_device *dev, |
| 3065 | u8 *mac, |
| 3066 | struct station_parameters *params) |
| 3067 | { |
| 3068 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 3069 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3070 | hdd_context_t *pHddCtx; |
| 3071 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3072 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3073 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3074 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3075 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3076 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3077 | ENTER(); |
| 3078 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3079 | if ((NULL == pAdapter)) |
| 3080 | { |
| 3081 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3082 | "invalid adapter "); |
| 3083 | return -EINVAL; |
| 3084 | } |
| 3085 | |
| 3086 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3087 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3088 | |
| 3089 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 3090 | { |
| 3091 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3092 | "invalid HDD state or HDD station context"); |
| 3093 | return -EINVAL; |
| 3094 | } |
| 3095 | |
| 3096 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3097 | { |
| 3098 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3099 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3100 | return -EAGAIN; |
| 3101 | } |
| 3102 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3103 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 3104 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3105 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 3106 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3107 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3108 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3109 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3110 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3111 | WLANTL_STA_AUTHENTICATED); |
| 3112 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3113 | if (status != VOS_STATUS_SUCCESS) |
| 3114 | { |
| 3115 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3116 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3117 | return -EINVAL; |
| 3118 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3119 | } |
| 3120 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3121 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3122 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3123 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3124 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3125 | StaParams.capability = params->capability; |
| 3126 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3127 | StaParams.max_sp = params->max_sp; |
| 3128 | |
| 3129 | if (0 != params->ext_capab_len) |
| 3130 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3131 | sizeof(StaParams.extn_capability)); |
| 3132 | |
| 3133 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3134 | { |
| 3135 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3136 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3137 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3138 | |
| 3139 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3140 | |
| 3141 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3142 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3143 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3144 | * modified to send more rates. |
| 3145 | */ |
| 3146 | |
| 3147 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3148 | */ |
| 3149 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3150 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3151 | |
| 3152 | if (0 != StaParams.supported_rates_len) { |
| 3153 | int i = 0; |
| 3154 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3155 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3156 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3157 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3158 | for (i=0; i < StaParams.supported_rates_len; i++) |
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 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3161 | } |
| 3162 | |
| 3163 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3164 | { |
| 3165 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3166 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3167 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3168 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3169 | if (0 != params->ext_capab_len ) { |
| 3170 | /*Define A Macro : TODO Sunil*/ |
| 3171 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3172 | isBufSta = 1; |
| 3173 | } |
| 3174 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3175 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues, |
| 3176 | params->max_sp, isBufSta); |
| 3177 | if (VOS_STATUS_SUCCESS != status) { |
| 3178 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3179 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3180 | return -EINVAL; |
| 3181 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3182 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3183 | |
| 3184 | if (VOS_STATUS_SUCCESS != status) { |
| 3185 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3186 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3187 | return -EINVAL; |
| 3188 | } |
| 3189 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3190 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3191 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3192 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3193 | return status; |
| 3194 | } |
| 3195 | |
| 3196 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3197 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3198 | * This function is used to initialize the key information |
| 3199 | */ |
| 3200 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3201 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3202 | struct net_device *ndev, |
| 3203 | u8 key_index, bool pairwise, |
| 3204 | const u8 *mac_addr, |
| 3205 | struct key_params *params |
| 3206 | ) |
| 3207 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3208 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3209 | struct net_device *ndev, |
| 3210 | u8 key_index, const u8 *mac_addr, |
| 3211 | struct key_params *params |
| 3212 | ) |
| 3213 | #endif |
| 3214 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3215 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3216 | tCsrRoamSetKey setKey; |
| 3217 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3218 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3219 | v_U32_t roamId= 0xFF; |
| 3220 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3221 | hdd_hostapd_state_t *pHostapdState; |
| 3222 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3223 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3224 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3225 | |
| 3226 | ENTER(); |
| 3227 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3228 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3229 | status = wlan_hdd_validate_context(pHddCtx); |
| 3230 | |
| 3231 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3232 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3233 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3234 | "%s: HDD context is not valid", __func__); |
| 3235 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3236 | } |
| 3237 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3238 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3239 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3240 | |
| 3241 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3242 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3243 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3244 | key_index); |
| 3245 | |
| 3246 | return -EINVAL; |
| 3247 | } |
| 3248 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3249 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3250 | { |
| 3251 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3252 | params->key_len); |
| 3253 | |
| 3254 | return -EINVAL; |
| 3255 | } |
| 3256 | |
| 3257 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3258 | "%s: called with key index = %d & key length %d", |
| 3259 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3260 | |
| 3261 | /*extract key idx, key len and key*/ |
| 3262 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3263 | setKey.keyId = key_index; |
| 3264 | setKey.keyLength = params->key_len; |
| 3265 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3266 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3267 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3268 | { |
| 3269 | case WLAN_CIPHER_SUITE_WEP40: |
| 3270 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3271 | break; |
| 3272 | |
| 3273 | case WLAN_CIPHER_SUITE_WEP104: |
| 3274 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3275 | break; |
| 3276 | |
| 3277 | case WLAN_CIPHER_SUITE_TKIP: |
| 3278 | { |
| 3279 | u8 *pKey = &setKey.Key[0]; |
| 3280 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3281 | |
| 3282 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3283 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3284 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3285 | |
| 3286 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3287 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3288 | |--------------|----------|----------| |
| 3289 | <---16bytes---><--8bytes--><--8bytes--> |
| 3290 | |
| 3291 | */ |
| 3292 | /*Sme expects the 32 bytes key to be in the below order |
| 3293 | |
| 3294 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3295 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3296 | |--------------|----------|----------| |
| 3297 | <---16bytes---><--8bytes--><--8bytes--> |
| 3298 | */ |
| 3299 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3300 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3301 | |
| 3302 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3303 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3304 | |
| 3305 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3306 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3307 | |
| 3308 | |
| 3309 | break; |
| 3310 | } |
| 3311 | |
| 3312 | case WLAN_CIPHER_SUITE_CCMP: |
| 3313 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3314 | break; |
| 3315 | |
| 3316 | #ifdef FEATURE_WLAN_WAPI |
| 3317 | case WLAN_CIPHER_SUITE_SMS4: |
| 3318 | { |
| 3319 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3320 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3321 | params->key, params->key_len); |
| 3322 | return 0; |
| 3323 | } |
| 3324 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3325 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3326 | #ifdef FEATURE_WLAN_CCX |
| 3327 | case WLAN_CIPHER_SUITE_KRK: |
| 3328 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3329 | break; |
| 3330 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3331 | |
| 3332 | #ifdef WLAN_FEATURE_11W |
| 3333 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3334 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3335 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3336 | #endif |
| 3337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3338 | default: |
| 3339 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3340 | __func__, params->cipher); |
| 3341 | return -EOPNOTSUPP; |
| 3342 | } |
| 3343 | |
| 3344 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3345 | __func__, setKey.encType); |
| 3346 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3347 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3348 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3349 | (!pairwise) |
| 3350 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3351 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3352 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3353 | ) |
| 3354 | { |
| 3355 | /* set group key*/ |
| 3356 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3357 | "%s- %d: setting Broadcast key", |
| 3358 | __func__, __LINE__); |
| 3359 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3360 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3361 | } |
| 3362 | else |
| 3363 | { |
| 3364 | /* set pairwise key*/ |
| 3365 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3366 | "%s- %d: setting pairwise key", |
| 3367 | __func__, __LINE__); |
| 3368 | setKey.keyDirection = eSIR_TX_RX; |
| 3369 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3370 | } |
| 3371 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3372 | { |
| 3373 | setKey.keyDirection = eSIR_TX_RX; |
| 3374 | /*Set the group key*/ |
| 3375 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3376 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3377 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3378 | if ( 0 != status ) |
| 3379 | { |
| 3380 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3381 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3382 | return -EINVAL; |
| 3383 | } |
| 3384 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3385 | the PTK after peer joins the IBSS network*/ |
| 3386 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3387 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3388 | return status; |
| 3389 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3390 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3391 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3392 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3393 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3394 | if( pHostapdState->bssState == BSS_START ) |
| 3395 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3396 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3397 | |
| 3398 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3399 | { |
| 3400 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3401 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3402 | __LINE__, status ); |
| 3403 | } |
| 3404 | } |
| 3405 | |
| 3406 | /* Saving WEP keys */ |
| 3407 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3408 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3409 | { |
| 3410 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3411 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3412 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3413 | } |
| 3414 | else |
| 3415 | { |
| 3416 | //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] | 3417 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3418 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3419 | } |
| 3420 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3421 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3422 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3423 | { |
| 3424 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3425 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3426 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3427 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3428 | if (!pairwise) |
| 3429 | #else |
| 3430 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3431 | #endif |
| 3432 | { |
| 3433 | /* set group key*/ |
| 3434 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3435 | { |
| 3436 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3437 | "%s- %d: Perform Set key Complete", |
| 3438 | __func__, __LINE__); |
| 3439 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3440 | } |
| 3441 | } |
| 3442 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3443 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3444 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3445 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3446 | |
| 3447 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3448 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3449 | params->key, params->key_len); |
| 3450 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3451 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3452 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3453 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3454 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3455 | "%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] | 3456 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3457 | setKey.peerMac[2], setKey.peerMac[3], |
| 3458 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3459 | setKey.keyDirection); |
| 3460 | |
| 3461 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3462 | |
| 3463 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3464 | { |
| 3465 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3466 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3467 | __LINE__, vos_status ); |
| 3468 | |
| 3469 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3470 | |
| 3471 | return -EINVAL; |
| 3472 | |
| 3473 | } |
| 3474 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3475 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3476 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3477 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3478 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3479 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3480 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3481 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3482 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3483 | "%s: Update PreAuth Key success", __func__); |
| 3484 | return 0; |
| 3485 | } |
| 3486 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3487 | { |
| 3488 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3489 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3490 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3491 | } |
| 3492 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3493 | |
| 3494 | /* issue set key request to SME*/ |
| 3495 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3496 | pAdapter->sessionId, &setKey, &roamId ); |
| 3497 | |
| 3498 | if ( 0 != status ) |
| 3499 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3500 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3501 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3502 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3503 | return -EINVAL; |
| 3504 | } |
| 3505 | |
| 3506 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3507 | /* in case of IBSS as there was no information available about WEP keys during |
| 3508 | * 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] | 3509 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3510 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3511 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3512 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3513 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3514 | ) |
| 3515 | && |
| 3516 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3517 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3518 | ) |
| 3519 | ) |
| 3520 | { |
| 3521 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3522 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3523 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3524 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3525 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3526 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3527 | setKey.peerMac[2], setKey.peerMac[3], |
| 3528 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3529 | setKey.keyDirection); |
| 3530 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3531 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3532 | pAdapter->sessionId, &setKey, &roamId ); |
| 3533 | |
| 3534 | if ( 0 != status ) |
| 3535 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3536 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3537 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3538 | __func__, status); |
| 3539 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3540 | return -EINVAL; |
| 3541 | } |
| 3542 | } |
| 3543 | } |
| 3544 | |
| 3545 | return 0; |
| 3546 | } |
| 3547 | |
| 3548 | /* |
| 3549 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3550 | * This function is used to get the key information |
| 3551 | */ |
| 3552 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3553 | static int wlan_hdd_cfg80211_get_key( |
| 3554 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3555 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3556 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3557 | const u8 *mac_addr, void *cookie, |
| 3558 | void (*callback)(void *cookie, struct key_params*) |
| 3559 | ) |
| 3560 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3561 | static int wlan_hdd_cfg80211_get_key( |
| 3562 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3563 | struct net_device *ndev, |
| 3564 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3565 | void (*callback)(void *cookie, struct key_params*) |
| 3566 | ) |
| 3567 | #endif |
| 3568 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3569 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3570 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3571 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3572 | struct key_params params; |
| 3573 | |
| 3574 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3575 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3576 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3577 | __func__,pAdapter->device_mode); |
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 | memset(¶ms, 0, sizeof(params)); |
| 3580 | |
| 3581 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3582 | { |
| 3583 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3584 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3585 | |
| 3586 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3587 | { |
| 3588 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3589 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3590 | break; |
| 3591 | |
| 3592 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3593 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3594 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3595 | break; |
| 3596 | |
| 3597 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3598 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3599 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3600 | break; |
| 3601 | |
| 3602 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3603 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3604 | break; |
| 3605 | |
| 3606 | case eCSR_ENCRYPT_TYPE_AES: |
| 3607 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3608 | break; |
| 3609 | |
| 3610 | default: |
| 3611 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3612 | break; |
| 3613 | } |
| 3614 | |
| 3615 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3616 | params.seq_len = 0; |
| 3617 | params.seq = NULL; |
| 3618 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3619 | callback(cookie, ¶ms); |
| 3620 | return 0; |
| 3621 | } |
| 3622 | |
| 3623 | /* |
| 3624 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3625 | * This function is used to delete the key information |
| 3626 | */ |
| 3627 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3628 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3629 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3630 | u8 key_index, |
| 3631 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3632 | const u8 *mac_addr |
| 3633 | ) |
| 3634 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3635 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3636 | struct net_device *ndev, |
| 3637 | u8 key_index, |
| 3638 | const u8 *mac_addr |
| 3639 | ) |
| 3640 | #endif |
| 3641 | { |
| 3642 | int status = 0; |
| 3643 | |
| 3644 | //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] | 3645 | //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] | 3646 | //it is observed that this is invalidating peer |
| 3647 | //key index whenever re-key is done. This is affecting data link. |
| 3648 | //It should be ok to ignore del_key. |
| 3649 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3650 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3651 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3652 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3653 | tCsrRoamSetKey setKey; |
| 3654 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3655 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3656 | ENTER(); |
| 3657 | |
| 3658 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3659 | __func__,pAdapter->device_mode); |
| 3660 | |
| 3661 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3662 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3663 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3664 | key_index); |
| 3665 | |
| 3666 | return -EINVAL; |
| 3667 | } |
| 3668 | |
| 3669 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3670 | setKey.keyId = key_index; |
| 3671 | |
| 3672 | if (mac_addr) |
| 3673 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3674 | else |
| 3675 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3676 | |
| 3677 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3678 | |
| 3679 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3680 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3681 | ) |
| 3682 | { |
| 3683 | |
| 3684 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3685 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3686 | if( pHostapdState->bssState == BSS_START) |
| 3687 | { |
| 3688 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3689 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3690 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3691 | { |
| 3692 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3693 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3694 | __LINE__, status ); |
| 3695 | } |
| 3696 | } |
| 3697 | } |
| 3698 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3699 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3700 | ) |
| 3701 | { |
| 3702 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3703 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3704 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3705 | |
| 3706 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3707 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3708 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3709 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3710 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3711 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3712 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3713 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3714 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3715 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3716 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3717 | if ( 0 != status ) |
| 3718 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3719 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3720 | "%s: sme_RoamSetKey failure, returned %d", |
| 3721 | __func__, status); |
| 3722 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3723 | return -EINVAL; |
| 3724 | } |
| 3725 | } |
| 3726 | } |
| 3727 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3728 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3729 | return status; |
| 3730 | } |
| 3731 | |
| 3732 | /* |
| 3733 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3734 | * This function is used to set the default tx key index |
| 3735 | */ |
| 3736 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3737 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3738 | struct net_device *ndev, |
| 3739 | u8 key_index, |
| 3740 | bool unicast, bool multicast) |
| 3741 | #else |
| 3742 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3743 | struct net_device *ndev, |
| 3744 | u8 key_index) |
| 3745 | #endif |
| 3746 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3747 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3748 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3749 | hdd_wext_state_t *pWextState; |
| 3750 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3751 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3752 | |
| 3753 | ENTER(); |
| 3754 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3755 | if ((NULL == pAdapter)) |
| 3756 | { |
| 3757 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3758 | "invalid adapter"); |
| 3759 | return -EINVAL; |
| 3760 | } |
| 3761 | |
| 3762 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3763 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3764 | |
| 3765 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3766 | { |
| 3767 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3768 | "invalid Wext state or HDD context"); |
| 3769 | return -EINVAL; |
| 3770 | } |
| 3771 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3772 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3773 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3774 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3775 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3776 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3777 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3778 | key_index); |
| 3779 | |
| 3780 | return -EINVAL; |
| 3781 | } |
| 3782 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3783 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3784 | status = wlan_hdd_validate_context(pHddCtx); |
| 3785 | |
| 3786 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3787 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3788 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3789 | "%s: HDD context is not valid", __func__); |
| 3790 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3791 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3792 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3793 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3794 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
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 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3797 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3798 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3799 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3800 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3801 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3802 | { |
| 3803 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3804 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3805 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3806 | tCsrRoamSetKey setKey; |
| 3807 | v_U32_t roamId= 0xFF; |
| 3808 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3809 | |
| 3810 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3811 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3812 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3813 | Keys->defaultIndex = (u8)key_index; |
| 3814 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3815 | setKey.keyId = key_index; |
| 3816 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3817 | |
| 3818 | vos_mem_copy(&setKey.Key[0], |
| 3819 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3820 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3821 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3822 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3823 | |
| 3824 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3825 | &pHddStaCtx->conn_info.bssId[0], |
| 3826 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3827 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3828 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3829 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3830 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3831 | { |
| 3832 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3833 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3834 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3835 | type(104) and switching encryption type to 40*/ |
| 3836 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3837 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3838 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3839 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3840 | } |
| 3841 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3842 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3843 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3844 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3845 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3846 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3847 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3848 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3849 | if ( 0 != status ) |
| 3850 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3851 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3852 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3853 | status); |
| 3854 | return -EINVAL; |
| 3855 | } |
| 3856 | } |
| 3857 | } |
| 3858 | |
| 3859 | /* In SoftAp mode setting key direction for default mode */ |
| 3860 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3861 | { |
| 3862 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3863 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3864 | (eCSR_ENCRYPT_TYPE_AES != |
| 3865 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3866 | ) |
| 3867 | { |
| 3868 | /* Saving key direction for default key index to TX default */ |
| 3869 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3870 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3871 | } |
| 3872 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3873 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3874 | return status; |
| 3875 | } |
| 3876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3877 | /* |
| 3878 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3879 | * This function is used to inform the BSS details to nl80211 interface. |
| 3880 | */ |
| 3881 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3882 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3883 | { |
| 3884 | struct net_device *dev = pAdapter->dev; |
| 3885 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3886 | struct wiphy *wiphy = wdev->wiphy; |
| 3887 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3888 | int chan_no; |
| 3889 | int ie_length; |
| 3890 | const char *ie; |
| 3891 | unsigned int freq; |
| 3892 | struct ieee80211_channel *chan; |
| 3893 | int rssi = 0; |
| 3894 | struct cfg80211_bss *bss = NULL; |
| 3895 | |
| 3896 | ENTER(); |
| 3897 | |
| 3898 | if( NULL == pBssDesc ) |
| 3899 | { |
| 3900 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3901 | return bss; |
| 3902 | } |
| 3903 | |
| 3904 | chan_no = pBssDesc->channelId; |
| 3905 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3906 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3907 | |
| 3908 | if( NULL == ie ) |
| 3909 | { |
| 3910 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3911 | return bss; |
| 3912 | } |
| 3913 | |
| 3914 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3915 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3916 | { |
| 3917 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3918 | } |
| 3919 | else |
| 3920 | { |
| 3921 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3922 | } |
| 3923 | #else |
| 3924 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3925 | #endif |
| 3926 | |
| 3927 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3928 | |
| 3929 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3930 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3931 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3932 | if (bss == NULL) |
| 3933 | { |
| 3934 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3935 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3936 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3937 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3938 | pBssDesc->capabilityInfo, |
| 3939 | pBssDesc->beaconInterval, ie, ie_length, |
| 3940 | rssi, GFP_KERNEL )); |
| 3941 | } |
| 3942 | else |
| 3943 | { |
| 3944 | return bss; |
| 3945 | } |
| 3946 | } |
| 3947 | |
| 3948 | |
| 3949 | |
| 3950 | /* |
| 3951 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3952 | * This function is used to inform the BSS details to nl80211 interface. |
| 3953 | */ |
| 3954 | struct cfg80211_bss* |
| 3955 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3956 | tSirBssDescription *bss_desc |
| 3957 | ) |
| 3958 | { |
| 3959 | /* |
| 3960 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3961 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3962 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3963 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3964 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3965 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3966 | cfg80211_inform_bss_frame. |
| 3967 | */ |
| 3968 | struct net_device *dev = pAdapter->dev; |
| 3969 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3970 | struct wiphy *wiphy = wdev->wiphy; |
| 3971 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3972 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3973 | qcom_ie_age *qie_age = NULL; |
| 3974 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3975 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3976 | 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] | 3977 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3978 | const char *ie = |
| 3979 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3980 | unsigned int freq; |
| 3981 | struct ieee80211_channel *chan; |
| 3982 | struct ieee80211_mgmt *mgmt = |
| 3983 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 3984 | struct cfg80211_bss *bss_status = NULL; |
| 3985 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 3986 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3987 | #ifdef WLAN_OPEN_SOURCE |
| 3988 | struct timespec ts; |
| 3989 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3990 | |
| 3991 | ENTER(); |
| 3992 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 3993 | if (!mgmt) |
| 3994 | return NULL; |
| 3995 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3996 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3997 | |
| 3998 | #ifdef WLAN_OPEN_SOURCE |
| 3999 | /* Android does not want the timestamp from the frame. |
| 4000 | Instead it wants a monotonic increasing value */ |
| 4001 | get_monotonic_boottime(&ts); |
| 4002 | mgmt->u.probe_resp.timestamp = |
| 4003 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 4004 | #else |
| 4005 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4006 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 4007 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4008 | |
| 4009 | #endif |
| 4010 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4011 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 4012 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4013 | |
| 4014 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4015 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 4016 | /* Assuming this is the last IE, copy at the end */ |
| 4017 | ie_length -=sizeof(qcom_ie_age); |
| 4018 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 4019 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 4020 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 4021 | qie_age->oui_1 = QCOM_OUI1; |
| 4022 | qie_age->oui_2 = QCOM_OUI2; |
| 4023 | qie_age->oui_3 = QCOM_OUI3; |
| 4024 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 4025 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 4026 | #endif |
| 4027 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4028 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 4029 | if (bss_desc->fProbeRsp) |
| 4030 | { |
| 4031 | mgmt->frame_control |= |
| 4032 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 4033 | } |
| 4034 | else |
| 4035 | { |
| 4036 | mgmt->frame_control |= |
| 4037 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 4038 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4039 | |
| 4040 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4041 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4042 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 4043 | { |
| 4044 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4045 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4046 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4047 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 4048 | |
| 4049 | { |
| 4050 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4051 | } |
| 4052 | else |
| 4053 | { |
| 4054 | kfree(mgmt); |
| 4055 | return NULL; |
| 4056 | } |
| 4057 | #else |
| 4058 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4059 | #endif |
| 4060 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4061 | /*when the band is changed on the fly using the GUI, three things are done |
| 4062 | * 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) |
| 4063 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 4064 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 4065 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 4066 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 4067 | * 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 |
| 4068 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 4069 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 4070 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 4071 | * So drop the bss and continue to next bss. |
| 4072 | */ |
| 4073 | if(chan == NULL) |
| 4074 | { |
| 4075 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 4076 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4077 | return NULL; |
| 4078 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4079 | /*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] | 4080 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4081 | * */ |
| 4082 | if (( eConnectionState_Associated == |
| 4083 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4084 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4085 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4086 | WNI_CFG_BSSID_LEN))) |
| 4087 | { |
| 4088 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4089 | rssi = (pAdapter->rssi * 100); |
| 4090 | } |
| 4091 | else |
| 4092 | { |
| 4093 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4094 | } |
| 4095 | |
| 4096 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4097 | frame_len, rssi, GFP_KERNEL); |
| 4098 | kfree(mgmt); |
| 4099 | return bss_status; |
| 4100 | } |
| 4101 | |
| 4102 | /* |
| 4103 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4104 | * This function is used to update the BSS data base of CFG8011 |
| 4105 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4106 | 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] | 4107 | tCsrRoamInfo *pRoamInfo |
| 4108 | ) |
| 4109 | { |
| 4110 | tCsrRoamConnectedProfile roamProfile; |
| 4111 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4112 | struct cfg80211_bss *bss = NULL; |
| 4113 | |
| 4114 | ENTER(); |
| 4115 | |
| 4116 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4117 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4118 | |
| 4119 | if (NULL != roamProfile.pBssDesc) |
| 4120 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4121 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4122 | &roamProfile); |
| 4123 | |
| 4124 | if (NULL == bss) |
| 4125 | { |
| 4126 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4127 | __func__); |
| 4128 | } |
| 4129 | |
| 4130 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4131 | } |
| 4132 | else |
| 4133 | { |
| 4134 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4135 | __func__); |
| 4136 | } |
| 4137 | return bss; |
| 4138 | } |
| 4139 | |
| 4140 | /* |
| 4141 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4142 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4143 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4144 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4145 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4146 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4147 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4148 | tCsrScanResultInfo *pScanResult; |
| 4149 | eHalStatus status = 0; |
| 4150 | tScanResultHandle pResult; |
| 4151 | struct cfg80211_bss *bss_status = NULL; |
| 4152 | |
| 4153 | ENTER(); |
| 4154 | |
| 4155 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4156 | { |
| 4157 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4158 | return -EAGAIN; |
| 4159 | } |
| 4160 | |
| 4161 | /* |
| 4162 | * start getting scan results and populate cgf80211 BSS database |
| 4163 | */ |
| 4164 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4165 | |
| 4166 | /* no scan results */ |
| 4167 | if (NULL == pResult) |
| 4168 | { |
| 4169 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 4170 | return status; |
| 4171 | } |
| 4172 | |
| 4173 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4174 | |
| 4175 | while (pScanResult) |
| 4176 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4177 | /* |
| 4178 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4179 | * entry already exists in bss data base of cfg80211 for that |
| 4180 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4181 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4182 | * mgmt packet as input. As of now there is no possibility to get |
| 4183 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4184 | * ieee80211_mgmt(probe response) and passing to c |
| 4185 | * fg80211_inform_bss_frame. |
| 4186 | * */ |
| 4187 | |
| 4188 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4189 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4190 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4191 | |
| 4192 | if (NULL == bss_status) |
| 4193 | { |
| 4194 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4195 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 4196 | } |
| 4197 | else |
| 4198 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4199 | cfg80211_put_bss( |
| 4200 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 4201 | wiphy, |
| 4202 | #endif |
| 4203 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4204 | } |
| 4205 | |
| 4206 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4207 | } |
| 4208 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4209 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4210 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4211 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4212 | } |
| 4213 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4214 | void |
| 4215 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4216 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4217 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4218 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4219 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 4220 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4221 | } /****** end hddPrintMacAddr() ******/ |
| 4222 | |
| 4223 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4224 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4225 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4226 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4227 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4228 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4229 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4230 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4231 | } /****** end hddPrintPmkId() ******/ |
| 4232 | |
| 4233 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4234 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4235 | |
| 4236 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4237 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4238 | |
| 4239 | #define dump_bssid(bssid) \ |
| 4240 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4241 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4242 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 4243 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4244 | } |
| 4245 | |
| 4246 | #define dump_pmkid(pMac, pmkid) \ |
| 4247 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4248 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4249 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4250 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4251 | } |
| 4252 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4253 | #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] | 4254 | /* |
| 4255 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4256 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4257 | */ |
| 4258 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4259 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4260 | int index, bool preauth ) |
| 4261 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4262 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4263 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4264 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4265 | |
| 4266 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4267 | 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] | 4268 | |
| 4269 | if( NULL == pRoamInfo ) |
| 4270 | { |
| 4271 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4272 | return -EINVAL; |
| 4273 | } |
| 4274 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4275 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4276 | { |
| 4277 | dump_bssid(pRoamInfo->bssid); |
| 4278 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4279 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4280 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4281 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4282 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4283 | } |
| 4284 | #endif //FEATURE_WLAN_LFR |
| 4285 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4286 | /* |
| 4287 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4288 | * scanning callback function, called after finishing scan |
| 4289 | * |
| 4290 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4291 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4292 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4293 | { |
| 4294 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4295 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4296 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4297 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4298 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4299 | struct cfg80211_scan_request *req = NULL; |
| 4300 | int ret = 0; |
| 4301 | |
| 4302 | ENTER(); |
| 4303 | |
| 4304 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4305 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4306 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4307 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4308 | |
| 4309 | //Block on scan req completion variable. Can't wait forever though. |
| 4310 | ret = wait_for_completion_interruptible_timeout( |
| 4311 | &pScanInfo->scan_req_completion_event, |
| 4312 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4313 | if (!ret) |
| 4314 | { |
| 4315 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4316 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4317 | } |
| 4318 | |
| 4319 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4320 | { |
| 4321 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4322 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4323 | } |
| 4324 | |
| 4325 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4326 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4327 | { |
| 4328 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4329 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4330 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4331 | (int) scanId); |
| 4332 | } |
| 4333 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4334 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4335 | pAdapter); |
| 4336 | |
| 4337 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4338 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4339 | |
| 4340 | |
| 4341 | /* If any client wait scan result through WEXT |
| 4342 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4343 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4344 | { |
| 4345 | /* The other scan request waiting for current scan finish |
| 4346 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4347 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4348 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4349 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4350 | } |
| 4351 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4352 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4353 | { |
| 4354 | struct net_device *dev = pAdapter->dev; |
| 4355 | union iwreq_data wrqu; |
| 4356 | int we_event; |
| 4357 | char *msg; |
| 4358 | |
| 4359 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4360 | we_event = SIOCGIWSCAN; |
| 4361 | msg = NULL; |
| 4362 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4363 | } |
| 4364 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4365 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4366 | |
| 4367 | /* Get the Scan Req */ |
| 4368 | req = pAdapter->request; |
| 4369 | |
| 4370 | if (!req) |
| 4371 | { |
| 4372 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4373 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4374 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4375 | } |
| 4376 | |
| 4377 | /* |
| 4378 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4379 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4380 | req->n_ssids = 0; |
| 4381 | req->n_channels = 0; |
| 4382 | req->ie = 0; |
| 4383 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4384 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4385 | /* Scan is no longer pending */ |
| 4386 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4387 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4388 | /* |
| 4389 | * cfg80211_scan_done informing NL80211 about completion |
| 4390 | * of scanning |
| 4391 | */ |
| 4392 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4393 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4394 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4395 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4396 | /* release the wake lock at the end of the scan*/ |
| 4397 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4398 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4399 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4400 | * immediatly after the driver gets connect request(i.e after scan) |
| 4401 | * from supplicant, this result in app's is suspending and not able |
| 4402 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4403 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4404 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4405 | #ifdef FEATURE_WLAN_TDLS |
| 4406 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4407 | #endif |
| 4408 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4409 | EXIT(); |
| 4410 | return 0; |
| 4411 | } |
| 4412 | |
| 4413 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4414 | * FUNCTION: hdd_isScanAllowed |
| 4415 | * Go through each adapter and check if scan allowed |
| 4416 | * |
| 4417 | */ |
| 4418 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4419 | { |
| 4420 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4421 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4422 | hdd_adapter_t *pAdapter = NULL; |
| 4423 | VOS_STATUS status = 0; |
| 4424 | v_U8_t staId = 0; |
| 4425 | v_U8_t *staMac = NULL; |
| 4426 | |
Gopichand Nakkala | 8c0386c | 2013-07-09 23:31:37 +0530 | [diff] [blame] | 4427 | if (VOS_TIMER_STATE_RUNNING == |
| 4428 | vos_timer_getCurrentState(&pHddCtx->hdd_p2p_go_conn_is_in_progress)) |
| 4429 | { |
| 4430 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4431 | "%s: Connection is in progress, Do not allow the scan", __func__); |
| 4432 | return VOS_FALSE; |
| 4433 | } |
| 4434 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4435 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4436 | |
| 4437 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4438 | { |
| 4439 | pAdapter = pAdapterNode->pAdapter; |
| 4440 | |
| 4441 | if( pAdapter ) |
| 4442 | { |
| 4443 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4444 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4445 | __func__, pAdapter->device_mode); |
| 4446 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4447 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4448 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4449 | { |
| 4450 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4451 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4452 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4453 | { |
| 4454 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4455 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4456 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4457 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4458 | staMac[0], staMac[1], staMac[2], |
| 4459 | staMac[3], staMac[4], staMac[5]); |
| 4460 | return VOS_FALSE; |
| 4461 | } |
| 4462 | } |
| 4463 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4464 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4465 | { |
| 4466 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4467 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4468 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4469 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4470 | { |
| 4471 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4472 | |
| 4473 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4474 | "%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] | 4475 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4476 | staMac[0], staMac[1], staMac[2], |
| 4477 | staMac[3], staMac[4], staMac[5]); |
| 4478 | return VOS_FALSE; |
| 4479 | } |
| 4480 | } |
| 4481 | } |
| 4482 | } |
| 4483 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4484 | pAdapterNode = pNext; |
| 4485 | } |
| 4486 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4487 | "%s: Scan allowed", __func__); |
| 4488 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4489 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4490 | |
| 4491 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4492 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4493 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4494 | * later, scan dump command can be used to recieve scan results |
| 4495 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4496 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4497 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4498 | struct net_device *dev, |
| 4499 | #endif |
| 4500 | struct cfg80211_scan_request *request) |
| 4501 | { |
| 4502 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4503 | struct net_device *dev = request->wdev->netdev; |
| 4504 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4505 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4506 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4507 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4508 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4509 | tCsrScanRequest scanRequest; |
| 4510 | tANI_U8 *channelList = NULL, i; |
| 4511 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4512 | int status; |
| 4513 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4514 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4515 | |
| 4516 | ENTER(); |
| 4517 | |
| 4518 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4519 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4520 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4521 | status = wlan_hdd_validate_context(pHddCtx); |
| 4522 | |
| 4523 | if (0 != status) |
| 4524 | { |
| 4525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4526 | "%s: HDD context is not valid", __func__); |
| 4527 | return status; |
| 4528 | } |
| 4529 | |
| 4530 | cfg_param = pHddCtx->cfg_ini; |
| 4531 | pScanInfo = &pHddCtx->scan_info; |
| 4532 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4533 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4534 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4535 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4536 | { |
| 4537 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4538 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4539 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4540 | return -EBUSY; |
| 4541 | } |
| 4542 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4543 | #ifdef WLAN_BTAMP_FEATURE |
| 4544 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4545 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4546 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4547 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4548 | "%s: No scanning when AMP is on", __func__); |
| 4549 | return -EOPNOTSUPP; |
| 4550 | } |
| 4551 | #endif |
| 4552 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4553 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4554 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4555 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4556 | "%s: Not scanning on device_mode = %d", |
| 4557 | __func__, pAdapter->device_mode); |
| 4558 | return -EOPNOTSUPP; |
| 4559 | } |
| 4560 | |
| 4561 | if (TRUE == pScanInfo->mScanPending) |
| 4562 | { |
| 4563 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4564 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4565 | } |
| 4566 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4567 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4568 | //Channel and action frame is pending |
| 4569 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4570 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4571 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4572 | { |
| 4573 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4574 | return -EBUSY; |
| 4575 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4576 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4577 | /* if tdls disagree scan right now, return immediately. |
| 4578 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4579 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4580 | */ |
| 4581 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4582 | wiphy, |
| 4583 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4584 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4585 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4586 | request); |
| 4587 | if(status <= 0) |
| 4588 | { |
| 4589 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4590 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4591 | } |
| 4592 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4593 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4594 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4595 | { |
| 4596 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4597 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4598 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4599 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4600 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4601 | { |
| 4602 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4603 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4604 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4605 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4606 | } |
| 4607 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4608 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4609 | /* Check if scan is allowed at this point of time. |
| 4610 | */ |
| 4611 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4612 | { |
| 4613 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4614 | return -EBUSY; |
| 4615 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4616 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4617 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4618 | |
| 4619 | if (NULL != request) |
| 4620 | { |
| 4621 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4622 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4623 | |
| 4624 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4625 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4626 | * is not aging out the scan results. |
| 4627 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4628 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4629 | { |
| 4630 | request->n_ssids = 0; |
| 4631 | } |
| 4632 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4633 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4634 | { |
| 4635 | tCsrSSIDInfo *SsidInfo; |
| 4636 | int j; |
| 4637 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4638 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4639 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4640 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4641 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4642 | |
| 4643 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4644 | { |
| 4645 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4646 | "memory alloc failed SSIDInfo buffer"); |
| 4647 | return -ENOMEM; |
| 4648 | } |
| 4649 | |
| 4650 | /* copy all the ssid's and their length */ |
| 4651 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4652 | { |
| 4653 | /* get the ssid length */ |
| 4654 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4655 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4656 | SsidInfo->SSID.length); |
| 4657 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4658 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4659 | j, SsidInfo->SSID.ssId); |
| 4660 | } |
| 4661 | /* set the scan type to active */ |
| 4662 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4663 | } |
| 4664 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4665 | { |
| 4666 | /* set the scan type to active */ |
| 4667 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4668 | } |
| 4669 | else |
| 4670 | { |
| 4671 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4672 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4673 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4674 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4675 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4676 | } |
| 4677 | else |
| 4678 | { |
| 4679 | /* set the scan type to active */ |
| 4680 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4681 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4682 | |
| 4683 | /* set min and max channel time to zero */ |
| 4684 | scanRequest.minChnTime = 0; |
| 4685 | scanRequest.maxChnTime = 0; |
| 4686 | } |
| 4687 | |
| 4688 | /* set BSSType to default type */ |
| 4689 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4690 | |
| 4691 | /*TODO: scan the requested channels only*/ |
| 4692 | |
| 4693 | /*Right now scanning all the channels */ |
| 4694 | if( request ) |
| 4695 | { |
| 4696 | if( request->n_channels ) |
| 4697 | { |
| 4698 | channelList = vos_mem_malloc( request->n_channels ); |
| 4699 | if( NULL == channelList ) |
| 4700 | { |
| 4701 | status = -ENOMEM; |
| 4702 | goto free_mem; |
| 4703 | } |
| 4704 | |
| 4705 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4706 | channelList[i] = request->channels[i]->hw_value; |
| 4707 | } |
| 4708 | |
| 4709 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4710 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4711 | |
| 4712 | /* set requestType to full scan */ |
| 4713 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4714 | |
| 4715 | /* 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] | 4716 | * 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] | 4717 | * 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] | 4718 | */ |
| 4719 | |
| 4720 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4721 | * and in that case driver shoudnt flush scan results. If |
| 4722 | * driver flushes the scan results here and unfortunately if |
| 4723 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4724 | * fails which is not desired |
| 4725 | */ |
| 4726 | |
| 4727 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4728 | { |
| 4729 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4730 | pAdapter->sessionId ); |
| 4731 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4732 | |
| 4733 | if( request->ie_len ) |
| 4734 | { |
| 4735 | /* save this for future association (join requires this) */ |
| 4736 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4737 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4738 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4739 | |
| 4740 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4741 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4742 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4743 | ) |
| 4744 | { |
| 4745 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4746 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4747 | } |
| 4748 | |
| 4749 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4750 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4751 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4752 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4753 | request->ie_len); |
| 4754 | if (pP2pIe != NULL) |
| 4755 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4756 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4757 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4758 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4759 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4760 | { |
| 4761 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4762 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4763 | "Go nego completed to Connection is started"); |
| 4764 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4765 | "for 8way Handshake"); |
| 4766 | } |
| 4767 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4768 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4769 | { |
| 4770 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4771 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4772 | "Disconnected state to Connection is started"); |
| 4773 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4774 | "for 4way Handshake"); |
| 4775 | } |
| 4776 | #endif |
| 4777 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4778 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4779 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4780 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4781 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4782 | "%s: This is a P2P Search", __func__); |
| 4783 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4784 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4785 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4786 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4787 | /* set requestType to P2P Discovery */ |
| 4788 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4789 | } |
| 4790 | |
| 4791 | /* |
| 4792 | Skip Dfs Channel in case of P2P Search |
| 4793 | if it is set in ini file |
| 4794 | */ |
| 4795 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4796 | { |
| 4797 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4798 | } |
| 4799 | else |
| 4800 | { |
| 4801 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4802 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4803 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4804 | } |
| 4805 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4806 | } |
| 4807 | } |
| 4808 | |
| 4809 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4810 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4811 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4812 | * address the following issues. |
| 4813 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4814 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4815 | * for long time, this result in apps running at full power for long time. |
| 4816 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4817 | * be stuck in full power because of resume BMPS |
| 4818 | */ |
| 4819 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4820 | |
| 4821 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4822 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4823 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4824 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4825 | if (eHAL_STATUS_SUCCESS != status) |
| 4826 | { |
| 4827 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4828 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4829 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4830 | if(eHAL_STATUS_RESOURCES == status) |
| 4831 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4832 | 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] | 4833 | status = -EBUSY; |
| 4834 | } else { |
| 4835 | status = -EIO; |
| 4836 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4837 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4838 | goto free_mem; |
| 4839 | } |
| 4840 | |
| 4841 | pScanInfo->mScanPending = TRUE; |
| 4842 | pAdapter->request = request; |
| 4843 | pScanInfo->scanId = scanId; |
| 4844 | |
| 4845 | complete(&pScanInfo->scan_req_completion_event); |
| 4846 | |
| 4847 | free_mem: |
| 4848 | if( scanRequest.SSIDs.SSIDList ) |
| 4849 | { |
| 4850 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4851 | } |
| 4852 | |
| 4853 | if( channelList ) |
| 4854 | vos_mem_free( channelList ); |
| 4855 | |
| 4856 | EXIT(); |
| 4857 | |
| 4858 | return status; |
| 4859 | } |
| 4860 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4861 | |
| 4862 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 4863 | { |
| 4864 | v_U8_t iniDot11Mode = |
| 4865 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 4866 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 4867 | |
| 4868 | switch ( iniDot11Mode ) |
| 4869 | { |
| 4870 | case eHDD_DOT11_MODE_AUTO: |
| 4871 | case eHDD_DOT11_MODE_11ac: |
| 4872 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 4873 | #ifdef WLAN_FEATURE_11AC |
| 4874 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 4875 | #else |
| 4876 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4877 | #endif |
| 4878 | break; |
| 4879 | case eHDD_DOT11_MODE_11n: |
| 4880 | case eHDD_DOT11_MODE_11n_ONLY: |
| 4881 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4882 | break; |
| 4883 | default: |
| 4884 | hddDot11Mode = iniDot11Mode; |
| 4885 | break; |
| 4886 | } |
| 4887 | /* This call decides required channel bonding mode */ |
| 4888 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 4889 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 4890 | operationChannel); |
| 4891 | } |
| 4892 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4893 | /* |
| 4894 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4895 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4896 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4897 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4898 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4899 | { |
| 4900 | int status = 0; |
| 4901 | hdd_wext_state_t *pWextState; |
| 4902 | v_U32_t roamId; |
| 4903 | tCsrRoamProfile *pRoamProfile; |
| 4904 | eMib_dot11DesiredBssType connectedBssType; |
| 4905 | eCsrAuthType RSNAuthType; |
| 4906 | |
| 4907 | ENTER(); |
| 4908 | |
| 4909 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4910 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4911 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4912 | { |
| 4913 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4914 | return -EINVAL; |
| 4915 | } |
| 4916 | |
| 4917 | pRoamProfile = &pWextState->roamProfile; |
| 4918 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4919 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4920 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4921 | int ret = 0; |
| 4922 | hdd_station_ctx_t *pHddStaCtx; |
| 4923 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4924 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4925 | |
| 4926 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4927 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4928 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4929 | { |
| 4930 | /* Issue disconnect to CSR */ |
| 4931 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4932 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4933 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4934 | pAdapter->sessionId, |
| 4935 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4936 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4937 | ret = wait_for_completion_interruptible_timeout( |
| 4938 | &pAdapter->disconnect_comp_var, |
| 4939 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4940 | if (0 == ret) |
| 4941 | { |
| 4942 | VOS_ASSERT(0); |
| 4943 | } |
| 4944 | } |
| 4945 | } |
| 4946 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4947 | { |
| 4948 | ret = wait_for_completion_interruptible_timeout( |
| 4949 | &pAdapter->disconnect_comp_var, |
| 4950 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4951 | if (0 == ret) |
| 4952 | { |
| 4953 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4954 | } |
| 4955 | } |
| 4956 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4957 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4958 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4959 | { |
| 4960 | /*QoS not enabled in cfg file*/ |
| 4961 | pRoamProfile->uapsd_mask = 0; |
| 4962 | } |
| 4963 | else |
| 4964 | { |
| 4965 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4966 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4967 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4968 | } |
| 4969 | |
| 4970 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4971 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4972 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4973 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4974 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4975 | ssid, ssid_len); |
| 4976 | |
| 4977 | if (bssid) |
| 4978 | { |
| 4979 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4980 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4981 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4982 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4983 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4984 | case of join failure we should send valid BSSID to supplicant |
| 4985 | */ |
| 4986 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4987 | WNI_CFG_BSSID_LEN); |
| 4988 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 4989 | else |
| 4990 | { |
| 4991 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 4992 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4993 | |
| 4994 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 4995 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4996 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4997 | /*set gen ie*/ |
| 4998 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 4999 | /*set auth*/ |
| 5000 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 5001 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5002 | #ifdef FEATURE_WLAN_WAPI |
| 5003 | if (pAdapter->wapi_info.nWapiMode) |
| 5004 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5005 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5006 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 5007 | { |
| 5008 | case WAPI_AUTH_MODE_PSK: |
| 5009 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5010 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5011 | pAdapter->wapi_info.wapiAuthMode); |
| 5012 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5013 | break; |
| 5014 | } |
| 5015 | case WAPI_AUTH_MODE_CERT: |
| 5016 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5017 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5018 | pAdapter->wapi_info.wapiAuthMode); |
| 5019 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5020 | break; |
| 5021 | } |
| 5022 | } // End of switch |
| 5023 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 5024 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 5025 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5026 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5027 | pRoamProfile->AuthType.numEntries = 1; |
| 5028 | pRoamProfile->EncryptionType.numEntries = 1; |
| 5029 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5030 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 5031 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5032 | } |
| 5033 | } |
| 5034 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5035 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5036 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5037 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5038 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5039 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5040 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 5041 | sizeof (tSirGtkOffloadParams)); |
| 5042 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5043 | } |
| 5044 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5045 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 5046 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5047 | if( operatingChannel ) |
| 5048 | { |
| 5049 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 5050 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5051 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5052 | else |
| 5053 | { |
| 5054 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5055 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5056 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5057 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 5058 | { |
| 5059 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 5060 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5061 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 5062 | * 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] | 5063 | * 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] | 5064 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5065 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 5066 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5067 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5068 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5069 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 5070 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5071 | |
| 5072 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5073 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 5074 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5075 | if ((eHAL_STATUS_SUCCESS != status) && |
| 5076 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5077 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5078 | |
| 5079 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5080 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 5081 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 5082 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5083 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5084 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5085 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5086 | |
| 5087 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5088 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5089 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5090 | } |
| 5091 | else |
| 5092 | { |
| 5093 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 5094 | return -EINVAL; |
| 5095 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5096 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5097 | return status; |
| 5098 | } |
| 5099 | |
| 5100 | /* |
| 5101 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 5102 | * This function is used to set the authentication type (OPEN/SHARED). |
| 5103 | * |
| 5104 | */ |
| 5105 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 5106 | enum nl80211_auth_type auth_type) |
| 5107 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5108 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5110 | |
| 5111 | ENTER(); |
| 5112 | |
| 5113 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5114 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5115 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5116 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5117 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5118 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 5119 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5120 | break; |
| 5121 | |
| 5122 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5123 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5124 | case NL80211_AUTHTYPE_FT: |
| 5125 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5126 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5127 | "%s: set authentication type to OPEN", __func__); |
| 5128 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5129 | break; |
| 5130 | |
| 5131 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5132 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5133 | "%s: set authentication type to SHARED", __func__); |
| 5134 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5135 | break; |
| 5136 | #ifdef FEATURE_WLAN_CCX |
| 5137 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5138 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5139 | "%s: set authentication type to CCKM WPA", __func__); |
| 5140 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5141 | break; |
| 5142 | #endif |
| 5143 | |
| 5144 | |
| 5145 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5146 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5147 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5148 | auth_type); |
| 5149 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5150 | return -EINVAL; |
| 5151 | } |
| 5152 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5153 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5154 | pHddStaCtx->conn_info.authType; |
| 5155 | return 0; |
| 5156 | } |
| 5157 | |
| 5158 | /* |
| 5159 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5160 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5161 | * |
| 5162 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5163 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5164 | u32 key_mgmt |
| 5165 | ) |
| 5166 | { |
| 5167 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5168 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5169 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5170 | /*set key mgmt type*/ |
| 5171 | switch(key_mgmt) |
| 5172 | { |
| 5173 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5174 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5175 | case WLAN_AKM_SUITE_FT_PSK: |
| 5176 | #endif |
| 5177 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5178 | __func__); |
| 5179 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5180 | break; |
| 5181 | |
| 5182 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5183 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5184 | case WLAN_AKM_SUITE_FT_8021X: |
| 5185 | #endif |
| 5186 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5187 | __func__); |
| 5188 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5189 | break; |
| 5190 | #ifdef FEATURE_WLAN_CCX |
| 5191 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5192 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5193 | case WLAN_AKM_SUITE_CCKM: |
| 5194 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5195 | __func__); |
| 5196 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5197 | break; |
| 5198 | #endif |
| 5199 | |
| 5200 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5201 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5202 | __func__, key_mgmt); |
| 5203 | return -EINVAL; |
| 5204 | |
| 5205 | } |
| 5206 | return 0; |
| 5207 | } |
| 5208 | |
| 5209 | /* |
| 5210 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5211 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5212 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5213 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5214 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5215 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5216 | bool ucast |
| 5217 | ) |
| 5218 | { |
| 5219 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5220 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5221 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5222 | |
| 5223 | ENTER(); |
| 5224 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5225 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5226 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5227 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5228 | __func__, cipher); |
| 5229 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5230 | } |
| 5231 | else |
| 5232 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5233 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5234 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5235 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5236 | { |
| 5237 | case IW_AUTH_CIPHER_NONE: |
| 5238 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5239 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5240 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5241 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5242 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5243 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5244 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5245 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5246 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5247 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5248 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5249 | case WLAN_CIPHER_SUITE_TKIP: |
| 5250 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5251 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5252 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5253 | case WLAN_CIPHER_SUITE_CCMP: |
| 5254 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5255 | break; |
| 5256 | #ifdef FEATURE_WLAN_WAPI |
| 5257 | case WLAN_CIPHER_SUITE_SMS4: |
| 5258 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5259 | break; |
| 5260 | #endif |
| 5261 | |
| 5262 | #ifdef FEATURE_WLAN_CCX |
| 5263 | case WLAN_CIPHER_SUITE_KRK: |
| 5264 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5265 | break; |
| 5266 | #endif |
| 5267 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5268 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5269 | __func__, cipher); |
| 5270 | return -EOPNOTSUPP; |
| 5271 | } |
| 5272 | } |
| 5273 | |
| 5274 | if (ucast) |
| 5275 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5276 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5277 | __func__, encryptionType); |
| 5278 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5279 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5280 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5281 | encryptionType; |
| 5282 | } |
| 5283 | else |
| 5284 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5285 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5286 | __func__, encryptionType); |
| 5287 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5288 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5289 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5290 | } |
| 5291 | |
| 5292 | return 0; |
| 5293 | } |
| 5294 | |
| 5295 | |
| 5296 | /* |
| 5297 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5298 | * This function is used to parse WPA/RSN IE's. |
| 5299 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5300 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5301 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5302 | size_t ie_len |
| 5303 | ) |
| 5304 | { |
| 5305 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5306 | u8 *genie = ie; |
| 5307 | v_U16_t remLen = ie_len; |
| 5308 | #ifdef FEATURE_WLAN_WAPI |
| 5309 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5310 | u16 *tmp; |
| 5311 | v_U16_t akmsuiteCount; |
| 5312 | int *akmlist; |
| 5313 | #endif |
| 5314 | ENTER(); |
| 5315 | |
| 5316 | /* clear previous assocAddIE */ |
| 5317 | pWextState->assocAddIE.length = 0; |
| 5318 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5319 | |
| 5320 | while (remLen >= 2) |
| 5321 | { |
| 5322 | v_U16_t eLen = 0; |
| 5323 | v_U8_t elementId; |
| 5324 | elementId = *genie++; |
| 5325 | eLen = *genie++; |
| 5326 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5327 | |
| 5328 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5329 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5330 | |
| 5331 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5332 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5333 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5334 | 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] | 5335 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5336 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5337 | "%s: Invalid WPA IE", __func__); |
| 5338 | return -EINVAL; |
| 5339 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5340 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5341 | { |
| 5342 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5343 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5344 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5345 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5346 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5347 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5348 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5349 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5350 | VOS_ASSERT(0); |
| 5351 | return -ENOMEM; |
| 5352 | } |
| 5353 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5354 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5355 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5356 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5357 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5358 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5359 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5360 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5361 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5362 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5363 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5364 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5365 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5366 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5367 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5368 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5369 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5370 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5371 | /*Consider P2P IE, only for P2P Client */ |
| 5372 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5373 | { |
| 5374 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5375 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5376 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5377 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5378 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5379 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5380 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5381 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5382 | VOS_ASSERT(0); |
| 5383 | return -ENOMEM; |
| 5384 | } |
| 5385 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5386 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5387 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5388 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5390 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5391 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5392 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5393 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5394 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5395 | /*Consider WFD IE, only for P2P Client */ |
| 5396 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5397 | { |
| 5398 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5399 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5400 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5402 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5403 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5404 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5405 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5406 | VOS_ASSERT(0); |
| 5407 | return -ENOMEM; |
| 5408 | } |
| 5409 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5410 | // WPS IE + P2P IE + WFD IE |
| 5411 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5412 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5413 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5414 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5415 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5416 | } |
| 5417 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5418 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5419 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5420 | HS20_OUI_TYPE_SIZE)) ) |
| 5421 | { |
| 5422 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5423 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5424 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5425 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5426 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5427 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5428 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5429 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5430 | VOS_ASSERT(0); |
| 5431 | return -ENOMEM; |
| 5432 | } |
| 5433 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5434 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5435 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5436 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5437 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5438 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5439 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5440 | break; |
| 5441 | case DOT11F_EID_RSN: |
| 5442 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5443 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5444 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5445 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5446 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5447 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5448 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5449 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5450 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5451 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5452 | 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] | 5453 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5454 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5455 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5456 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5457 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5458 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5459 | VOS_ASSERT(0); |
| 5460 | return -ENOMEM; |
| 5461 | } |
| 5462 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5463 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5464 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5465 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5466 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5467 | break; |
| 5468 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5469 | #ifdef FEATURE_WLAN_WAPI |
| 5470 | case WLAN_EID_WAPI: |
| 5471 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5472 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5473 | pAdapter->wapi_info.nWapiMode); |
| 5474 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5475 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5476 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5477 | tmp = tmp + 1; |
| 5478 | akmlist = (int *)(tmp); |
| 5479 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5480 | { |
| 5481 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5482 | } |
| 5483 | else |
| 5484 | { |
| 5485 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5486 | VOS_ASSERT(0); |
| 5487 | return -EINVAL; |
| 5488 | } |
| 5489 | |
| 5490 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5491 | { |
| 5492 | 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] | 5493 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5494 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5495 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5496 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5497 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5498 | 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] | 5499 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5500 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5501 | } |
| 5502 | break; |
| 5503 | #endif |
| 5504 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5505 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5506 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5507 | /* when Unknown IE is received we should break and continue |
| 5508 | * to the next IE in the buffer instead we were returning |
| 5509 | * so changing this to break */ |
| 5510 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5511 | } |
| 5512 | genie += eLen; |
| 5513 | remLen -= eLen; |
| 5514 | } |
| 5515 | EXIT(); |
| 5516 | return 0; |
| 5517 | } |
| 5518 | |
| 5519 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5520 | * FUNCTION: hdd_isWPAIEPresent |
| 5521 | * Parse the received IE to find the WPA IE |
| 5522 | * |
| 5523 | */ |
| 5524 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5525 | { |
| 5526 | v_U8_t eLen = 0; |
| 5527 | v_U16_t remLen = ie_len; |
| 5528 | v_U8_t elementId = 0; |
| 5529 | |
| 5530 | while (remLen >= 2) |
| 5531 | { |
| 5532 | elementId = *ie++; |
| 5533 | eLen = *ie++; |
| 5534 | remLen -= 2; |
| 5535 | if (eLen > remLen) |
| 5536 | { |
| 5537 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5538 | "%s: IE length is wrong %d", __func__, eLen); |
| 5539 | return FALSE; |
| 5540 | } |
| 5541 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5542 | { |
| 5543 | /* OUI - 0x00 0X50 0XF2 |
| 5544 | WPA Information Element - 0x01 |
| 5545 | WPA version - 0x01*/ |
| 5546 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5547 | return TRUE; |
| 5548 | } |
| 5549 | ie += eLen; |
| 5550 | remLen -= eLen; |
| 5551 | } |
| 5552 | return FALSE; |
| 5553 | } |
| 5554 | |
| 5555 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5556 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5557 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5558 | * parameters during connect operation. |
| 5559 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5560 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5561 | struct cfg80211_connect_params *req |
| 5562 | ) |
| 5563 | { |
| 5564 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5565 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5566 | ENTER(); |
| 5567 | |
| 5568 | /*set wpa version*/ |
| 5569 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5570 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5571 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5572 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 5573 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5574 | { |
| 5575 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5576 | } |
| 5577 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5578 | { |
| 5579 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5580 | } |
| 5581 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5582 | |
| 5583 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5584 | pWextState->wpaVersion); |
| 5585 | |
| 5586 | /*set authentication type*/ |
| 5587 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5588 | |
| 5589 | if (0 > status) |
| 5590 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5591 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5592 | "%s: failed to set authentication type ", __func__); |
| 5593 | return status; |
| 5594 | } |
| 5595 | |
| 5596 | /*set key mgmt type*/ |
| 5597 | if (req->crypto.n_akm_suites) |
| 5598 | { |
| 5599 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5600 | if (0 > status) |
| 5601 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5602 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5603 | __func__); |
| 5604 | return status; |
| 5605 | } |
| 5606 | } |
| 5607 | |
| 5608 | /*set pairwise cipher type*/ |
| 5609 | if (req->crypto.n_ciphers_pairwise) |
| 5610 | { |
| 5611 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5612 | req->crypto.ciphers_pairwise[0], true); |
| 5613 | if (0 > status) |
| 5614 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5615 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5616 | "%s: failed to set unicast cipher type", __func__); |
| 5617 | return status; |
| 5618 | } |
| 5619 | } |
| 5620 | else |
| 5621 | { |
| 5622 | /*Reset previous cipher suite to none*/ |
| 5623 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5624 | if (0 > status) |
| 5625 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5626 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5627 | "%s: failed to set unicast cipher type", __func__); |
| 5628 | return status; |
| 5629 | } |
| 5630 | } |
| 5631 | |
| 5632 | /*set group cipher type*/ |
| 5633 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5634 | false); |
| 5635 | |
| 5636 | if (0 > status) |
| 5637 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5638 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5639 | __func__); |
| 5640 | return status; |
| 5641 | } |
| 5642 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5643 | #ifdef WLAN_FEATURE_11W |
| 5644 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5645 | #endif |
| 5646 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5647 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5648 | if (req->ie_len) |
| 5649 | { |
| 5650 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5651 | if ( 0 > status) |
| 5652 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5653 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5654 | __func__); |
| 5655 | return status; |
| 5656 | } |
| 5657 | } |
| 5658 | |
| 5659 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5660 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5661 | { |
| 5662 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5663 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5664 | ) |
| 5665 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5666 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5667 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5668 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5669 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5670 | __func__); |
| 5671 | return -EOPNOTSUPP; |
| 5672 | } |
| 5673 | else |
| 5674 | { |
| 5675 | u8 key_len = req->key_len; |
| 5676 | u8 key_idx = req->key_idx; |
| 5677 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5678 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5679 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5680 | ) |
| 5681 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5682 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5683 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5684 | __func__, key_idx, key_len); |
| 5685 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5686 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5687 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5688 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5689 | (u8)key_len; |
| 5690 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5691 | } |
| 5692 | } |
| 5693 | } |
| 5694 | } |
| 5695 | |
| 5696 | return status; |
| 5697 | } |
| 5698 | |
| 5699 | /* |
| 5700 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5701 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5702 | * parameters during connect operation. |
| 5703 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5704 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5705 | struct net_device *ndev, |
| 5706 | struct cfg80211_connect_params *req |
| 5707 | ) |
| 5708 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5709 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5710 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5711 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5712 | hdd_context_t *pHddCtx = NULL; |
| 5713 | |
| 5714 | ENTER(); |
| 5715 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5716 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5717 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5718 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5719 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5720 | status = wlan_hdd_validate_context(pHddCtx); |
| 5721 | |
| 5722 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5723 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5724 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5725 | "%s: HDD context is not valid", __func__); |
| 5726 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5727 | } |
| 5728 | |
| 5729 | #ifdef WLAN_BTAMP_FEATURE |
| 5730 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5731 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5732 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5733 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5734 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5735 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5736 | } |
| 5737 | #endif |
| 5738 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5739 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5740 | |
| 5741 | if ( 0 > status) |
| 5742 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5743 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5744 | __func__); |
| 5745 | return status; |
| 5746 | } |
| 5747 | |
| 5748 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5749 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5750 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5751 | (vos_concurrent_sessions_running())) |
| 5752 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5753 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5754 | } |
| 5755 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5756 | if ( req->channel ) |
| 5757 | { |
| 5758 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5759 | req->ssid_len, req->bssid, |
| 5760 | req->channel->hw_value); |
| 5761 | } |
| 5762 | else |
| 5763 | { |
| 5764 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5765 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5766 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5767 | |
| 5768 | if (0 > status) |
| 5769 | { |
| 5770 | //ReEnable BMPS if disabled |
| 5771 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5772 | (NULL != pHddCtx)) |
| 5773 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5774 | if (pHddCtx->hdd_wlan_suspended) |
| 5775 | { |
| 5776 | hdd_set_pwrparams(pHddCtx); |
| 5777 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5778 | //ReEnable Bmps and Imps back |
| 5779 | hdd_enable_bmps_imps(pHddCtx); |
| 5780 | } |
| 5781 | |
| 5782 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5783 | return status; |
| 5784 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5785 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5786 | EXIT(); |
| 5787 | return status; |
| 5788 | } |
| 5789 | |
| 5790 | |
| 5791 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5792 | * FUNCTION: wlan_hdd_disconnect |
| 5793 | * This function is used to issue a disconnect request to SME |
| 5794 | */ |
| 5795 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 5796 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5797 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5798 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5799 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5800 | |
| 5801 | status = wlan_hdd_validate_context(pHddCtx); |
| 5802 | |
| 5803 | if (0 != status) |
| 5804 | { |
| 5805 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5806 | "%s: HDD context is not valid", __func__); |
| 5807 | return status; |
| 5808 | } |
| 5809 | |
| 5810 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5811 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5812 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5813 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5814 | /*issue disconnect*/ |
| 5815 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5816 | pAdapter->sessionId, reason); |
| 5817 | |
| 5818 | if ( 0 != status ) |
| 5819 | { |
| 5820 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5821 | "%s csrRoamDisconnect failure, returned %d \n", |
| 5822 | __func__, (int)status ); |
| 5823 | return -EINVAL; |
| 5824 | } |
| 5825 | wait_for_completion_interruptible_timeout( |
| 5826 | &pAdapter->disconnect_comp_var, |
| 5827 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5828 | /*stop tx queues*/ |
| 5829 | netif_tx_disable(pAdapter->dev); |
| 5830 | netif_carrier_off(pAdapter->dev); |
| 5831 | return status; |
| 5832 | } |
| 5833 | |
| 5834 | |
| 5835 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5836 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5837 | * This function is used to issue a disconnect request to SME |
| 5838 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5839 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5840 | struct net_device *dev, |
| 5841 | u16 reason |
| 5842 | ) |
| 5843 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5844 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5845 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5846 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5847 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5848 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5849 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5850 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5851 | tANI_U8 staIdx; |
| 5852 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5853 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5854 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5855 | |
| 5856 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5857 | __func__,pAdapter->device_mode); |
| 5858 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5859 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5860 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5861 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5862 | status = wlan_hdd_validate_context(pHddCtx); |
| 5863 | |
| 5864 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5865 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5866 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5867 | "%s: HDD context is not valid", __func__); |
| 5868 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5869 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5870 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5871 | if (NULL != pRoamProfile) |
| 5872 | { |
| 5873 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5874 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5875 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5876 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5877 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5878 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5879 | switch(reason) |
| 5880 | { |
| 5881 | case WLAN_REASON_MIC_FAILURE: |
| 5882 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5883 | break; |
| 5884 | |
| 5885 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5886 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5887 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5888 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5889 | break; |
| 5890 | |
| 5891 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5892 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5893 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5894 | break; |
| 5895 | |
| 5896 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5897 | default: |
| 5898 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5899 | break; |
| 5900 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5901 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5902 | pScanInfo = &pHddCtx->scan_info; |
| 5903 | if (pScanInfo->mScanPending) |
| 5904 | { |
| 5905 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 5906 | "Aborting Scan"); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame^] | 5907 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5908 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5909 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5910 | #ifdef FEATURE_WLAN_TDLS |
| 5911 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5912 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5913 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5914 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5915 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5916 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5917 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5918 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5919 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5920 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5921 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5922 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5923 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5924 | pAdapter->sessionId, |
| 5925 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5926 | } |
| 5927 | } |
| 5928 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5929 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 5930 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5931 | { |
| 5932 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5933 | "%s wlan_hdd_disconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5934 | __func__, (int)status ); |
| 5935 | return -EINVAL; |
| 5936 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5937 | } |
| 5938 | } |
| 5939 | else |
| 5940 | { |
| 5941 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5942 | } |
| 5943 | |
| 5944 | return status; |
| 5945 | } |
| 5946 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5947 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5948 | /* |
| 5949 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5950 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5951 | * settings in IBSS mode. |
| 5952 | */ |
| 5953 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5954 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5955 | struct cfg80211_ibss_params *params |
| 5956 | ) |
| 5957 | { |
| 5958 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5959 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5960 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5961 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5962 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5963 | ENTER(); |
| 5964 | |
| 5965 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5966 | |
| 5967 | if (params->ie_len && ( NULL != params->ie) ) |
| 5968 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5969 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5970 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5971 | { |
| 5972 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5973 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5974 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5975 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5976 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5977 | tDot11fIEWPA dot11WPAIE; |
| 5978 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5979 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5980 | |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5981 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5982 | params->ie_len, DOT11F_EID_WPA); |
| 5983 | if ( NULL != ie ) |
| 5984 | { |
| 5985 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5986 | // Unpack the WPA IE |
| 5987 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 5988 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 5989 | &ie[2+4], |
| 5990 | ie[1] - 4, |
| 5991 | &dot11WPAIE); |
| 5992 | /*Extract the multicast cipher, the encType for unicast |
| 5993 | cipher for wpa-none is none*/ |
| 5994 | encryptionType = |
| 5995 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 5996 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5997 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5998 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5999 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 6000 | |
| 6001 | if (0 > status) |
| 6002 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6003 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6004 | __func__); |
| 6005 | return status; |
| 6006 | } |
| 6007 | } |
| 6008 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6009 | pWextState->roamProfile.AuthType.authType[0] = |
| 6010 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6011 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6012 | |
| 6013 | if (params->privacy) |
| 6014 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6015 | /* Security enabled IBSS, At this time there is no information available |
| 6016 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6017 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6018 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6019 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6020 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6021 | *enable privacy bit in beacons */ |
| 6022 | |
| 6023 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 6024 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6025 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6026 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6027 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 6028 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 6029 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6030 | return status; |
| 6031 | } |
| 6032 | |
| 6033 | /* |
| 6034 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6035 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6036 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6037 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6038 | struct net_device *dev, |
| 6039 | struct cfg80211_ibss_params *params |
| 6040 | ) |
| 6041 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6042 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6043 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6044 | tCsrRoamProfile *pRoamProfile; |
| 6045 | int status; |
| 6046 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6047 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6048 | |
| 6049 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6050 | |
| 6051 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6052 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6053 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6054 | status = wlan_hdd_validate_context(pHddCtx); |
| 6055 | |
| 6056 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6057 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6059 | "%s: HDD context is not valid", __func__); |
| 6060 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6061 | } |
| 6062 | |
| 6063 | if (NULL == pWextState) |
| 6064 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6065 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6066 | __func__); |
| 6067 | return -EIO; |
| 6068 | } |
| 6069 | |
| 6070 | pRoamProfile = &pWextState->roamProfile; |
| 6071 | |
| 6072 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 6073 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6074 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6075 | "%s Interface type is not set to IBSS \n", __func__); |
| 6076 | return -EINVAL; |
| 6077 | } |
| 6078 | |
| 6079 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6080 | if (NULL != |
| 6081 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6082 | params->chandef.chan) |
| 6083 | #else |
| 6084 | params->channel) |
| 6085 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6086 | { |
| 6087 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6088 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6089 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6090 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6091 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6092 | |
| 6093 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6094 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6095 | ieee80211_frequency_to_channel( |
| 6096 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6097 | params->chandef.chan->center_freq); |
| 6098 | #else |
| 6099 | params->channel->center_freq); |
| 6100 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6101 | |
| 6102 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 6103 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6104 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6105 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 6106 | __func__); |
| 6107 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6108 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6109 | |
| 6110 | for (indx = 0; indx < numChans; indx++) |
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 | if (channelNum == validChan[indx]) |
| 6113 | { |
| 6114 | break; |
| 6115 | } |
| 6116 | } |
| 6117 | if (indx >= numChans) |
| 6118 | { |
| 6119 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6120 | __func__, channelNum); |
| 6121 | return -EINVAL; |
| 6122 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6123 | /* Set the Operational Channel */ |
| 6124 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 6125 | channelNum); |
| 6126 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 6127 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6128 | pRoamProfile->ChannelInfo.ChannelList = |
| 6129 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6130 | } |
| 6131 | |
| 6132 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6133 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6134 | if (status < 0) |
| 6135 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6136 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6137 | __func__); |
| 6138 | return status; |
| 6139 | } |
| 6140 | |
| 6141 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6142 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6143 | params->ssid_len, params->bssid, |
| 6144 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6145 | |
| 6146 | if (0 > status) |
| 6147 | { |
| 6148 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6149 | return status; |
| 6150 | } |
| 6151 | |
| 6152 | return 0; |
| 6153 | } |
| 6154 | |
| 6155 | /* |
| 6156 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6157 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6158 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6159 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6160 | struct net_device *dev |
| 6161 | ) |
| 6162 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6163 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6164 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6165 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6166 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6167 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6168 | |
| 6169 | ENTER(); |
| 6170 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6171 | status = wlan_hdd_validate_context(pHddCtx); |
| 6172 | |
| 6173 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6174 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6175 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6176 | "%s: HDD context is not valid", __func__); |
| 6177 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6178 | } |
| 6179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6180 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6181 | if (NULL == pWextState) |
| 6182 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6183 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6184 | __func__); |
| 6185 | return -EIO; |
| 6186 | } |
| 6187 | |
| 6188 | pRoamProfile = &pWextState->roamProfile; |
| 6189 | |
| 6190 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6191 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6192 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6193 | 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] | 6194 | __func__); |
| 6195 | return -EINVAL; |
| 6196 | } |
| 6197 | |
| 6198 | /* Issue Disconnect request */ |
| 6199 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6200 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6201 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6202 | |
| 6203 | return 0; |
| 6204 | } |
| 6205 | |
| 6206 | /* |
| 6207 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6208 | * This function is used to set the phy parameters |
| 6209 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6210 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6211 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6212 | u32 changed) |
| 6213 | { |
| 6214 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6215 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6216 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6217 | |
| 6218 | ENTER(); |
| 6219 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6220 | status = wlan_hdd_validate_context(pHddCtx); |
| 6221 | |
| 6222 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6223 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6224 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6225 | "%s: HDD context is not valid", __func__); |
| 6226 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6227 | } |
| 6228 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6229 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6230 | { |
| 6231 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6232 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6233 | wiphy->rts_threshold; |
| 6234 | |
| 6235 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6236 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6237 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6238 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6239 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6240 | __func__, rts_threshold); |
| 6241 | return -EINVAL; |
| 6242 | } |
| 6243 | |
| 6244 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6245 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6246 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6247 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6248 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6249 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6250 | __func__, rts_threshold); |
| 6251 | return -EIO; |
| 6252 | } |
| 6253 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6254 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6255 | rts_threshold); |
| 6256 | } |
| 6257 | |
| 6258 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6259 | { |
| 6260 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6261 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6262 | wiphy->frag_threshold; |
| 6263 | |
| 6264 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6265 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6266 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6267 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6268 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6269 | frag_threshold); |
| 6270 | return -EINVAL; |
| 6271 | } |
| 6272 | |
| 6273 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6274 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6275 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6276 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6277 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6278 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6279 | __func__, frag_threshold); |
| 6280 | return -EIO; |
| 6281 | } |
| 6282 | |
| 6283 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6284 | frag_threshold); |
| 6285 | } |
| 6286 | |
| 6287 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6288 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6289 | { |
| 6290 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6291 | wiphy->retry_short : |
| 6292 | wiphy->retry_long; |
| 6293 | |
| 6294 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6295 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6296 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6297 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6298 | __func__, retry_value); |
| 6299 | return -EINVAL; |
| 6300 | } |
| 6301 | |
| 6302 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6303 | { |
| 6304 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6305 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6306 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6307 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6308 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6309 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6310 | __func__, retry_value); |
| 6311 | return -EIO; |
| 6312 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6313 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6314 | __func__, retry_value); |
| 6315 | } |
| 6316 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6317 | { |
| 6318 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6319 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6320 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6321 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6322 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6323 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6324 | __func__, retry_value); |
| 6325 | return -EIO; |
| 6326 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6327 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6328 | __func__, retry_value); |
| 6329 | } |
| 6330 | } |
| 6331 | |
| 6332 | return 0; |
| 6333 | } |
| 6334 | |
| 6335 | /* |
| 6336 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6337 | * This function is used to set the txpower |
| 6338 | */ |
| 6339 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6340 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6341 | struct wireless_dev *wdev, |
| 6342 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6343 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6344 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6345 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6346 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6347 | #endif |
| 6348 | int dbm) |
| 6349 | { |
| 6350 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6351 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6352 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6353 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6354 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6355 | |
| 6356 | ENTER(); |
| 6357 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6358 | status = wlan_hdd_validate_context(pHddCtx); |
| 6359 | |
| 6360 | if (0 != status) |
| 6361 | { |
| 6362 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6363 | "%s: HDD context is not valid", __func__); |
| 6364 | return status; |
| 6365 | } |
| 6366 | |
| 6367 | hHal = pHddCtx->hHal; |
| 6368 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6369 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6370 | dbm, ccmCfgSetCallback, |
| 6371 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6372 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6373 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6374 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6375 | return -EIO; |
| 6376 | } |
| 6377 | |
| 6378 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6379 | dbm); |
| 6380 | |
| 6381 | switch(type) |
| 6382 | { |
| 6383 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6384 | /* Fall through */ |
| 6385 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6386 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6387 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6388 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6389 | __func__); |
| 6390 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6391 | } |
| 6392 | break; |
| 6393 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6394 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6395 | __func__); |
| 6396 | return -EOPNOTSUPP; |
| 6397 | break; |
| 6398 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6399 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6400 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6401 | return -EIO; |
| 6402 | } |
| 6403 | |
| 6404 | return 0; |
| 6405 | } |
| 6406 | |
| 6407 | /* |
| 6408 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6409 | * This function is used to read the txpower |
| 6410 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6411 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 6412 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6413 | struct wireless_dev *wdev, |
| 6414 | #endif |
| 6415 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6416 | { |
| 6417 | |
| 6418 | hdd_adapter_t *pAdapter; |
| 6419 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6420 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6421 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6422 | ENTER(); |
| 6423 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6424 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6425 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6426 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6427 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6428 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6429 | "%s: HDD context is not valid", __func__); |
| 6430 | *dbm = 0; |
| 6431 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6432 | } |
| 6433 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6434 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6435 | if (NULL == pAdapter) |
| 6436 | { |
| 6437 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6438 | return -ENOENT; |
| 6439 | } |
| 6440 | |
| 6441 | wlan_hdd_get_classAstats(pAdapter); |
| 6442 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6443 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6444 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6445 | return 0; |
| 6446 | } |
| 6447 | |
| 6448 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6449 | u8* mac, struct station_info *sinfo) |
| 6450 | { |
| 6451 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6452 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6453 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6454 | tANI_U8 rate_flags; |
| 6455 | |
| 6456 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6457 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6458 | |
| 6459 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6460 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6461 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6462 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6463 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6464 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6465 | tANI_U16 maxRate = 0; |
| 6466 | tANI_U16 myRate; |
| 6467 | tANI_U16 currentRate = 0; |
| 6468 | tANI_U8 maxSpeedMCS = 0; |
| 6469 | tANI_U8 maxMCSIdx = 0; |
| 6470 | tANI_U8 rateFlag = 1; |
| 6471 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6472 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6473 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6474 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6475 | #ifdef WLAN_FEATURE_11AC |
| 6476 | tANI_U32 vht_mcs_map; |
| 6477 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6478 | #endif /* WLAN_FEATURE_11AC */ |
| 6479 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6480 | ENTER(); |
| 6481 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6482 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6483 | (0 == ssidlen)) |
| 6484 | { |
| 6485 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6486 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6487 | /*To keep GUI happy*/ |
| 6488 | return 0; |
| 6489 | } |
| 6490 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6491 | status = wlan_hdd_validate_context(pHddCtx); |
| 6492 | |
| 6493 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6494 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6495 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6496 | "%s: HDD context is not valid", __func__); |
| 6497 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6498 | } |
| 6499 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6500 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6501 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6502 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6503 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6504 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6505 | |
| 6506 | //convert to the UI units of 100kbps |
| 6507 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6508 | |
| 6509 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6510 | 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] | 6511 | sinfo->signal, |
| 6512 | pCfg->reportMaxLinkSpeed, |
| 6513 | myRate, |
| 6514 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6515 | (int) pCfg->linkSpeedRssiMid, |
| 6516 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6517 | (int) rate_flags, |
| 6518 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6519 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6520 | |
| 6521 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6522 | { |
| 6523 | // we do not want to necessarily report the current speed |
| 6524 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6525 | { |
| 6526 | // report the max possible speed |
| 6527 | rssidx = 0; |
| 6528 | } |
| 6529 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6530 | { |
| 6531 | // report the max possible speed with RSSI scaling |
| 6532 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6533 | { |
| 6534 | // report the max possible speed |
| 6535 | rssidx = 0; |
| 6536 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6537 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6538 | { |
| 6539 | // report middle speed |
| 6540 | rssidx = 1; |
| 6541 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6542 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6543 | { |
| 6544 | // report middle speed |
| 6545 | rssidx = 2; |
| 6546 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6547 | else |
| 6548 | { |
| 6549 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6550 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6551 | } |
| 6552 | } |
| 6553 | else |
| 6554 | { |
| 6555 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6556 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6557 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6558 | __func__, pCfg->reportMaxLinkSpeed); |
| 6559 | rssidx = 0; |
| 6560 | } |
| 6561 | |
| 6562 | maxRate = 0; |
| 6563 | |
| 6564 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6565 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6566 | OperationalRates, &ORLeng)) |
| 6567 | { |
| 6568 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6569 | /*To keep GUI happy*/ |
| 6570 | return 0; |
| 6571 | } |
| 6572 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6573 | for (i = 0; i < ORLeng; i++) |
| 6574 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6575 | 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] | 6576 | { |
| 6577 | /* Validate Rate Set */ |
| 6578 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6579 | { |
| 6580 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6581 | break; |
| 6582 | } |
| 6583 | } |
| 6584 | /* Update MAX rate */ |
| 6585 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6586 | } |
| 6587 | |
| 6588 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6589 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6590 | ExtendedRates, &ERLeng)) |
| 6591 | { |
| 6592 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6593 | /*To keep GUI happy*/ |
| 6594 | return 0; |
| 6595 | } |
| 6596 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6597 | for (i = 0; i < ERLeng; i++) |
| 6598 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6599 | 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] | 6600 | { |
| 6601 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6602 | { |
| 6603 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6604 | break; |
| 6605 | } |
| 6606 | } |
| 6607 | /* Update MAX rate */ |
| 6608 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6609 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6610 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6611 | rates or if we are always reporting max speed or if we have |
| 6612 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6613 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6614 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6615 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6616 | MCSRates, &MCSLeng)) |
| 6617 | { |
| 6618 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6619 | /*To keep GUI happy*/ |
| 6620 | return 0; |
| 6621 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6622 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6623 | #ifdef WLAN_FEATURE_11AC |
| 6624 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6625 | 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] | 6626 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6627 | 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] | 6628 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6629 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6630 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6631 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6632 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6633 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6634 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6635 | maxMCSIdx = 7; |
| 6636 | } |
| 6637 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6638 | { |
| 6639 | maxMCSIdx = 8; |
| 6640 | } |
| 6641 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6642 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6643 | //VHT20 is supporting 0~8 |
| 6644 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6645 | maxMCSIdx = 8; |
| 6646 | else |
| 6647 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6648 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6649 | |
| 6650 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6651 | { |
| 6652 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6653 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6654 | } |
| 6655 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6656 | { |
| 6657 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6658 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6659 | } |
| 6660 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6661 | { |
| 6662 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6663 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6664 | } |
| 6665 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6666 | maxSpeedMCS = 1; |
| 6667 | if (currentRate > maxRate) |
| 6668 | { |
| 6669 | maxRate = currentRate; |
| 6670 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6671 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6672 | } |
| 6673 | else |
| 6674 | #endif /* WLAN_FEATURE_11AC */ |
| 6675 | { |
| 6676 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6677 | { |
| 6678 | rateFlag |= 1; |
| 6679 | } |
| 6680 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6681 | { |
| 6682 | rateFlag |= 2; |
| 6683 | } |
| 6684 | |
| 6685 | for (i = 0; i < MCSLeng; i++) |
| 6686 | { |
| 6687 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6688 | for (j = 0; j < temp; j++) |
| 6689 | { |
| 6690 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6691 | { |
| 6692 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6693 | break; |
| 6694 | } |
| 6695 | } |
| 6696 | if ((j < temp) && (currentRate > maxRate)) |
| 6697 | { |
| 6698 | maxRate = currentRate; |
| 6699 | maxSpeedMCS = 1; |
| 6700 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6701 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6702 | } |
| 6703 | } |
| 6704 | } |
| 6705 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6706 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6707 | { |
| 6708 | maxRate = myRate; |
| 6709 | maxSpeedMCS = 1; |
| 6710 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6711 | } |
| 6712 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6713 | // 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] | 6714 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6715 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6716 | { |
| 6717 | maxRate = myRate; |
| 6718 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6719 | { |
| 6720 | maxSpeedMCS = 0; |
| 6721 | } |
| 6722 | else |
| 6723 | { |
| 6724 | maxSpeedMCS = 1; |
| 6725 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6726 | } |
| 6727 | } |
| 6728 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6729 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6730 | { |
| 6731 | sinfo->txrate.legacy = maxRate; |
| 6732 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6733 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6734 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6735 | } |
| 6736 | else |
| 6737 | { |
| 6738 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6739 | #ifdef WLAN_FEATURE_11AC |
| 6740 | sinfo->txrate.nss = 1; |
| 6741 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6742 | { |
| 6743 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6744 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6745 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6746 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6747 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6748 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6749 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6750 | } |
| 6751 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6752 | { |
| 6753 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6754 | } |
| 6755 | #endif /* WLAN_FEATURE_11AC */ |
| 6756 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6757 | { |
| 6758 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6759 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6760 | { |
| 6761 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6762 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6763 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6764 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6765 | { |
| 6766 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6767 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6768 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6769 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6770 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6771 | sinfo->txrate.mcs, |
| 6772 | sinfo->txrate.flags ); |
| 6773 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6774 | } |
| 6775 | } |
| 6776 | else |
| 6777 | { |
| 6778 | // report current rate instead of max rate |
| 6779 | |
| 6780 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6781 | { |
| 6782 | //provide to the UI in units of 100kbps |
| 6783 | sinfo->txrate.legacy = myRate; |
| 6784 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6785 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6786 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6787 | } |
| 6788 | else |
| 6789 | { |
| 6790 | //must be MCS |
| 6791 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6792 | #ifdef WLAN_FEATURE_11AC |
| 6793 | sinfo->txrate.nss = 1; |
| 6794 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6795 | { |
| 6796 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6797 | } |
| 6798 | else |
| 6799 | #endif /* WLAN_FEATURE_11AC */ |
| 6800 | { |
| 6801 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6802 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6803 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6804 | { |
| 6805 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6806 | } |
| 6807 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6808 | { |
| 6809 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6810 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6811 | #ifdef WLAN_FEATURE_11AC |
| 6812 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6813 | { |
| 6814 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6815 | } |
| 6816 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6817 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6818 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6819 | sinfo->txrate.mcs, |
| 6820 | sinfo->txrate.flags ); |
| 6821 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6822 | } |
| 6823 | } |
| 6824 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6825 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6826 | sinfo->tx_packets = |
| 6827 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6828 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6829 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6830 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6831 | |
| 6832 | sinfo->tx_retries = |
| 6833 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6834 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6835 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6836 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6837 | |
| 6838 | sinfo->tx_failed = |
| 6839 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6840 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6841 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6842 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6843 | |
| 6844 | sinfo->filled |= |
| 6845 | STATION_INFO_TX_PACKETS | |
| 6846 | STATION_INFO_TX_RETRIES | |
| 6847 | STATION_INFO_TX_FAILED; |
| 6848 | |
| 6849 | EXIT(); |
| 6850 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6851 | } |
| 6852 | |
| 6853 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 6854 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6855 | { |
| 6856 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6857 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6858 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6859 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6860 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6861 | ENTER(); |
| 6862 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6863 | if (NULL == pAdapter) |
| 6864 | { |
| 6865 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6866 | return -ENODEV; |
| 6867 | } |
| 6868 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6869 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6870 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6871 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6872 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6873 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6874 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6875 | "%s: HDD context is not valid", __func__); |
| 6876 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6877 | } |
| 6878 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6879 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6880 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6881 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6882 | (eConnectionState_Associated == |
| 6883 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6884 | { |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 6885 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6886 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6887 | { |
| 6888 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6889 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6890 | __func__, vos_status); |
| 6891 | } |
| 6892 | } |
| 6893 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6894 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6895 | *on successful execution of the function call |
| 6896 | *we are oppositely mapped w.r.t mode in the driver |
| 6897 | **/ |
| 6898 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6899 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6900 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6901 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6902 | { |
| 6903 | return -EINVAL; |
| 6904 | } |
| 6905 | return 0; |
| 6906 | } |
| 6907 | |
| 6908 | |
| 6909 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6910 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6911 | struct net_device *netdev, |
| 6912 | u8 key_index) |
| 6913 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6914 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6915 | return 0; |
| 6916 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6917 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6918 | |
| 6919 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6920 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6921 | struct net_device *dev, |
| 6922 | struct ieee80211_txq_params *params) |
| 6923 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6924 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6925 | return 0; |
| 6926 | } |
| 6927 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6928 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6929 | struct ieee80211_txq_params *params) |
| 6930 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6931 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6932 | return 0; |
| 6933 | } |
| 6934 | #endif //LINUX_VERSION_CODE |
| 6935 | |
| 6936 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6937 | struct net_device *dev, u8 *mac) |
| 6938 | { |
| 6939 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6940 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6941 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6942 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6943 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6944 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6945 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6946 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6947 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6948 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6949 | return -EINVAL; |
| 6950 | } |
| 6951 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6952 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6953 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6954 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6955 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6956 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6957 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6958 | "%s: HDD context is not valid", __func__); |
| 6959 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6960 | } |
| 6961 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6962 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6963 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6964 | ) |
| 6965 | { |
| 6966 | if( NULL == mac ) |
| 6967 | { |
| 6968 | v_U16_t i; |
| 6969 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6970 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 6971 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 6972 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6973 | { |
| 6974 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6975 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6976 | "%s: Delete STA with MAC::" |
| 6977 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6978 | __func__, |
| 6979 | macAddr[0], macAddr[1], macAddr[2], |
| 6980 | macAddr[3], macAddr[4], macAddr[5]); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 6981 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6982 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6983 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6984 | } |
| 6985 | } |
| 6986 | } |
| 6987 | else |
| 6988 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6989 | |
| 6990 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6991 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6992 | { |
| 6993 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6994 | "%s: Skip this DEL STA as this is not used::" |
| 6995 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6996 | __func__, |
| 6997 | mac[0], mac[1], mac[2], |
| 6998 | mac[3], mac[4], mac[5]); |
| 6999 | return -ENOENT; |
| 7000 | } |
| 7001 | |
| 7002 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 7003 | { |
| 7004 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7005 | "%s: Skip this DEL STA as deauth is in progress::" |
| 7006 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7007 | __func__, |
| 7008 | mac[0], mac[1], mac[2], |
| 7009 | mac[3], mac[4], mac[5]); |
| 7010 | return -ENOENT; |
| 7011 | } |
| 7012 | |
| 7013 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 7014 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7015 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7016 | "%s: Delete STA with MAC::" |
| 7017 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7018 | __func__, |
| 7019 | mac[0], mac[1], mac[2], |
| 7020 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7021 | |
| 7022 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 7023 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7024 | { |
| 7025 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 7026 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7027 | "%s: STA removal failed for ::" |
| 7028 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7029 | __func__, |
| 7030 | mac[0], mac[1], mac[2], |
| 7031 | mac[3], mac[4], mac[5]); |
| 7032 | return -ENOENT; |
| 7033 | } |
| 7034 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7035 | } |
| 7036 | } |
| 7037 | |
| 7038 | EXIT(); |
| 7039 | |
| 7040 | return 0; |
| 7041 | } |
| 7042 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7043 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 7044 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 7045 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7046 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7047 | #ifdef FEATURE_WLAN_TDLS |
| 7048 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7049 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7050 | mask = params->sta_flags_mask; |
| 7051 | |
| 7052 | set = params->sta_flags_set; |
| 7053 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7054 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7055 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7056 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 7057 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 7058 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7059 | |
| 7060 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7061 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7062 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7063 | } |
| 7064 | } |
| 7065 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7066 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7067 | } |
| 7068 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7069 | |
| 7070 | #ifdef FEATURE_WLAN_LFR |
| 7071 | 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] | 7072 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7073 | { |
| 7074 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 7075 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7076 | static tANI_U32 i; // HDD Local Cache index |
| 7077 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7078 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7079 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7080 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7081 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7082 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7083 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7084 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7085 | ENTER(); |
| 7086 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7087 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7088 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7089 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7090 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7091 | return -EINVAL; |
| 7092 | } |
| 7093 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7094 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7095 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7096 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7097 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7098 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7099 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7100 | "%s: HDD context is not valid", __func__); |
| 7101 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7102 | } |
| 7103 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7104 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7105 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7106 | |
| 7107 | for (j = 0; j < i; j++) |
| 7108 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7109 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7110 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 7111 | { |
| 7112 | /* BSSID matched previous entry. Overwrite it. */ |
| 7113 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7114 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7115 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7116 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7117 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7118 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7119 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7120 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7121 | dump_bssid(pmksa->bssid); |
| 7122 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7123 | break; |
| 7124 | } |
| 7125 | } |
| 7126 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7127 | /* Check we compared all entries,if then take the first slot now */ |
| 7128 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 7129 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7130 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7131 | { |
| 7132 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 7133 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 7134 | pmksa->bssid, ETHER_ADDR_LEN); |
| 7135 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 7136 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7137 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7138 | 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] | 7139 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7140 | dump_bssid(pmksa->bssid); |
| 7141 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7142 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7143 | // 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] | 7144 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7145 | } |
| 7146 | |
| 7147 | |
| 7148 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7149 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7150 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7151 | 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] | 7152 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7153 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7154 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7155 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7156 | i ); |
| 7157 | return 0; |
| 7158 | } |
| 7159 | |
| 7160 | |
| 7161 | 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] | 7162 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7163 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7164 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7165 | // TODO: Implement this later. |
| 7166 | return 0; |
| 7167 | } |
| 7168 | |
| 7169 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 7170 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7171 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7172 | // TODO: Implement this later. |
| 7173 | return 0; |
| 7174 | } |
| 7175 | #endif |
| 7176 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7177 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7178 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7179 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 7180 | { |
| 7181 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7182 | hdd_station_ctx_t *pHddStaCtx; |
| 7183 | |
| 7184 | if (NULL == pAdapter) |
| 7185 | { |
| 7186 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 7187 | return -ENODEV; |
| 7188 | } |
| 7189 | |
| 7190 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7191 | |
| 7192 | // Added for debug on reception of Re-assoc Req. |
| 7193 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 7194 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7195 | 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] | 7196 | ftie->ie_len); |
| 7197 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 7198 | } |
| 7199 | |
| 7200 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7201 | 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] | 7202 | ftie->ie_len); |
| 7203 | #endif |
| 7204 | |
| 7205 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7206 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 7207 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7208 | ftie->ie_len); |
| 7209 | return 0; |
| 7210 | } |
| 7211 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7212 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7213 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7214 | |
| 7215 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 7216 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7217 | { |
| 7218 | int ret; |
| 7219 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 7220 | hdd_context_t *pHddCtx; |
| 7221 | |
| 7222 | if (NULL == pAdapter) |
| 7223 | { |
| 7224 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7225 | "%s: HDD adapter is Null", __func__); |
| 7226 | return ; |
| 7227 | } |
| 7228 | |
| 7229 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7230 | if (NULL == pHddCtx) |
| 7231 | { |
| 7232 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7233 | "%s: HDD context is Null!!!", __func__); |
| 7234 | return ; |
| 7235 | } |
| 7236 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7237 | spin_lock(&pHddCtx->schedScan_lock); |
| 7238 | if (TRUE == pHddCtx->isWiphySuspended) |
| 7239 | { |
| 7240 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 7241 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7242 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7243 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 7244 | return ; |
| 7245 | } |
| 7246 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7247 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7248 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7249 | |
| 7250 | if (0 > ret) |
| 7251 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7252 | |
| 7253 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7254 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7255 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7256 | } |
| 7257 | |
| 7258 | /* |
| 7259 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7260 | * NL interface to enable PNO |
| 7261 | */ |
| 7262 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7263 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7264 | { |
| 7265 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7266 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7267 | hdd_context_t *pHddCtx; |
| 7268 | tHalHandle hHal; |
| 7269 | v_U32_t i, indx, num_ch; |
| 7270 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7271 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7272 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7273 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7274 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7275 | |
| 7276 | if (NULL == pAdapter) |
| 7277 | { |
| 7278 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7279 | "%s: HDD adapter is Null", __func__); |
| 7280 | return -ENODEV; |
| 7281 | } |
| 7282 | |
| 7283 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7284 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7285 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7286 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7287 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7288 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7289 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7290 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7291 | } |
| 7292 | |
| 7293 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7294 | if (NULL == hHal) |
| 7295 | { |
| 7296 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7297 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7298 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7299 | } |
| 7300 | |
| 7301 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7302 | if (NULL == pPnoRequest) |
| 7303 | { |
| 7304 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7305 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7306 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7307 | } |
| 7308 | |
| 7309 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 7310 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 7311 | |
| 7312 | if (( !pPnoRequest->ucNetworksCount ) || |
| 7313 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 7314 | { |
| 7315 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7316 | "Network input is not correct"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7317 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7318 | goto error; |
| 7319 | } |
| 7320 | |
| 7321 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 7322 | { |
| 7323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7324 | "Incorrect number of channels"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7325 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7326 | goto error; |
| 7327 | } |
| 7328 | |
| 7329 | /* Framework provides one set of channels(all) |
| 7330 | * common for all saved profile */ |
| 7331 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 7332 | channels_allowed, &num_channels_allowed)) |
| 7333 | { |
| 7334 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7335 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7336 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7337 | goto error; |
| 7338 | } |
| 7339 | /* Checking each channel against allowed channel list */ |
| 7340 | num_ch = 0; |
| 7341 | for (i = 0; i < request->n_channels; i++) |
| 7342 | { |
| 7343 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 7344 | { |
| 7345 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 7346 | { |
| 7347 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 7348 | break ; |
| 7349 | } |
| 7350 | } |
| 7351 | } |
| 7352 | |
| 7353 | /* Filling per profile params */ |
| 7354 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 7355 | { |
| 7356 | pPnoRequest->aNetworks[i].ssId.length = |
| 7357 | request->match_sets[i].ssid.ssid_len; |
| 7358 | |
| 7359 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 7360 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 7361 | { |
| 7362 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7363 | "SSID Len %d is not correct for network %d", |
| 7364 | pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7365 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7366 | goto error; |
| 7367 | } |
| 7368 | |
| 7369 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 7370 | request->match_sets[i].ssid.ssid, |
| 7371 | request->match_sets[i].ssid.ssid_len); |
| 7372 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 7373 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 7374 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 7375 | |
| 7376 | /*Copying list of valid channel into request */ |
| 7377 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 7378 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 7379 | |
| 7380 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 7381 | } |
| 7382 | |
| 7383 | /* framework provides interval in ms */ |
| 7384 | pPnoRequest->scanTimers.ucScanTimersCount = 1; |
| 7385 | pPnoRequest->scanTimers.aTimerValues[0].uTimerValue = |
| 7386 | (request->interval)/1000; |
| 7387 | pPnoRequest->scanTimers.aTimerValues[0].uTimerRepeat = 0; |
| 7388 | pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND; |
| 7389 | |
| 7390 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7391 | pPnoRequest, pAdapter->sessionId, |
| 7392 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 7393 | if (eHAL_STATUS_SUCCESS != status) |
| 7394 | { |
| 7395 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7396 | "Failed to enable PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7397 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7398 | goto error; |
| 7399 | } |
| 7400 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7401 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7402 | "PNO scanRequest offloaded"); |
| 7403 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7404 | error: |
| 7405 | vos_mem_free(pPnoRequest); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7406 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7407 | } |
| 7408 | |
| 7409 | /* |
| 7410 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 7411 | * NL interface to disable PNO |
| 7412 | */ |
| 7413 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 7414 | struct net_device *dev) |
| 7415 | { |
| 7416 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7417 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7418 | hdd_context_t *pHddCtx; |
| 7419 | tHalHandle hHal; |
| 7420 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7421 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7422 | |
| 7423 | ENTER(); |
| 7424 | |
| 7425 | if (NULL == pAdapter) |
| 7426 | { |
| 7427 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7428 | "%s: HDD adapter is Null", __func__); |
| 7429 | return -ENODEV; |
| 7430 | } |
| 7431 | |
| 7432 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7433 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7434 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7435 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7436 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7437 | "%s: HDD context is Null", __func__); |
| 7438 | return -ENODEV; |
| 7439 | } |
| 7440 | |
| 7441 | /* The return 0 is intentional when isLogpInProgress and |
| 7442 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 7443 | * failure in sched_scan_stop , especially for a case where the unload |
| 7444 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 7445 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 7446 | * success. If it returns a failure , then its next invocation due to the |
| 7447 | * clean up of the second interface will have the dev pointer corresponding |
| 7448 | * to the first one leading to a crash. |
| 7449 | */ |
| 7450 | if (pHddCtx->isLogpInProgress) |
| 7451 | { |
| 7452 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7453 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7454 | return ret; |
| 7455 | } |
| 7456 | |
| 7457 | if (pHddCtx->isLoadUnloadInProgress) |
| 7458 | { |
| 7459 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7460 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 7461 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7462 | } |
| 7463 | |
| 7464 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7465 | if (NULL == hHal) |
| 7466 | { |
| 7467 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7468 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7469 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7470 | } |
| 7471 | |
| 7472 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7473 | if (NULL == pPnoRequest) |
| 7474 | { |
| 7475 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7476 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7477 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7478 | } |
| 7479 | |
| 7480 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 7481 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 7482 | pPnoRequest->ucNetworksCount = 0; |
| 7483 | |
| 7484 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 7485 | pAdapter->sessionId, |
| 7486 | NULL, pAdapter); |
| 7487 | if (eHAL_STATUS_SUCCESS != status) |
| 7488 | { |
| 7489 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7490 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7491 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7492 | } |
| 7493 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7494 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7495 | "%s: PNO scan disabled", __func__); |
| 7496 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7497 | vos_mem_free(pPnoRequest); |
| 7498 | |
| 7499 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7500 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7501 | } |
| 7502 | |
| 7503 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 7504 | |
| 7505 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7506 | #ifdef FEATURE_WLAN_TDLS |
| 7507 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 7508 | u8 *peer, u8 action_code, u8 dialog_token, |
| 7509 | u16 status_code, const u8 *buf, size_t len) |
| 7510 | { |
| 7511 | |
| 7512 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7513 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7514 | u8 peerMac[6]; |
| 7515 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7516 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7517 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7518 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7519 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7520 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7521 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7522 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7523 | "Invalid arguments"); |
| 7524 | return -EINVAL; |
| 7525 | } |
| 7526 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7527 | if (pHddCtx->isLogpInProgress) |
| 7528 | { |
| 7529 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7530 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7531 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7532 | return -EBUSY; |
| 7533 | } |
| 7534 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7535 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7536 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7537 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7538 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7539 | MAC_ADDRESS_STR " action %d declined.", |
| 7540 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7541 | return -ENOTSUPP; |
| 7542 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7543 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7544 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 7545 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 7546 | { |
| 7547 | /* if tdls_mode is disabled to respond to peer's request */ |
| 7548 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 7549 | { |
| 7550 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7551 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7552 | " TDLS mode is disabled. action %d declined.", |
| 7553 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7554 | |
| 7555 | return -ENOTSUPP; |
| 7556 | } |
| 7557 | } |
| 7558 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7559 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 7560 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 7561 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7562 | { |
| 7563 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7564 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7565 | " TDLS setup is ongoing. action %d declined.", |
| 7566 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7567 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7568 | } |
| 7569 | } |
| 7570 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7571 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 7572 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7573 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7574 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7575 | { |
| 7576 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 7577 | we return error code at 'add_station()'. Hence we have this |
| 7578 | check again in addtion to add_station(). |
| 7579 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7580 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7581 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7582 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7583 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7584 | " TDLS Max peer already connected. action %d declined.", |
| 7585 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7586 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7587 | } |
| 7588 | else |
| 7589 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7590 | /* maximum reached. tweak to send error code to peer and return |
| 7591 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7592 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7593 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7594 | "%s: " MAC_ADDRESS_STR |
| 7595 | " TDLS Max peer already connected send response status %d", |
| 7596 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7597 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7598 | /* fall through to send setup resp with failure status |
| 7599 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7600 | } |
| 7601 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7602 | else |
| 7603 | { |
| 7604 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7605 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7606 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7607 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7608 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7609 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 7610 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7611 | return -EPERM; |
| 7612 | } |
| 7613 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7614 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7615 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7616 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7617 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7618 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7619 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 7620 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 7621 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7622 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7623 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7624 | /*Except teardown responder will not be used so just make 0*/ |
| 7625 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7626 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7627 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7628 | |
| 7629 | hddTdlsPeer_t *pTdlsPeer; |
| 7630 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 7631 | |
| 7632 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 7633 | responder = pTdlsPeer->is_responder; |
| 7634 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7635 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7636 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7637 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 7638 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 7639 | dialog_token, status_code, len); |
| 7640 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7641 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7642 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7643 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7644 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 7645 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7646 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7647 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 7648 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7649 | { |
| 7650 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 7651 | { |
| 7652 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7653 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7654 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7655 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7656 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 7657 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7658 | } |
| 7659 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7660 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7661 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7662 | { |
| 7663 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7664 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7665 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7666 | return -EBUSY; |
| 7667 | } |
| 7668 | |
| 7669 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7670 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7671 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7672 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7673 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7674 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7675 | if (VOS_STATUS_SUCCESS != status) |
| 7676 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7677 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7678 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7679 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7680 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7681 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7682 | } |
| 7683 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7684 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7685 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7686 | |
| 7687 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7688 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7689 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7690 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7691 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7692 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7693 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7694 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7695 | } |
| 7696 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7697 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7698 | { |
| 7699 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7700 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7701 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7702 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7703 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7704 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7705 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7706 | } |
| 7707 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7708 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7709 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7710 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7711 | |
| 7712 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7713 | error: |
| 7714 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7715 | because we already know that this transaction will be failed, |
| 7716 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7717 | to be safe, do not change the state mahine. |
| 7718 | */ |
| 7719 | if(max_sta_failed == 0 && |
| 7720 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7721 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7722 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7723 | } |
| 7724 | |
| 7725 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7726 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7727 | { |
| 7728 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7729 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7730 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7731 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7732 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7733 | tANI_U8 staIdx; |
| 7734 | #endif |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7735 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7736 | const char *tdls_oper_str[]= { |
| 7737 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7738 | "NL80211_TDLS_SETUP", |
| 7739 | "NL80211_TDLS_TEARDOWN", |
| 7740 | "NL80211_TDLS_ENABLE_LINK", |
| 7741 | "NL80211_TDLS_DISABLE_LINK", |
Gopichand Nakkala | 29d0019 | 2013-06-20 19:03:52 +0530 | [diff] [blame] | 7742 | "NL80211_TDLS_UNKNOWN_OPER"}; |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7743 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7744 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7745 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7746 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7747 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7748 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7749 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7750 | return -EINVAL; |
| 7751 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7752 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7753 | status = wlan_hdd_validate_context(pHddCtx); |
| 7754 | |
| 7755 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7756 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7757 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7758 | "%s: HDD context is not valid", __func__); |
| 7759 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7760 | } |
| 7761 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7762 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7763 | |
| 7764 | if ( NULL == pTdlsPeer ) { |
| 7765 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7766 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7767 | return -EINVAL; |
| 7768 | } |
| 7769 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7770 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7771 | if((int)oper > 4) |
| 7772 | oper = 5; |
| 7773 | |
| 7774 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7775 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7776 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7777 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7778 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7779 | |
| 7780 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7781 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7782 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7783 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7784 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7785 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7786 | return -ENOTSUPP; |
| 7787 | } |
| 7788 | |
| 7789 | switch (oper) { |
| 7790 | case NL80211_TDLS_ENABLE_LINK: |
| 7791 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7792 | VOS_STATUS status; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7793 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7794 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7795 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7796 | { |
| 7797 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7798 | MAC_ADDRESS_STR " failed", |
| 7799 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7800 | return -EINVAL; |
| 7801 | } |
| 7802 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7803 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7804 | { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7805 | long ret; |
| 7806 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7807 | if (0 != wlan_hdd_tdls_get_link_establish_params(pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 7808 | return -EINVAL; |
| 7809 | } |
| 7810 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
| 7811 | |
| 7812 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7813 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 7814 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 7815 | * register with the TL on after the response for this operation |
| 7816 | * is received . |
| 7817 | */ |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7818 | ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_link_establish_req_comp, |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7819 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7820 | if (ret <= 0) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7821 | { |
| 7822 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7823 | "%s: Link Establish Request Faled Status %ld", |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7824 | __func__, ret); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7825 | return -EINVAL; |
| 7826 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7827 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 7828 | /* Mark TDLS client Authenticated .*/ |
| 7829 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 7830 | pTdlsPeer->staId, |
| 7831 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7832 | if (VOS_STATUS_SUCCESS == status) |
| 7833 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7834 | if (pTdlsPeer->is_responder == 0) |
| 7835 | { |
| 7836 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7837 | |
| 7838 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7839 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7840 | WAIT_TIME_TDLS_INITIATOR); |
| 7841 | /* suspend initiator TX until it receives direct packet from the |
| 7842 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7843 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7844 | &staId, NULL); |
| 7845 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7846 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7847 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7848 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7849 | |
| 7850 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 7851 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 7852 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7853 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 7854 | int ac; |
| 7855 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 7856 | WLANTL_AC_VI, |
| 7857 | WLANTL_AC_BK, |
| 7858 | WLANTL_AC_BE }; |
| 7859 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 7860 | for(ac=0; ac < 4; ac++) |
| 7861 | { |
| 7862 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7863 | pTdlsPeer->staId, ucAc[ac], |
| 7864 | tlTid[ac], tlTid[ac], 0, 0, |
| 7865 | WLANTL_BI_DIR ); |
| 7866 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7867 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7868 | } |
| 7869 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7870 | } |
| 7871 | break; |
| 7872 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7873 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7874 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7875 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7876 | long status; |
| 7877 | |
| 7878 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7879 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7880 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7881 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7882 | |
| 7883 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7884 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7885 | if (status <= 0) |
| 7886 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7887 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7888 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7889 | "%s: Del station failed status %ld", |
| 7890 | __func__, status); |
| 7891 | return -EPERM; |
| 7892 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7893 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7894 | } |
| 7895 | else |
| 7896 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7897 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7898 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7899 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7900 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7901 | if (pHddTdlsCtx->defer_link_lost_indication) |
| 7902 | { |
| 7903 | if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) && |
| 7904 | (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0)) |
| 7905 | { |
| 7906 | status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7907 | if ( 0 != status) |
| 7908 | { |
| 7909 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7910 | "%s wlan_hdd_disconnect failure, returned %d \n", |
| 7911 | __func__, (int)status ); |
| 7912 | return -EINVAL; |
| 7913 | } |
| 7914 | } |
| 7915 | } |
| 7916 | #endif |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7917 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7918 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7919 | case NL80211_TDLS_TEARDOWN: |
| 7920 | case NL80211_TDLS_SETUP: |
| 7921 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7922 | /* We don't support in-driver setup/teardown/discovery */ |
| 7923 | return -ENOTSUPP; |
| 7924 | default: |
| 7925 | return -ENOTSUPP; |
| 7926 | } |
| 7927 | return 0; |
| 7928 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7929 | |
| 7930 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7931 | struct net_device *dev, u8 *peer) |
| 7932 | { |
| 7933 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7934 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7935 | |
| 7936 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7937 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7938 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7939 | #endif |
| 7940 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7941 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7942 | /* |
| 7943 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7944 | * Callback rountine called upon receiving response for |
| 7945 | * get offload info |
| 7946 | */ |
| 7947 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7948 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7949 | { |
| 7950 | |
| 7951 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7952 | tANI_U8 tempReplayCounter[8]; |
| 7953 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7954 | |
| 7955 | ENTER(); |
| 7956 | |
| 7957 | if (NULL == pAdapter) |
| 7958 | { |
| 7959 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7960 | "%s: HDD adapter is Null", __func__); |
| 7961 | return ; |
| 7962 | } |
| 7963 | |
| 7964 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7965 | { |
| 7966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7967 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7968 | return ; |
| 7969 | } |
| 7970 | |
| 7971 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7972 | { |
| 7973 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7974 | "%s: wlan Failed to get replay counter value", |
| 7975 | __func__); |
| 7976 | return ; |
| 7977 | } |
| 7978 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7979 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7980 | /* Update replay counter */ |
| 7981 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 7982 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7983 | |
| 7984 | { |
| 7985 | /* changing from little to big endian since supplicant |
| 7986 | * works on big endian format |
| 7987 | */ |
| 7988 | int i; |
| 7989 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7990 | |
| 7991 | for (i = 0; i < 8; i++) |
| 7992 | { |
| 7993 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 7994 | } |
| 7995 | } |
| 7996 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7997 | /* Update replay counter to NL */ |
| 7998 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7999 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8000 | } |
| 8001 | |
| 8002 | /* |
| 8003 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 8004 | * This function is used to offload GTK rekeying job to the firmware. |
| 8005 | */ |
| 8006 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 8007 | struct cfg80211_gtk_rekey_data *data) |
| 8008 | { |
| 8009 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8010 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8011 | hdd_station_ctx_t *pHddStaCtx; |
| 8012 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8013 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8014 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8015 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8016 | |
| 8017 | ENTER(); |
| 8018 | |
| 8019 | if (NULL == pAdapter) |
| 8020 | { |
| 8021 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8022 | "%s: HDD adapter is Null", __func__); |
| 8023 | return -ENODEV; |
| 8024 | } |
| 8025 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8026 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8027 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8028 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8029 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8030 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8031 | "%s: HDD context is not valid", __func__); |
| 8032 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8033 | } |
| 8034 | |
| 8035 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8036 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8037 | if (NULL == hHal) |
| 8038 | { |
| 8039 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8040 | "%s: HAL context is Null!!!", __func__); |
| 8041 | return -EAGAIN; |
| 8042 | } |
| 8043 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8044 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 8045 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 8046 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 8047 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8048 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8049 | { |
| 8050 | /* changing from big to little endian since driver |
| 8051 | * works on little endian format |
| 8052 | */ |
| 8053 | tANI_U8 *p = |
| 8054 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 8055 | int i; |
| 8056 | |
| 8057 | for (i = 0; i < 8; i++) |
| 8058 | { |
| 8059 | p[7-i] = data->replay_ctr[i]; |
| 8060 | } |
| 8061 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8062 | |
| 8063 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 8064 | { |
| 8065 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8066 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 8067 | sizeof (tSirGtkOffloadParams)); |
| 8068 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8069 | pAdapter->sessionId); |
| 8070 | |
| 8071 | if (eHAL_STATUS_SUCCESS != status) |
| 8072 | { |
| 8073 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8074 | "%s: sme_SetGTKOffload failed, returned %d", |
| 8075 | __func__, status); |
| 8076 | return status; |
| 8077 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8078 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8079 | "%s: sme_SetGTKOffload successfull", __func__); |
| 8080 | } |
| 8081 | else |
| 8082 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8083 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8084 | "%s: wlan not suspended GTKOffload request is stored", |
| 8085 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8086 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8087 | |
| 8088 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8089 | } |
| 8090 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 8091 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8092 | /* |
| 8093 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 8094 | * This function is used to set access control policy |
| 8095 | */ |
| 8096 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 8097 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 8098 | { |
| 8099 | int i; |
| 8100 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8101 | hdd_hostapd_state_t *pHostapdState; |
| 8102 | tsap_Config_t *pConfig; |
| 8103 | v_CONTEXT_t pVosContext = NULL; |
| 8104 | hdd_context_t *pHddCtx; |
| 8105 | int status; |
| 8106 | |
| 8107 | ENTER(); |
| 8108 | |
| 8109 | if (NULL == pAdapter) |
| 8110 | { |
| 8111 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8112 | "%s: HDD adapter is Null", __func__); |
| 8113 | return -ENODEV; |
| 8114 | } |
| 8115 | |
| 8116 | if (NULL == params) |
| 8117 | { |
| 8118 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8119 | "%s: params is Null", __func__); |
| 8120 | return -EINVAL; |
| 8121 | } |
| 8122 | |
| 8123 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8124 | status = wlan_hdd_validate_context(pHddCtx); |
| 8125 | |
| 8126 | if (0 != status) |
| 8127 | { |
| 8128 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8129 | "%s: HDD context is not valid", __func__); |
| 8130 | return status; |
| 8131 | } |
| 8132 | |
| 8133 | pVosContext = pHddCtx->pvosContext; |
| 8134 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8135 | |
| 8136 | if (NULL == pHostapdState) |
| 8137 | { |
| 8138 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8139 | "%s: pHostapdState is Null", __func__); |
| 8140 | return -EINVAL; |
| 8141 | } |
| 8142 | |
| 8143 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 8144 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 8145 | |
| 8146 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 8147 | { |
| 8148 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 8149 | |
| 8150 | /* default value */ |
| 8151 | pConfig->num_accept_mac = 0; |
| 8152 | pConfig->num_deny_mac = 0; |
| 8153 | |
| 8154 | /** |
| 8155 | * access control policy |
| 8156 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 8157 | * listed in hostapd.deny file. |
| 8158 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 8159 | * listed in hostapd.accept file. |
| 8160 | */ |
| 8161 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 8162 | { |
| 8163 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 8164 | } |
| 8165 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 8166 | { |
| 8167 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 8168 | } |
| 8169 | else |
| 8170 | { |
| 8171 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8172 | "%s:Acl Policy : %d is not supported", |
| 8173 | __func__, params->acl_policy); |
| 8174 | return -ENOTSUPP; |
| 8175 | } |
| 8176 | |
| 8177 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 8178 | { |
| 8179 | pConfig->num_accept_mac = params->n_acl_entries; |
| 8180 | for (i = 0; i < params->n_acl_entries; i++) |
| 8181 | { |
| 8182 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8183 | "** Add ACL MAC entry %i in WhiletList :" |
| 8184 | MAC_ADDRESS_STR, i, |
| 8185 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8186 | |
| 8187 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 8188 | sizeof(qcmacaddr)); |
| 8189 | } |
| 8190 | } |
| 8191 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 8192 | { |
| 8193 | pConfig->num_deny_mac = params->n_acl_entries; |
| 8194 | for (i = 0; i < params->n_acl_entries; i++) |
| 8195 | { |
| 8196 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8197 | "** Add ACL MAC entry %i in BlackList :" |
| 8198 | MAC_ADDRESS_STR, i, |
| 8199 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8200 | |
| 8201 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 8202 | sizeof(qcmacaddr)); |
| 8203 | } |
| 8204 | } |
| 8205 | |
| 8206 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 8207 | { |
| 8208 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8209 | "%s: SAP Set Mac Acl fail", __func__); |
| 8210 | return -EINVAL; |
| 8211 | } |
| 8212 | } |
| 8213 | else |
| 8214 | { |
| 8215 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8216 | "%s: Invalid device_mode = %d", |
| 8217 | __func__, pAdapter->device_mode); |
| 8218 | return -EINVAL; |
| 8219 | } |
| 8220 | |
| 8221 | return 0; |
| 8222 | } |
| 8223 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8224 | #ifdef WLAN_NL80211_TESTMODE |
| 8225 | #ifdef FEATURE_WLAN_LPHB |
| 8226 | static void wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler |
| 8227 | ( |
| 8228 | void *pAdapter, |
| 8229 | void *indCont |
| 8230 | ) |
| 8231 | { |
| 8232 | tSirLPHBTimeoutInd *lphbTimeoutInd; |
| 8233 | struct sk_buff *skb; |
| 8234 | |
| 8235 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8236 | "LPHB wait timeout indication arrived"); |
| 8237 | |
| 8238 | if (NULL == indCont) |
| 8239 | { |
| 8240 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8241 | "LPHB timeout, invalid argument"); |
| 8242 | return; |
| 8243 | } |
| 8244 | |
| 8245 | lphbTimeoutInd = (tSirLPHBTimeoutInd *)indCont; |
| 8246 | skb = cfg80211_testmode_alloc_event_skb( |
| 8247 | ((hdd_adapter_t *)pAdapter)->wdev.wiphy, |
| 8248 | sizeof(tSirLPHBTimeoutInd), |
| 8249 | GFP_ATOMIC); |
| 8250 | if (!skb) |
| 8251 | { |
| 8252 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8253 | "LPHB timeout, NL buffer alloc fail"); |
| 8254 | return; |
| 8255 | } |
| 8256 | |
| 8257 | NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB); |
| 8258 | NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbTimeoutInd->protocolType); |
| 8259 | NLA_PUT(skb, WLAN_HDD_TM_ATTR_DATA, |
| 8260 | sizeof(tSirLPHBTimeoutInd), lphbTimeoutInd); |
| 8261 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 8262 | return; |
| 8263 | |
| 8264 | nla_put_failure: |
| 8265 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8266 | "NLA Put fail"); |
| 8267 | kfree_skb(skb); |
| 8268 | |
| 8269 | return; |
| 8270 | } |
| 8271 | #endif /* FEATURE_WLAN_LPHB */ |
| 8272 | |
| 8273 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 8274 | { |
| 8275 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 8276 | int err = 0; |
| 8277 | #ifdef FEATURE_WLAN_LPHB |
| 8278 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8279 | #endif /* FEATURE_WLAN_LPHB */ |
| 8280 | |
| 8281 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 8282 | if (err) |
| 8283 | { |
| 8284 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8285 | "%s Testmode INV ATTR", __func__); |
| 8286 | return err; |
| 8287 | } |
| 8288 | |
| 8289 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 8290 | { |
| 8291 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8292 | "%s Testmode INV CMD", __func__); |
| 8293 | return -EINVAL; |
| 8294 | } |
| 8295 | |
| 8296 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 8297 | { |
| 8298 | #ifdef FEATURE_WLAN_LPHB |
| 8299 | /* Low Power Heartbeat configuration request */ |
| 8300 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 8301 | { |
| 8302 | int buf_len; |
| 8303 | void *buf; |
| 8304 | tSirLPHBReq *hb_params = NULL; |
| 8305 | |
| 8306 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 8307 | { |
| 8308 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8309 | "%s Testmode INV DATA", __func__); |
| 8310 | return -EINVAL; |
| 8311 | } |
| 8312 | |
| 8313 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 8314 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 8315 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 8316 | if (NULL == hb_params) |
| 8317 | { |
| 8318 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8319 | "%s Request Buffer Alloc Fail", __func__); |
| 8320 | return -EINVAL; |
| 8321 | } |
| 8322 | |
| 8323 | vos_mem_copy(hb_params, buf, buf_len); |
| 8324 | |
| 8325 | /* LPHB enable and disable request will send to FW |
| 8326 | * when host suspend and resume |
| 8327 | * host suspend -> enable LPHB |
| 8328 | * host resume -> disable LPHB |
| 8329 | * if host is not suspend, cache into HDD context |
| 8330 | * and when host goes to suspend, send request to FW */ |
| 8331 | if ((LPHB_SET_EN_PARAMS_INDID == hb_params->cmd) && |
| 8332 | (!pHddCtx->hdd_wlan_suspended)) |
| 8333 | { |
| 8334 | /* Feature enable command cache into HDD context, |
| 8335 | * if WLAN is not suspend |
| 8336 | * When WLAN goes into suspend, send enable command to FW */ |
| 8337 | pHddCtx->lphbEnableReq.enable = |
| 8338 | hb_params->params.lphbEnableReq.enable; |
| 8339 | pHddCtx->lphbEnableReq.item = |
| 8340 | hb_params->params.lphbEnableReq.item; |
| 8341 | pHddCtx->lphbEnableReq.session = |
| 8342 | hb_params->params.lphbEnableReq.session; |
| 8343 | vos_mem_free(hb_params); |
| 8344 | } |
| 8345 | else |
| 8346 | { |
| 8347 | eHalStatus smeStatus; |
| 8348 | |
| 8349 | /* If WLAN is suspend state, send enable command immediately */ |
| 8350 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 8351 | hb_params, |
| 8352 | wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler); |
| 8353 | if (eHAL_STATUS_SUCCESS != smeStatus) |
| 8354 | { |
| 8355 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8356 | "LPHB Config Fail, disable"); |
| 8357 | pHddCtx->lphbEnableReq.enable = 0; |
| 8358 | vos_mem_free(hb_params); |
| 8359 | } |
| 8360 | } |
| 8361 | return 0; |
| 8362 | } |
| 8363 | #endif /* FEATURE_WLAN_LPHB */ |
| 8364 | default: |
| 8365 | return -EOPNOTSUPP; |
| 8366 | } |
| 8367 | |
| 8368 | return err; |
| 8369 | } |
| 8370 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 8371 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8372 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 8373 | struct net_device *dev, |
| 8374 | int idx, struct survey_info *survey) |
| 8375 | { |
| 8376 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8377 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8378 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8379 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8380 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8381 | v_S7_t snr,rssi; |
| 8382 | int status, i, j, filled = 0; |
| 8383 | |
| 8384 | ENTER(); |
| 8385 | |
| 8386 | |
| 8387 | if (NULL == pAdapter) |
| 8388 | { |
| 8389 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8390 | "%s: HDD adapter is Null", __func__); |
| 8391 | return -ENODEV; |
| 8392 | } |
| 8393 | |
| 8394 | if (NULL == wiphy) |
| 8395 | { |
| 8396 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8397 | "%s: wiphy is Null", __func__); |
| 8398 | return -ENODEV; |
| 8399 | } |
| 8400 | |
| 8401 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8402 | status = wlan_hdd_validate_context(pHddCtx); |
| 8403 | |
| 8404 | if (0 != status) |
| 8405 | { |
| 8406 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8407 | "%s: HDD context is not valid", __func__); |
| 8408 | return status; |
| 8409 | } |
| 8410 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8411 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8412 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8413 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8414 | 0 != pAdapter->survey_idx || |
| 8415 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8416 | { |
| 8417 | /* The survey dump ops when implemented completely is expected to |
| 8418 | * return a survey of all channels and the ops is called by the |
| 8419 | * kernel with incremental values of the argument 'idx' till it |
| 8420 | * returns -ENONET. But we can only support the survey for the |
| 8421 | * operating channel for now. survey_idx is used to track |
| 8422 | * that the ops is called only once and then return -ENONET for |
| 8423 | * the next iteration |
| 8424 | */ |
| 8425 | pAdapter->survey_idx = 0; |
| 8426 | return -ENONET; |
| 8427 | } |
| 8428 | |
| 8429 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8430 | |
| 8431 | wlan_hdd_get_snr(pAdapter, &snr); |
| 8432 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 8433 | |
| 8434 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 8435 | hdd_wlan_get_freq(channel, &freq); |
| 8436 | |
| 8437 | |
| 8438 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 8439 | { |
| 8440 | if (NULL == wiphy->bands[i]) |
| 8441 | { |
| 8442 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 8443 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 8444 | continue; |
| 8445 | } |
| 8446 | |
| 8447 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 8448 | { |
| 8449 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 8450 | |
| 8451 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 8452 | { |
| 8453 | survey->channel = &band->channels[j]; |
| 8454 | /* The Rx BDs contain SNR values in dB for the received frames |
| 8455 | * while the supplicant expects noise. So we calculate and |
| 8456 | * return the value of noise (dBm) |
| 8457 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 8458 | */ |
| 8459 | survey->noise = rssi - snr; |
| 8460 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 8461 | filled = 1; |
| 8462 | } |
| 8463 | } |
| 8464 | } |
| 8465 | |
| 8466 | if (filled) |
| 8467 | pAdapter->survey_idx = 1; |
| 8468 | else |
| 8469 | { |
| 8470 | pAdapter->survey_idx = 0; |
| 8471 | return -ENONET; |
| 8472 | } |
| 8473 | |
| 8474 | return 0; |
| 8475 | } |
| 8476 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8477 | /* |
| 8478 | * FUNCTION: wlan_hdd_cfg80211_resume_wlan |
| 8479 | * this is called when cfg80211 driver resume |
| 8480 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 8481 | */ |
| 8482 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 8483 | { |
| 8484 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8485 | hdd_adapter_t *pAdapter; |
| 8486 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 8487 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 8488 | |
| 8489 | ENTER(); |
| 8490 | |
| 8491 | if ( NULL == pHddCtx ) |
| 8492 | { |
| 8493 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8494 | "%s: HddCtx validation failed", __func__); |
| 8495 | return 0; |
| 8496 | } |
| 8497 | |
| 8498 | if (pHddCtx->isLogpInProgress) |
| 8499 | { |
| 8500 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8501 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8502 | return 0; |
| 8503 | } |
| 8504 | |
| 8505 | if (pHddCtx->isLoadUnloadInProgress) |
| 8506 | { |
| 8507 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8508 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 8509 | return 0; |
| 8510 | } |
| 8511 | |
| 8512 | spin_lock(&pHddCtx->schedScan_lock); |
| 8513 | pHddCtx->isWiphySuspended = FALSE; |
| 8514 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 8515 | { |
| 8516 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8517 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8518 | "%s: Return resume is not due to PNO indication", __func__); |
| 8519 | return 0; |
| 8520 | } |
| 8521 | // Reset flag to avoid updatating cfg80211 data old results again |
| 8522 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 8523 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8524 | |
| 8525 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8526 | |
| 8527 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 8528 | { |
| 8529 | pAdapter = pAdapterNode->pAdapter; |
| 8530 | if ( (NULL != pAdapter) && |
| 8531 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 8532 | { |
| 8533 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
| 8534 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 8535 | "%s: NO SCAN result", __func__); |
| 8536 | else |
| 8537 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
| 8538 | |
| 8539 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8540 | "%s : cfg80211 scan result database updated", __func__); |
| 8541 | |
| 8542 | return 0; |
| 8543 | |
| 8544 | } |
| 8545 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8546 | pAdapterNode = pNext; |
| 8547 | } |
| 8548 | |
| 8549 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8550 | "%s: Failed to find Adapter", __func__); |
| 8551 | return 0; |
| 8552 | } |
| 8553 | |
| 8554 | /* |
| 8555 | * FUNCTION: wlan_hdd_cfg80211_suspend_wlan |
| 8556 | * this is called when cfg80211 driver suspends |
| 8557 | */ |
| 8558 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 8559 | struct cfg80211_wowlan *wow) |
| 8560 | { |
| 8561 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8562 | |
| 8563 | ENTER(); |
| 8564 | if (NULL == pHddCtx) |
| 8565 | { |
| 8566 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8567 | "%s: HddCtx validation failed", __func__); |
| 8568 | return 0; |
| 8569 | } |
| 8570 | |
| 8571 | pHddCtx->isWiphySuspended = TRUE; |
| 8572 | |
| 8573 | EXIT(); |
| 8574 | |
| 8575 | return 0; |
| 8576 | } |
| 8577 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8578 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8579 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8580 | { |
| 8581 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 8582 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 8583 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 8584 | .change_station = wlan_hdd_change_station, |
| 8585 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 8586 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 8587 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 8588 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8589 | #else |
| 8590 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 8591 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 8592 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8593 | #endif |
| 8594 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 8595 | .add_key = wlan_hdd_cfg80211_add_key, |
| 8596 | .get_key = wlan_hdd_cfg80211_get_key, |
| 8597 | .del_key = wlan_hdd_cfg80211_del_key, |
| 8598 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8599 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8600 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8601 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8602 | .scan = wlan_hdd_cfg80211_scan, |
| 8603 | .connect = wlan_hdd_cfg80211_connect, |
| 8604 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 8605 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 8606 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 8607 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 8608 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 8609 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8610 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 8611 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 8612 | .mgmt_tx = wlan_hdd_action, |
| 8613 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 8614 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 8615 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 8616 | .set_txq_params = wlan_hdd_set_txq_params, |
| 8617 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8618 | .get_station = wlan_hdd_cfg80211_get_station, |
| 8619 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 8620 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8621 | .add_station = wlan_hdd_cfg80211_add_station, |
| 8622 | #ifdef FEATURE_WLAN_LFR |
| 8623 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 8624 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 8625 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 8626 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8627 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 8628 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 8629 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8630 | #ifdef FEATURE_WLAN_TDLS |
| 8631 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 8632 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 8633 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8634 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8635 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 8636 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8637 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8638 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 8639 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 8640 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8641 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 8642 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8643 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8644 | #ifdef WLAN_NL80211_TESTMODE |
| 8645 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 8646 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8647 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8648 | }; |
| 8649 | |