Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 21 | |
| 22 | /**======================================================================== |
| 23 | |
| 24 | \file wlan_hdd_cfg80211.c |
| 25 | |
| 26 | \brief WLAN Host Device Driver implementation |
| 27 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 28 | Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 30 | Qualcomm Technologies Confidential and Proprietary. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | |
| 32 | ========================================================================*/ |
| 33 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 34 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 36 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | |
| 38 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 39 | This section contains comments describing changes made to the module. |
| 40 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | |
| 42 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 43 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | |
| 45 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 46 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 48 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 49 | |
| 50 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 51 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | ==========================================================================*/ |
| 53 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | |
| 55 | #include <linux/version.h> |
| 56 | #include <linux/module.h> |
| 57 | #include <linux/kernel.h> |
| 58 | #include <linux/init.h> |
| 59 | #include <linux/wireless.h> |
| 60 | #include <wlan_hdd_includes.h> |
| 61 | #include <net/arp.h> |
| 62 | #include <net/cfg80211.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <wlan_hdd_wowl.h> |
| 65 | #include <aniGlobal.h> |
| 66 | #include "ccmApi.h" |
| 67 | #include "sirParams.h" |
| 68 | #include "dot11f.h" |
| 69 | #include "wlan_hdd_assoc.h" |
| 70 | #include "wlan_hdd_wext.h" |
| 71 | #include "sme_Api.h" |
| 72 | #include "wlan_hdd_p2p.h" |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_hostapd.h" |
| 75 | #include "sapInternal.h" |
| 76 | #include "wlan_hdd_softap_tx_rx.h" |
| 77 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 78 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 79 | #include "wlan_hdd_power.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 80 | #ifdef WLAN_BTAMP_FEATURE |
| 81 | #include "bap_hdd_misc.h" |
| 82 | #endif |
| 83 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 84 | #ifdef FEATURE_WLAN_TDLS |
| 85 | #include "wlan_hdd_tdls.h" |
| 86 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 87 | #include "wlan_nv.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 88 | |
| 89 | #define g_mode_rates_size (12) |
| 90 | #define a_mode_rates_size (8) |
| 91 | #define FREQ_BASE_80211G (2407) |
| 92 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 93 | #define MAX_SCAN_SSID 9 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 94 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 95 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 96 | |
| 97 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 98 | .band = IEEE80211_BAND_2GHZ, \ |
| 99 | .center_freq = (freq), \ |
| 100 | .hw_value = (chan),\ |
| 101 | .flags = (flag), \ |
| 102 | .max_antenna_gain = 0 ,\ |
| 103 | .max_power = 30, \ |
| 104 | } |
| 105 | |
| 106 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 107 | .band = IEEE80211_BAND_5GHZ, \ |
| 108 | .center_freq = (freq), \ |
| 109 | .hw_value = (chan),\ |
| 110 | .flags = (flag), \ |
| 111 | .max_antenna_gain = 0 ,\ |
| 112 | .max_power = 30, \ |
| 113 | } |
| 114 | |
| 115 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 116 | {\ |
| 117 | .bitrate = rate, \ |
| 118 | .hw_value = rate_id, \ |
| 119 | .flags = flag, \ |
| 120 | } |
| 121 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 122 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 123 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 124 | #else |
| 125 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 126 | #endif |
| 127 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 128 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 129 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 130 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 131 | #endif |
| 132 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 133 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 134 | { |
| 135 | WLAN_CIPHER_SUITE_WEP40, |
| 136 | WLAN_CIPHER_SUITE_WEP104, |
| 137 | WLAN_CIPHER_SUITE_TKIP, |
| 138 | #ifdef FEATURE_WLAN_CCX |
| 139 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 140 | WLAN_CIPHER_SUITE_KRK, |
| 141 | WLAN_CIPHER_SUITE_CCMP, |
| 142 | #else |
| 143 | WLAN_CIPHER_SUITE_CCMP, |
| 144 | #endif |
| 145 | #ifdef FEATURE_WLAN_WAPI |
| 146 | WLAN_CIPHER_SUITE_SMS4, |
| 147 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 148 | #ifdef WLAN_FEATURE_11W |
| 149 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 150 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 154 | { |
| 155 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 156 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 157 | } |
| 158 | |
| 159 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 160 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 161 | HDD2GHZCHAN(2412, 1, 0) , |
| 162 | HDD2GHZCHAN(2417, 2, 0) , |
| 163 | HDD2GHZCHAN(2422, 3, 0) , |
| 164 | HDD2GHZCHAN(2427, 4, 0) , |
| 165 | HDD2GHZCHAN(2432, 5, 0) , |
| 166 | HDD2GHZCHAN(2437, 6, 0) , |
| 167 | HDD2GHZCHAN(2442, 7, 0) , |
| 168 | HDD2GHZCHAN(2447, 8, 0) , |
| 169 | HDD2GHZCHAN(2452, 9, 0) , |
| 170 | HDD2GHZCHAN(2457, 10, 0) , |
| 171 | HDD2GHZCHAN(2462, 11, 0) , |
| 172 | HDD2GHZCHAN(2467, 12, 0) , |
| 173 | HDD2GHZCHAN(2472, 13, 0) , |
| 174 | HDD2GHZCHAN(2484, 14, 0) , |
| 175 | }; |
| 176 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 177 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 178 | { |
| 179 | HDD2GHZCHAN(2412, 1, 0) , |
| 180 | HDD2GHZCHAN(2437, 6, 0) , |
| 181 | HDD2GHZCHAN(2462, 11, 0) , |
| 182 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 183 | |
| 184 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 185 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 186 | HDD5GHZCHAN(4920, 240, 0) , |
| 187 | HDD5GHZCHAN(4940, 244, 0) , |
| 188 | HDD5GHZCHAN(4960, 248, 0) , |
| 189 | HDD5GHZCHAN(4980, 252, 0) , |
| 190 | HDD5GHZCHAN(5040, 208, 0) , |
| 191 | HDD5GHZCHAN(5060, 212, 0) , |
| 192 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 193 | HDD5GHZCHAN(5180, 36, 0) , |
| 194 | HDD5GHZCHAN(5200, 40, 0) , |
| 195 | HDD5GHZCHAN(5220, 44, 0) , |
| 196 | HDD5GHZCHAN(5240, 48, 0) , |
| 197 | HDD5GHZCHAN(5260, 52, 0) , |
| 198 | HDD5GHZCHAN(5280, 56, 0) , |
| 199 | HDD5GHZCHAN(5300, 60, 0) , |
| 200 | HDD5GHZCHAN(5320, 64, 0) , |
| 201 | HDD5GHZCHAN(5500,100, 0) , |
| 202 | HDD5GHZCHAN(5520,104, 0) , |
| 203 | HDD5GHZCHAN(5540,108, 0) , |
| 204 | HDD5GHZCHAN(5560,112, 0) , |
| 205 | HDD5GHZCHAN(5580,116, 0) , |
| 206 | HDD5GHZCHAN(5600,120, 0) , |
| 207 | HDD5GHZCHAN(5620,124, 0) , |
| 208 | HDD5GHZCHAN(5640,128, 0) , |
| 209 | HDD5GHZCHAN(5660,132, 0) , |
| 210 | HDD5GHZCHAN(5680,136, 0) , |
| 211 | HDD5GHZCHAN(5700,140, 0) , |
| 212 | HDD5GHZCHAN(5745,149, 0) , |
| 213 | HDD5GHZCHAN(5765,153, 0) , |
| 214 | HDD5GHZCHAN(5785,157, 0) , |
| 215 | HDD5GHZCHAN(5805,161, 0) , |
| 216 | HDD5GHZCHAN(5825,165, 0) , |
| 217 | }; |
| 218 | |
| 219 | static struct ieee80211_rate g_mode_rates[] = |
| 220 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 221 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 222 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 223 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 224 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 225 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 226 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 227 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 228 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 229 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 230 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 231 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 232 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 233 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 234 | |
| 235 | static struct ieee80211_rate a_mode_rates[] = |
| 236 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 237 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 238 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 239 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 240 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 241 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 242 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 243 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 244 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 245 | }; |
| 246 | |
| 247 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 248 | { |
| 249 | .channels = hdd_channels_2_4_GHZ, |
| 250 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 251 | .band = IEEE80211_BAND_2GHZ, |
| 252 | .bitrates = g_mode_rates, |
| 253 | .n_bitrates = g_mode_rates_size, |
| 254 | .ht_cap.ht_supported = 1, |
| 255 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 256 | | IEEE80211_HT_CAP_GRN_FLD |
| 257 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 258 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 259 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 260 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 261 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 262 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 263 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 264 | }; |
| 265 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 266 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 267 | { |
| 268 | .channels = hdd_social_channels_2_4_GHZ, |
| 269 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 270 | .band = IEEE80211_BAND_2GHZ, |
| 271 | .bitrates = g_mode_rates, |
| 272 | .n_bitrates = g_mode_rates_size, |
| 273 | .ht_cap.ht_supported = 1, |
| 274 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 275 | | IEEE80211_HT_CAP_GRN_FLD |
| 276 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 277 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 278 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 279 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 280 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 281 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 282 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 283 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 284 | |
| 285 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 286 | { |
| 287 | .channels = hdd_channels_5_GHZ, |
| 288 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 289 | .band = IEEE80211_BAND_5GHZ, |
| 290 | .bitrates = a_mode_rates, |
| 291 | .n_bitrates = a_mode_rates_size, |
| 292 | .ht_cap.ht_supported = 1, |
| 293 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 294 | | IEEE80211_HT_CAP_GRN_FLD |
| 295 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 296 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 297 | | IEEE80211_HT_CAP_SGI_40 |
| 298 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 299 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 300 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 301 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 302 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 303 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 304 | }; |
| 305 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 306 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 307 | TX/RX direction for each kind of interface */ |
| 308 | static const struct ieee80211_txrx_stypes |
| 309 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 310 | [NL80211_IFTYPE_STATION] = { |
| 311 | .tx = 0xffff, |
| 312 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 313 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 314 | }, |
| 315 | [NL80211_IFTYPE_AP] = { |
| 316 | .tx = 0xffff, |
| 317 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 318 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 319 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 320 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 321 | BIT(SIR_MAC_MGMT_AUTH) | |
| 322 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 323 | BIT(SIR_MAC_MGMT_ACTION), |
| 324 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 325 | [NL80211_IFTYPE_ADHOC] = { |
| 326 | .tx = 0xffff, |
| 327 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 328 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 329 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 330 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 331 | BIT(SIR_MAC_MGMT_AUTH) | |
| 332 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 333 | BIT(SIR_MAC_MGMT_ACTION), |
| 334 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 335 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 336 | .tx = 0xffff, |
| 337 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 338 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 339 | }, |
| 340 | [NL80211_IFTYPE_P2P_GO] = { |
| 341 | /* This is also same as for SoftAP */ |
| 342 | .tx = 0xffff, |
| 343 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 344 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 345 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 346 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 347 | BIT(SIR_MAC_MGMT_AUTH) | |
| 348 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 349 | BIT(SIR_MAC_MGMT_ACTION), |
| 350 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 351 | }; |
| 352 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 353 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 354 | static const struct ieee80211_iface_limit |
| 355 | wlan_hdd_iface_limit[] = { |
| 356 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 357 | /* max = 3 ; Our driver create two interfaces during driver init |
| 358 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 359 | * interface until a group is formed. In JB architecture, once the |
| 360 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 361 | * Client. |
| 362 | * When supplicant remove the group, it first issue a set interface |
| 363 | * cmd to change the mode back to Station. In JB this works fine as |
| 364 | * we advertize two station type interface during driver init. |
| 365 | * Some vendors create separate interface for P2P GO/Client, |
| 366 | * after group formation(Third one). But while group remove |
| 367 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 368 | * But as we advertized only two sta type interfaces nl80211 was |
| 369 | * returning error for the third one which was leading to failure in |
| 370 | * delete interface. Ideally while removing the group, supplicant |
| 371 | * should not try to change the 3rd interface mode to Station type. |
| 372 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 373 | * interface type to 3 |
| 374 | */ |
| 375 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 376 | .types = BIT(NL80211_IFTYPE_STATION), |
| 377 | }, |
| 378 | { |
| 379 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 380 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 381 | }, |
| 382 | { |
| 383 | .max = 1, |
| 384 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 385 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 386 | }, |
| 387 | }; |
| 388 | |
| 389 | /* By default, only single channel concurrency is allowed */ |
| 390 | static struct ieee80211_iface_combination |
| 391 | wlan_hdd_iface_combination = { |
| 392 | .limits = wlan_hdd_iface_limit, |
| 393 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 394 | /* |
| 395 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 396 | * and p2p0 interfaces during driver init |
| 397 | * Some vendors create separate interface for P2P operations. |
| 398 | * wlan0: STA interface |
| 399 | * p2p0: P2P Device interface, action frames goes |
| 400 | * through this interface. |
| 401 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 402 | * created for p2p operations(GO/CLIENT interface). |
| 403 | */ |
| 404 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 405 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 406 | .beacon_int_infra_match = false, |
| 407 | }; |
| 408 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 409 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 410 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 411 | |
| 412 | /* Data rate 100KBPS based on IE Index */ |
| 413 | struct index_data_rate_type |
| 414 | { |
| 415 | v_U8_t beacon_rate_index; |
| 416 | v_U16_t supported_rate[4]; |
| 417 | }; |
| 418 | |
| 419 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 420 | The IDX field is the rate index |
| 421 | The HI field is the rate when RSSI is strong or being ignored |
| 422 | (in this case we report actual rate) |
| 423 | The MID field is the rate when RSSI is moderate |
| 424 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 425 | The LO field is the rate when RSSI is low |
| 426 | (in this case we don't report rates, actual current rate used) |
| 427 | */ |
| 428 | static const struct |
| 429 | { |
| 430 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 431 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 432 | } supported_data_rate[] = |
| 433 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 434 | /* IDX HI HM LM LO (RSSI-based index */ |
| 435 | {2, { 10, 10, 10, 0}}, |
| 436 | {4, { 20, 20, 10, 0}}, |
| 437 | {11, { 55, 20, 10, 0}}, |
| 438 | {12, { 60, 55, 20, 0}}, |
| 439 | {18, { 90, 55, 20, 0}}, |
| 440 | {22, {110, 55, 20, 0}}, |
| 441 | {24, {120, 90, 60, 0}}, |
| 442 | {36, {180, 120, 60, 0}}, |
| 443 | {44, {220, 180, 60, 0}}, |
| 444 | {48, {240, 180, 90, 0}}, |
| 445 | {66, {330, 180, 90, 0}}, |
| 446 | {72, {360, 240, 90, 0}}, |
| 447 | {96, {480, 240, 120, 0}}, |
| 448 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 449 | }; |
| 450 | |
| 451 | /* MCS Based rate table */ |
| 452 | static struct index_data_rate_type supported_mcs_rate[] = |
| 453 | { |
| 454 | /* MCS L20 L40 S20 S40 */ |
| 455 | {0, {65, 135, 72, 150}}, |
| 456 | {1, {130, 270, 144, 300}}, |
| 457 | {2, {195, 405, 217, 450}}, |
| 458 | {3, {260, 540, 289, 600}}, |
| 459 | {4, {390, 810, 433, 900}}, |
| 460 | {5, {520, 1080, 578, 1200}}, |
| 461 | {6, {585, 1215, 650, 1350}}, |
| 462 | {7, {650, 1350, 722, 1500}} |
| 463 | }; |
| 464 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 465 | #ifdef WLAN_FEATURE_11AC |
| 466 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 467 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 468 | |
| 469 | struct index_vht_data_rate_type |
| 470 | { |
| 471 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 472 | v_U16_t supported_VHT80_rate[2]; |
| 473 | v_U16_t supported_VHT40_rate[2]; |
| 474 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 475 | }; |
| 476 | |
| 477 | typedef enum |
| 478 | { |
| 479 | DATA_RATE_11AC_MAX_MCS_7, |
| 480 | DATA_RATE_11AC_MAX_MCS_8, |
| 481 | DATA_RATE_11AC_MAX_MCS_9, |
| 482 | DATA_RATE_11AC_MAX_MCS_NA |
| 483 | } eDataRate11ACMaxMcs; |
| 484 | |
| 485 | /* MCS Based VHT rate table */ |
| 486 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 487 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 488 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 489 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 490 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 491 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 492 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 493 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 494 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 495 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 496 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 497 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 498 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 499 | }; |
| 500 | #endif /* WLAN_FEATURE_11AC */ |
| 501 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 502 | extern struct net_device_ops net_ops_struct; |
| 503 | |
| 504 | /* |
| 505 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 506 | * This function is called by hdd_wlan_startup() |
| 507 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 508 | * This function is used to initialize and register wiphy structure. |
| 509 | */ |
| 510 | struct wiphy *wlan_hdd_cfg80211_init(int priv_size) |
| 511 | { |
| 512 | struct wiphy *wiphy; |
| 513 | ENTER(); |
| 514 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 515 | /* |
| 516 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 517 | */ |
| 518 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 519 | |
| 520 | if (!wiphy) |
| 521 | { |
| 522 | /* Print error and jump into err label and free the memory */ |
| 523 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 524 | return NULL; |
| 525 | } |
| 526 | |
| 527 | return wiphy; |
| 528 | } |
| 529 | |
| 530 | /* |
| 531 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 532 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 533 | * private ioctl to change the band value |
| 534 | */ |
| 535 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 536 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 537 | int i, j; |
| 538 | eNVChannelEnabledType channelEnabledState; |
| 539 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 540 | ENTER(); |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 541 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 542 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 543 | |
| 544 | if (NULL == wiphy->bands[i]) |
| 545 | { |
| 546 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 547 | __func__, i); |
| 548 | continue; |
| 549 | } |
| 550 | |
| 551 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 552 | { |
| 553 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 554 | |
| 555 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 556 | band->channels[j].hw_value); |
| 557 | |
| 558 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 559 | { |
| 560 | // Enable Social channels for P2P |
| 561 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 562 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 563 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 564 | else |
| 565 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 566 | continue; |
| 567 | } |
| 568 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 569 | { |
| 570 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 571 | continue; |
| 572 | } |
| 573 | |
| 574 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 575 | NV_CHANNEL_INVALID == channelEnabledState) |
| 576 | { |
| 577 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 578 | } |
| 579 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 580 | { |
| 581 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 582 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 583 | } |
| 584 | else |
| 585 | { |
| 586 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 587 | |IEEE80211_CHAN_RADAR); |
| 588 | } |
| 589 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 590 | } |
| 591 | return 0; |
| 592 | } |
| 593 | /* |
| 594 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 595 | * This function is called by hdd_wlan_startup() |
| 596 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 597 | * This function is used to initialize and register wiphy structure. |
| 598 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 599 | int wlan_hdd_cfg80211_register(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 600 | struct wiphy *wiphy, |
| 601 | hdd_config_t *pCfg |
| 602 | ) |
| 603 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 604 | |
| 605 | int i, j; |
| 606 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 607 | ENTER(); |
| 608 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 609 | /* Now bind the underlying wlan device with wiphy */ |
| 610 | set_wiphy_dev(wiphy, dev); |
| 611 | |
| 612 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
| 613 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 614 | wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 615 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 616 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 617 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 618 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 619 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 620 | | WIPHY_FLAG_OFFCHAN_TX; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 621 | #endif |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 622 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 623 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 624 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 625 | || pCfg->isFastRoamIniFeatureEnabled |
| 626 | #endif |
| 627 | #ifdef FEATURE_WLAN_CCX |
| 628 | || pCfg->isCcxIniFeatureEnabled |
| 629 | #endif |
| 630 | ) |
| 631 | { |
| 632 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 633 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 634 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 635 | #ifdef FEATURE_WLAN_TDLS |
| 636 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 637 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 638 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 639 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 640 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 641 | wiphy->max_sched_scan_ssids = MAX_SCAN_SSID; |
| 642 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 643 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 644 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 645 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 646 | driver can still register regulatory callback and |
| 647 | it will get CRDA setting in wiphy->band[], but |
| 648 | driver need to determine what to do with both |
| 649 | regulatory settings */ |
| 650 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 651 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 652 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 653 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 654 | wiphy->max_scan_ie_len = 200 ; //TODO: define a macro |
| 655 | |
| 656 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 657 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 658 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 659 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 660 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 661 | | BIT(NL80211_IFTYPE_AP); |
| 662 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 663 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 664 | if( pCfg->enableMCC ) |
| 665 | { |
| 666 | /* Currently, supports up to two channels */ |
| 667 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 668 | |
| 669 | if( !pCfg->allowMCCGODiffBI ) |
| 670 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 671 | |
| 672 | } |
| 673 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 674 | wiphy->n_iface_combinations = 1; |
| 675 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 676 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 677 | /* Before registering we need to update the ht capabilitied based |
| 678 | * on ini values*/ |
| 679 | if( !pCfg->ShortGI20MhzEnable ) |
| 680 | { |
| 681 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 682 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 683 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 684 | } |
| 685 | |
| 686 | if( !pCfg->ShortGI40MhzEnable ) |
| 687 | { |
| 688 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 689 | } |
| 690 | |
| 691 | if( !pCfg->nChannelBondingMode5GHz ) |
| 692 | { |
| 693 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 694 | } |
| 695 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 696 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 697 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 698 | |
| 699 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 700 | { |
| 701 | |
| 702 | if (NULL == wiphy->bands[i]) |
| 703 | { |
| 704 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 705 | __func__, i); |
| 706 | continue; |
| 707 | } |
| 708 | |
| 709 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 710 | { |
| 711 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 712 | |
| 713 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 714 | { |
| 715 | // Enable social channels for P2P |
| 716 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 717 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 718 | else |
| 719 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 720 | continue; |
| 721 | } |
| 722 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 723 | { |
| 724 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 725 | continue; |
| 726 | } |
| 727 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 728 | } |
| 729 | /*Initialise the supported cipher suite details*/ |
| 730 | wiphy->cipher_suites = hdd_cipher_suites; |
| 731 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 732 | |
| 733 | /*signal strength in mBm (100*dBm) */ |
| 734 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 735 | |
| 736 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 737 | wiphy->max_remain_on_channel_duration = 1000; |
| 738 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 739 | |
| 740 | /* Register our wiphy dev with cfg80211 */ |
| 741 | if (0 > wiphy_register(wiphy)) |
| 742 | { |
| 743 | /* print eror */ |
| 744 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 745 | return -EIO; |
| 746 | } |
| 747 | |
| 748 | EXIT(); |
| 749 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 750 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 751 | |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 752 | /* In this function we will try to get default country code from crda. |
| 753 | If the gCrdaDefaultCountryCode is configured in ini file, |
| 754 | we will try to call user space crda to get the regulatory settings for |
| 755 | that country. We will timeout if we can't get it from crda. |
| 756 | It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_register. |
| 757 | */ |
| 758 | int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg) |
| 759 | { |
| 760 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 761 | if (memcmp(pCfg->crdaDefaultCountryCode, |
| 762 | CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0) |
| 763 | { |
| 764 | init_completion(&pHddCtx->driver_crda_req); |
| 765 | regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode); |
| 766 | wait_for_completion_interruptible_timeout(&pHddCtx->driver_crda_req, |
| 767 | CRDA_WAIT_TIME); |
Yunsen Wang | e3ba1fb | 2013-04-05 15:04:43 -0700 | [diff] [blame] | 768 | /* if the country is not found from current regulatory.bin, |
| 769 | fall back to world domain */ |
| 770 | if (is_crda_regulatory_entry_valid() == VOS_FALSE) |
| 771 | crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1); |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 772 | } |
| 773 | return 0; |
| 774 | } |
| 775 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 776 | /* In this function we will do all post VOS start initialization. |
| 777 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 778 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 779 | */ |
| 780 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 781 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 782 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 783 | /* Register for all P2P action, public action etc frames */ |
| 784 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 785 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 786 | ENTER(); |
| 787 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 788 | /* Right now we are registering these frame when driver is getting |
| 789 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 790 | frame register ops, we will move this code as a part of that */ |
| 791 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 792 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 793 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 794 | |
| 795 | /* GAS Initial Response */ |
| 796 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 797 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 798 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 799 | /* GAS Comeback Request */ |
| 800 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 801 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 802 | |
| 803 | /* GAS Comeback Response */ |
| 804 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 805 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 806 | |
| 807 | /* P2P Public Action */ |
| 808 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 809 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 810 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 811 | |
| 812 | /* P2P Action */ |
| 813 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 814 | (v_U8_t*)P2P_ACTION_FRAME, |
| 815 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 816 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 817 | /* WNM BSS Transition Request frame */ |
| 818 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 819 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 820 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 821 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 822 | #ifdef WLAN_FEATURE_11W |
| 823 | /* SA Query Response Action Frame */ |
| 824 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 825 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 826 | SA_QUERY_FRAME_RSP_SIZE ); |
| 827 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 831 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 832 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 833 | /* Register for all P2P action, public action etc frames */ |
| 834 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 835 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 836 | ENTER(); |
| 837 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 838 | /* Right now we are registering these frame when driver is getting |
| 839 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 840 | frame register ops, we will move this code as a part of that */ |
| 841 | /* GAS Initial Request */ |
| 842 | |
| 843 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 844 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 845 | |
| 846 | /* GAS Initial Response */ |
| 847 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 848 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 849 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 850 | /* GAS Comeback Request */ |
| 851 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 852 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 853 | |
| 854 | /* GAS Comeback Response */ |
| 855 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 856 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 857 | |
| 858 | /* P2P Public Action */ |
| 859 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 860 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 861 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 862 | |
| 863 | /* P2P Action */ |
| 864 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 865 | (v_U8_t*)P2P_ACTION_FRAME, |
| 866 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 867 | |
| 868 | #ifdef WLAN_FEATURE_11W |
| 869 | /* SA Query Response Action Frame */ |
| 870 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 871 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 872 | SA_QUERY_FRAME_RSP_SIZE ); |
| 873 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | #ifdef FEATURE_WLAN_WAPI |
| 877 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 878 | const u8 *mac_addr, u8 *key , int key_Len) |
| 879 | { |
| 880 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 881 | tCsrRoamSetKey setKey; |
| 882 | v_BOOL_t isConnected = TRUE; |
| 883 | int status = 0; |
| 884 | v_U32_t roamId= 0xFF; |
| 885 | tANI_U8 *pKeyPtr = NULL; |
| 886 | int n = 0; |
| 887 | |
| 888 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 889 | __func__,pAdapter->device_mode); |
| 890 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 891 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 892 | setKey.keyId = key_index; // Store Key ID |
| 893 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 894 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 895 | setKey.paeRole = 0 ; // the PAE role |
| 896 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 897 | { |
| 898 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 899 | } |
| 900 | else |
| 901 | { |
| 902 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 903 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 904 | } |
| 905 | setKey.keyLength = key_Len; |
| 906 | pKeyPtr = setKey.Key; |
| 907 | memcpy( pKeyPtr, key, key_Len); |
| 908 | |
| 909 | hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x", |
| 910 | __func__, key_Len); |
| 911 | for (n = 0 ; n < key_Len; n++) |
| 912 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 913 | __func__,n,setKey.Key[n]); |
| 914 | |
| 915 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 916 | if ( isConnected ) |
| 917 | { |
| 918 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 919 | pAdapter->sessionId, &setKey, &roamId ); |
| 920 | } |
| 921 | if ( status != 0 ) |
| 922 | { |
| 923 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 924 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 925 | __LINE__, status ); |
| 926 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 927 | } |
| 928 | } |
| 929 | #endif /* FEATURE_WLAN_WAPI*/ |
| 930 | |
| 931 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 932 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 933 | beacon_data_t **ppBeacon, |
| 934 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 935 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 936 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 937 | beacon_data_t **ppBeacon, |
| 938 | struct cfg80211_beacon_data *params, |
| 939 | int dtim_period) |
| 940 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 941 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 942 | int size; |
| 943 | beacon_data_t *beacon = NULL; |
| 944 | beacon_data_t *old = NULL; |
| 945 | int head_len,tail_len; |
| 946 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 947 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 948 | if (params->head && !params->head_len) |
| 949 | return -EINVAL; |
| 950 | |
| 951 | old = pAdapter->sessionCtx.ap.beacon; |
| 952 | |
| 953 | if (!params->head && !old) |
| 954 | return -EINVAL; |
| 955 | |
| 956 | if (params->tail && !params->tail_len) |
| 957 | return -EINVAL; |
| 958 | |
| 959 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 960 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 961 | if (!params->dtim_period) |
| 962 | return -EINVAL; |
| 963 | #endif |
| 964 | |
| 965 | if(params->head) |
| 966 | head_len = params->head_len; |
| 967 | else |
| 968 | head_len = old->head_len; |
| 969 | |
| 970 | if(params->tail || !old) |
| 971 | tail_len = params->tail_len; |
| 972 | else |
| 973 | tail_len = old->tail_len; |
| 974 | |
| 975 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 976 | |
| 977 | beacon = kzalloc(size, GFP_KERNEL); |
| 978 | |
| 979 | if( beacon == NULL ) |
| 980 | return -ENOMEM; |
| 981 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 982 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 983 | if(params->dtim_period || !old ) |
| 984 | beacon->dtim_period = params->dtim_period; |
| 985 | else |
| 986 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 987 | #else |
| 988 | if(dtim_period || !old ) |
| 989 | beacon->dtim_period = dtim_period; |
| 990 | else |
| 991 | beacon->dtim_period = old->dtim_period; |
| 992 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 993 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 994 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 995 | beacon->tail = beacon->head + head_len; |
| 996 | beacon->head_len = head_len; |
| 997 | beacon->tail_len = tail_len; |
| 998 | |
| 999 | if(params->head) { |
| 1000 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1001 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1002 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1003 | if(old) |
| 1004 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1005 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1006 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1007 | if(params->tail) { |
| 1008 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1009 | } |
| 1010 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1011 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1012 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1013 | } |
| 1014 | |
| 1015 | *ppBeacon = beacon; |
| 1016 | |
| 1017 | kfree(old); |
| 1018 | |
| 1019 | return 0; |
| 1020 | |
| 1021 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1022 | |
| 1023 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1024 | { |
| 1025 | int left = length; |
| 1026 | v_U8_t *ptr = pIes; |
| 1027 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1028 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1029 | while(left >= 2) |
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 | elem_id = ptr[0]; |
| 1032 | elem_len = ptr[1]; |
| 1033 | left -= 2; |
| 1034 | if(elem_len > left) |
| 1035 | { |
| 1036 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1037 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1038 | eid,elem_len,left); |
| 1039 | return NULL; |
| 1040 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1041 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1042 | { |
| 1043 | return ptr; |
| 1044 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1045 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1046 | left -= elem_len; |
| 1047 | ptr += (elem_len + 2); |
| 1048 | } |
| 1049 | return NULL; |
| 1050 | } |
| 1051 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1052 | /* Check if rate is 11g rate or not */ |
| 1053 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1054 | { |
| 1055 | u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 104}; /* actual rate * 2 */ |
| 1056 | u8 i; |
| 1057 | for (i = 0; i < 8; i++) |
| 1058 | { |
| 1059 | if(rate == gRateArray[i]) |
| 1060 | return TRUE; |
| 1061 | } |
| 1062 | return FALSE; |
| 1063 | } |
| 1064 | |
| 1065 | /* Check for 11g rate and set proper 11g only mode */ |
| 1066 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1067 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1068 | { |
| 1069 | u8 i, num_rates = pIe[0]; |
| 1070 | |
| 1071 | pIe += 1; |
| 1072 | for ( i = 0; i < num_rates; i++) |
| 1073 | { |
| 1074 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1075 | { |
| 1076 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1077 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1078 | if (pIe[i] & BASIC_RATE_MASK) |
| 1079 | { |
| 1080 | /* If we have 11g rate as basic rate, it means mode |
| 1081 | is 11g only mode. |
| 1082 | */ |
| 1083 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1084 | *pCheckRatesfor11g = FALSE; |
| 1085 | } |
| 1086 | } |
| 1087 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1088 | { |
| 1089 | *require_ht = TRUE; |
| 1090 | } |
| 1091 | } |
| 1092 | return; |
| 1093 | } |
| 1094 | |
| 1095 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1096 | { |
| 1097 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1098 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1099 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1100 | u8 checkRatesfor11g = TRUE; |
| 1101 | u8 require_ht = FALSE; |
| 1102 | u8 *pIe=NULL; |
| 1103 | |
| 1104 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1105 | |
| 1106 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1107 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1108 | if (pIe != NULL) |
| 1109 | { |
| 1110 | pIe += 1; |
| 1111 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1112 | &pConfig->SapHw_mode); |
| 1113 | } |
| 1114 | |
| 1115 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1116 | WLAN_EID_EXT_SUPP_RATES); |
| 1117 | if (pIe != NULL) |
| 1118 | { |
| 1119 | |
| 1120 | pIe += 1; |
| 1121 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1122 | &pConfig->SapHw_mode); |
| 1123 | } |
| 1124 | |
| 1125 | if( pConfig->channel > 14 ) |
| 1126 | { |
| 1127 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1128 | } |
| 1129 | |
| 1130 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1131 | WLAN_EID_HT_CAPABILITY); |
| 1132 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1133 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1134 | { |
| 1135 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1136 | if(require_ht) |
| 1137 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1138 | } |
| 1139 | } |
| 1140 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1141 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1142 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1143 | { |
| 1144 | v_U8_t ielen = 0; |
| 1145 | v_U8_t *pIe = NULL; |
| 1146 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1147 | |
| 1148 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1149 | pBeacon->tail, pBeacon->tail_len); |
| 1150 | |
| 1151 | if (pIe) |
| 1152 | { |
| 1153 | ielen = pIe[1] + 2; |
| 1154 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1155 | { |
| 1156 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1157 | } |
| 1158 | else |
| 1159 | { |
| 1160 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1161 | return -EINVAL; |
| 1162 | } |
| 1163 | *total_ielen += ielen; |
| 1164 | } |
| 1165 | return 0; |
| 1166 | } |
| 1167 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1168 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1169 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1170 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1171 | #else |
| 1172 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1173 | struct cfg80211_beacon_data *params) |
| 1174 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1175 | { |
| 1176 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1177 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1178 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1179 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1180 | |
| 1181 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1182 | |
| 1183 | if(genie == NULL) { |
| 1184 | |
| 1185 | return -ENOMEM; |
| 1186 | } |
| 1187 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1188 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1189 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1190 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1191 | ret = -EINVAL; |
| 1192 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1196 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1197 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1198 | { |
| 1199 | ret = -EINVAL; |
| 1200 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1201 | } |
| 1202 | #endif |
| 1203 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1204 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1205 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1206 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1207 | ret = -EINVAL; |
| 1208 | goto done; |
| 1209 | } |
| 1210 | |
| 1211 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1212 | { |
| 1213 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1214 | &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1215 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1216 | ret = -EINVAL; |
| 1217 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1218 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1219 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1220 | |
| 1221 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1222 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1223 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1224 | { |
| 1225 | hddLog(LOGE, |
| 1226 | "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] | 1227 | ret = -EINVAL; |
| 1228 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1229 | } |
| 1230 | |
| 1231 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1232 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1233 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1234 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1235 | ==eHAL_STATUS_FAILURE) |
| 1236 | { |
| 1237 | hddLog(LOGE, |
| 1238 | "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] | 1239 | ret = -EINVAL; |
| 1240 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | // Added for ProResp IE |
| 1244 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1245 | { |
| 1246 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1247 | u8 probe_rsp_ie_len[3] = {0}; |
| 1248 | u8 counter = 0; |
| 1249 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1250 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1251 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1252 | Store More then 255 bytes into One Variable. |
| 1253 | */ |
| 1254 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1255 | { |
| 1256 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1257 | { |
| 1258 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1259 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1260 | } |
| 1261 | else |
| 1262 | { |
| 1263 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1264 | rem_probe_resp_ie_len = 0; |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | rem_probe_resp_ie_len = 0; |
| 1269 | |
| 1270 | if (probe_rsp_ie_len[0] > 0) |
| 1271 | { |
| 1272 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1273 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1274 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1275 | probe_rsp_ie_len[0], NULL, |
| 1276 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1277 | { |
| 1278 | hddLog(LOGE, |
| 1279 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1280 | ret = -EINVAL; |
| 1281 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1282 | } |
| 1283 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1284 | } |
| 1285 | |
| 1286 | if (probe_rsp_ie_len[1] > 0) |
| 1287 | { |
| 1288 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1289 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1290 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1291 | probe_rsp_ie_len[1], NULL, |
| 1292 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1293 | { |
| 1294 | hddLog(LOGE, |
| 1295 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1296 | ret = -EINVAL; |
| 1297 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1298 | } |
| 1299 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1300 | } |
| 1301 | |
| 1302 | if (probe_rsp_ie_len[2] > 0) |
| 1303 | { |
| 1304 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1305 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1306 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1307 | probe_rsp_ie_len[2], NULL, |
| 1308 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1309 | { |
| 1310 | hddLog(LOGE, |
| 1311 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1312 | ret = -EINVAL; |
| 1313 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1314 | } |
| 1315 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1316 | } |
| 1317 | |
| 1318 | if (probe_rsp_ie_len[1] == 0 ) |
| 1319 | { |
| 1320 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1321 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1322 | eANI_BOOLEAN_FALSE) ) |
| 1323 | { |
| 1324 | hddLog(LOGE, |
| 1325 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n"); |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | if (probe_rsp_ie_len[2] == 0 ) |
| 1330 | { |
| 1331 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1332 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1333 | eANI_BOOLEAN_FALSE) ) |
| 1334 | { |
| 1335 | hddLog(LOGE, |
| 1336 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n"); |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1341 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1342 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1343 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1344 | == eHAL_STATUS_FAILURE) |
| 1345 | { |
| 1346 | hddLog(LOGE, |
| 1347 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1348 | ret = -EINVAL; |
| 1349 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1350 | } |
| 1351 | } |
| 1352 | else |
| 1353 | { |
| 1354 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1355 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1356 | |
| 1357 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1358 | "%s: No Probe Response IE received in set beacon", |
| 1359 | __func__); |
| 1360 | } |
| 1361 | |
| 1362 | // Added for AssocResp IE |
| 1363 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1364 | { |
| 1365 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1366 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1367 | params->assocresp_ies_len, NULL, |
| 1368 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1369 | { |
| 1370 | hddLog(LOGE, |
| 1371 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1372 | ret = -EINVAL; |
| 1373 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1377 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1378 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1379 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1380 | == eHAL_STATUS_FAILURE) |
| 1381 | { |
| 1382 | hddLog(LOGE, |
| 1383 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1384 | ret = -EINVAL; |
| 1385 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1386 | } |
| 1387 | } |
| 1388 | else |
| 1389 | { |
| 1390 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1391 | "%s: No Assoc Response IE received in set beacon", |
| 1392 | __func__); |
| 1393 | |
| 1394 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1395 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1396 | eANI_BOOLEAN_FALSE) ) |
| 1397 | { |
| 1398 | hddLog(LOGE, |
| 1399 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 1400 | } |
| 1401 | } |
| 1402 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1403 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1404 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1405 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1406 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1408 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1409 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1410 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1411 | * wlan_hdd_cfg80211_set_channel() |
| 1412 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1413 | * channel list. |
| 1414 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1415 | static VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel) |
| 1416 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1417 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1418 | v_U32_t num_ch = 0; |
| 1419 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1420 | u32 indx = 0; |
| 1421 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1422 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1423 | 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] | 1424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1425 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1426 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1427 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1428 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1429 | /* Validate the channel */ |
| 1430 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1431 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1432 | if ( channel == rfChannels[count].channelNum ) |
| 1433 | { |
| 1434 | fValidChannel = TRUE; |
| 1435 | break; |
| 1436 | } |
| 1437 | } |
| 1438 | if (fValidChannel != TRUE) |
| 1439 | { |
| 1440 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1441 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1442 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1443 | } |
| 1444 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1445 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1446 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1447 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1448 | valid_ch, &num_ch)) |
| 1449 | { |
| 1450 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1451 | "%s: failed to get valid channel list", __func__); |
| 1452 | return VOS_STATUS_E_FAILURE; |
| 1453 | } |
| 1454 | for (indx = 0; indx < num_ch; indx++) |
| 1455 | { |
| 1456 | if (channel == valid_ch[indx]) |
| 1457 | { |
| 1458 | break; |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | if (indx >= num_ch) |
| 1463 | { |
| 1464 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1465 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1466 | return VOS_STATUS_E_FAILURE; |
| 1467 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1468 | } |
| 1469 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1470 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1471 | } |
| 1472 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1473 | /** |
| 1474 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1475 | * This function is used to set the channel number |
| 1476 | */ |
| 1477 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1478 | struct ieee80211_channel *chan, |
| 1479 | enum nl80211_channel_type channel_type |
| 1480 | ) |
| 1481 | { |
| 1482 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1483 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1484 | hdd_adapter_t *pAdapter = NULL; |
| 1485 | int freq = chan->center_freq; /* freq is in MHZ */ |
| 1486 | |
| 1487 | ENTER(); |
| 1488 | |
| 1489 | if( NULL == dev ) |
| 1490 | { |
| 1491 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1492 | "%s: Called with dev = NULL.\n", __func__); |
| 1493 | return -ENODEV; |
| 1494 | } |
| 1495 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1496 | |
| 1497 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1498 | "%s: device_mode = %d freq = %d \n",__func__, |
| 1499 | pAdapter->device_mode, chan->center_freq); |
| 1500 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 1501 | { |
| 1502 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1503 | return -EAGAIN; |
| 1504 | } |
| 1505 | |
| 1506 | /* |
| 1507 | * Do freq to chan conversion |
| 1508 | * TODO: for 11a |
| 1509 | */ |
| 1510 | |
| 1511 | channel = ieee80211_frequency_to_channel(freq); |
| 1512 | |
| 1513 | /* Check freq range */ |
| 1514 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1515 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1516 | { |
| 1517 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1518 | "%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1519 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1520 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1521 | return -EINVAL; |
| 1522 | } |
| 1523 | |
| 1524 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1525 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1526 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1527 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1528 | { |
| 1529 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1530 | { |
| 1531 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1532 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1533 | return -EINVAL; |
| 1534 | } |
| 1535 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1536 | "%s: set channel to [%d] for device mode =%d", |
| 1537 | __func__, channel,pAdapter->device_mode); |
| 1538 | } |
| 1539 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1540 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1541 | ) |
| 1542 | { |
| 1543 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1544 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1545 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1546 | |
| 1547 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1548 | { |
| 1549 | /* Link is up then return cant set channel*/ |
| 1550 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1551 | "%s: IBSS Associated, can't set the channel\n", __func__); |
| 1552 | return -EINVAL; |
| 1553 | } |
| 1554 | |
| 1555 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1556 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1557 | pRoamProfile->ChannelInfo.ChannelList = |
| 1558 | &pHddStaCtx->conn_info.operationChannel; |
| 1559 | } |
| 1560 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1561 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1562 | ) |
| 1563 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1564 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1565 | { |
| 1566 | if(VOS_STATUS_SUCCESS != |
| 1567 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1568 | { |
| 1569 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1570 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1571 | return -EINVAL; |
| 1572 | } |
| 1573 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1574 | } |
| 1575 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1576 | { |
| 1577 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1578 | |
| 1579 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1580 | channel set by supplicant |
| 1581 | */ |
| 1582 | if ( cfg_param->apAutoChannelSelection ) |
| 1583 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1584 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1585 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1586 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1587 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1588 | __func__, pAdapter->device_mode); |
| 1589 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1590 | else |
| 1591 | { |
| 1592 | if(VOS_STATUS_SUCCESS != |
| 1593 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1594 | { |
| 1595 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1596 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1597 | return -EINVAL; |
| 1598 | } |
| 1599 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1600 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1601 | } |
| 1602 | } |
| 1603 | else |
| 1604 | { |
| 1605 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1606 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1607 | return -EINVAL; |
| 1608 | } |
| 1609 | EXIT(); |
| 1610 | return 0; |
| 1611 | } |
| 1612 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1613 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1614 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1615 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1616 | #else |
| 1617 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1618 | struct cfg80211_beacon_data *params, |
| 1619 | const u8 *ssid, size_t ssid_len, |
| 1620 | enum nl80211_hidden_ssid hidden_ssid) |
| 1621 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1622 | { |
| 1623 | tsap_Config_t *pConfig; |
| 1624 | beacon_data_t *pBeacon = NULL; |
| 1625 | struct ieee80211_mgmt *pMgmt_frame; |
| 1626 | v_U8_t *pIe=NULL; |
| 1627 | v_U16_t capab_info; |
| 1628 | eCsrAuthType RSNAuthType; |
| 1629 | eCsrEncryptionType RSNEncryptType; |
| 1630 | eCsrEncryptionType mcRSNEncryptType; |
| 1631 | int status = VOS_STATUS_SUCCESS; |
| 1632 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1633 | hdd_hostapd_state_t *pHostapdState; |
| 1634 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1635 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1636 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1637 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1638 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1639 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1640 | |
| 1641 | ENTER(); |
| 1642 | |
| 1643 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1644 | |
| 1645 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1646 | |
| 1647 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1648 | |
| 1649 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1650 | |
| 1651 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1652 | |
| 1653 | //channel is already set in the set_channel Call back |
| 1654 | //pConfig->channel = pCommitConfig->channel; |
| 1655 | |
| 1656 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1657 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1658 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1659 | |
| 1660 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1661 | |
| 1662 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1663 | pConfig->dtim_period); |
| 1664 | |
| 1665 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1666 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1667 | { |
| 1668 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1669 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1670 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1671 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1672 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1673 | pConfig->ieee80211d = 1; |
| 1674 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1675 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1676 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1677 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1678 | else |
| 1679 | { |
| 1680 | pConfig->ieee80211d = 0; |
| 1681 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1682 | /* |
| 1683 | * If auto channel is configured i.e. channel is 0, |
| 1684 | * so skip channel validation. |
| 1685 | */ |
| 1686 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1687 | { |
| 1688 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1689 | { |
| 1690 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1691 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1692 | return -EINVAL; |
| 1693 | } |
| 1694 | } |
| 1695 | else |
| 1696 | { |
| 1697 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1698 | { |
| 1699 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1700 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1701 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1702 | } |
| 1703 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1704 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1705 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1706 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1707 | { |
| 1708 | pConfig->ieee80211d = 0; |
| 1709 | } |
| 1710 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1711 | |
| 1712 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1713 | |
| 1714 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1715 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1716 | |
| 1717 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1718 | |
| 1719 | /*Set wps station to configured*/ |
| 1720 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1721 | |
| 1722 | if(pIe) |
| 1723 | { |
| 1724 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1725 | { |
| 1726 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1727 | return -EINVAL; |
| 1728 | } |
| 1729 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1730 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1731 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1732 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1733 | * WPS state |
| 1734 | */ |
| 1735 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1736 | { |
| 1737 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1738 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1739 | { |
| 1740 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1741 | } |
| 1742 | } |
| 1743 | } |
| 1744 | else |
| 1745 | { |
| 1746 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1747 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1748 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1749 | |
| 1750 | pConfig->RSNWPAReqIELength = 0; |
| 1751 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1752 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1753 | WLAN_EID_RSN); |
| 1754 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1755 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1756 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1757 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1758 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1759 | /* The actual processing may eventually be more extensive than |
| 1760 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1761 | * by the app. |
| 1762 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1763 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1764 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1765 | &RSNEncryptType, |
| 1766 | &mcRSNEncryptType, |
| 1767 | &RSNAuthType, |
| 1768 | pConfig->pRSNWPAReqIE[1]+2, |
| 1769 | pConfig->pRSNWPAReqIE ); |
| 1770 | |
| 1771 | if( VOS_STATUS_SUCCESS == status ) |
| 1772 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1773 | /* Now copy over all the security attributes you have |
| 1774 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1775 | * */ |
| 1776 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1777 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1778 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1779 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1780 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1781 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1782 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1783 | } |
| 1784 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1785 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1786 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1787 | pBeacon->tail, pBeacon->tail_len); |
| 1788 | |
| 1789 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1790 | { |
| 1791 | if (pConfig->pRSNWPAReqIE) |
| 1792 | { |
| 1793 | /*Mixed mode WPA/WPA2*/ |
| 1794 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1795 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1796 | } |
| 1797 | else |
| 1798 | { |
| 1799 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1800 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1801 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1802 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1803 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1804 | &RSNEncryptType, |
| 1805 | &mcRSNEncryptType, |
| 1806 | &RSNAuthType, |
| 1807 | pConfig->pRSNWPAReqIE[1]+2, |
| 1808 | pConfig->pRSNWPAReqIE ); |
| 1809 | |
| 1810 | if( VOS_STATUS_SUCCESS == status ) |
| 1811 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1812 | /* Now copy over all the security attributes you have |
| 1813 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1814 | * */ |
| 1815 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1816 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1817 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1818 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1819 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1820 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1821 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1822 | } |
| 1823 | } |
| 1824 | } |
| 1825 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1826 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1827 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1828 | return -EINVAL; |
| 1829 | } |
| 1830 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1831 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1832 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1833 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1834 | if (params->ssid != NULL) |
| 1835 | { |
| 1836 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1837 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1838 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1839 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1840 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1841 | #else |
| 1842 | if (ssid != NULL) |
| 1843 | { |
| 1844 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1845 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1846 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1847 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1848 | } |
| 1849 | #endif |
| 1850 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1851 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1852 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1853 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1854 | /* default value */ |
| 1855 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1856 | pConfig->num_accept_mac = 0; |
| 1857 | pConfig->num_deny_mac = 0; |
| 1858 | |
| 1859 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1860 | pBeacon->tail, pBeacon->tail_len); |
| 1861 | |
| 1862 | /* pIe for black list is following form: |
| 1863 | type : 1 byte |
| 1864 | length : 1 byte |
| 1865 | OUI : 4 bytes |
| 1866 | acl type : 1 byte |
| 1867 | no of mac addr in black list: 1 byte |
| 1868 | 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] | 1869 | */ |
| 1870 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1871 | { |
| 1872 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1873 | pConfig->num_deny_mac = pIe[7]; |
| 1874 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1875 | pIe[6], pIe[7]); |
| 1876 | if (pConfig->num_deny_mac > MAX_MAC_ADDRESS_DENIED) |
| 1877 | pConfig->num_deny_mac = MAX_MAC_ADDRESS_DENIED; |
| 1878 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1879 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1880 | { |
| 1881 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1882 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1883 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1884 | } |
| 1885 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1886 | pBeacon->tail, pBeacon->tail_len); |
| 1887 | |
| 1888 | /* pIe for white list is following form: |
| 1889 | type : 1 byte |
| 1890 | length : 1 byte |
| 1891 | OUI : 4 bytes |
| 1892 | acl type : 1 byte |
| 1893 | no of mac addr in white list: 1 byte |
| 1894 | 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] | 1895 | */ |
| 1896 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1897 | { |
| 1898 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1899 | pConfig->num_accept_mac = pIe[7]; |
| 1900 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 1901 | pIe[6], pIe[7]); |
| 1902 | if (pConfig->num_accept_mac > MAX_MAC_ADDRESS_ACCEPTED) |
| 1903 | pConfig->num_accept_mac = MAX_MAC_ADDRESS_ACCEPTED; |
| 1904 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1905 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 1906 | { |
| 1907 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1908 | acl_entry++; |
| 1909 | } |
| 1910 | } |
| 1911 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 1912 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1913 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 1914 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 1915 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 1916 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 1917 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 1918 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1919 | (((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] | 1920 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 1921 | ((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] | 1922 | { |
| 1923 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
| 1924 | } |
| 1925 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1926 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 1927 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1928 | { |
| 1929 | sme_SelectCBMode(hHal, |
| 1930 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 1931 | pConfig->channel); |
| 1932 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1933 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 1934 | pConfig->ht_capab = |
| 1935 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 1936 | |
| 1937 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 1938 | { |
| 1939 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 1940 | return -EINVAL; |
| 1941 | } |
| 1942 | |
| 1943 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1944 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1945 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 1946 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1947 | pConfig->obssProtEnabled = |
| 1948 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1949 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1950 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1951 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1952 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1953 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 1954 | (int)pConfig->channel); |
| 1955 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1956 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 1957 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1958 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1959 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1960 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 1961 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 1962 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1963 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1964 | { |
| 1965 | //Bss already started. just return. |
| 1966 | //TODO Probably it should update some beacon params. |
| 1967 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 1968 | EXIT(); |
| 1969 | return 0; |
| 1970 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1972 | pConfig->persona = pHostapdAdapter->device_mode; |
| 1973 | |
| 1974 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 1975 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 1976 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 1977 | { |
| 1978 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 1979 | return -EINVAL; |
| 1980 | } |
| 1981 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1982 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1983 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 1984 | |
| 1985 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1986 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1987 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1988 | { |
| 1989 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1990 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 1991 | VOS_ASSERT(0); |
| 1992 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1993 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1994 | //Succesfully started Bss update the state bit. |
| 1995 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 1996 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1997 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 1998 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 1999 | { |
| 2000 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2001 | { |
| 2002 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2003 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2004 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2005 | } |
| 2006 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2007 | { |
| 2008 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2009 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2010 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2011 | } |
| 2012 | } |
| 2013 | #endif |
| 2014 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2015 | pHostapdState->bCommit = TRUE; |
| 2016 | EXIT(); |
| 2017 | |
| 2018 | return 0; |
| 2019 | } |
| 2020 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2021 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2022 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2023 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2024 | struct beacon_parameters *params) |
| 2025 | { |
| 2026 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2027 | int status=VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2028 | |
| 2029 | ENTER(); |
| 2030 | |
| 2031 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 2032 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2033 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 2034 | { |
| 2035 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2036 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2037 | return -EAGAIN; |
| 2038 | } |
| 2039 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2040 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2041 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2042 | ) |
| 2043 | { |
| 2044 | beacon_data_t *old,*new; |
| 2045 | |
| 2046 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2047 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2048 | if (old) |
| 2049 | return -EALREADY; |
| 2050 | |
| 2051 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2052 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2053 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2054 | { |
| 2055 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2056 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 2057 | return -EINVAL; |
| 2058 | } |
| 2059 | |
| 2060 | pAdapter->sessionCtx.ap.beacon = new; |
| 2061 | |
| 2062 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2063 | } |
| 2064 | |
| 2065 | EXIT(); |
| 2066 | return status; |
| 2067 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2068 | |
| 2069 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2070 | struct net_device *dev, |
| 2071 | struct beacon_parameters *params) |
| 2072 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2073 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2074 | int status=VOS_STATUS_SUCCESS; |
| 2075 | |
| 2076 | ENTER(); |
| 2077 | |
| 2078 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2079 | __func__,pAdapter->device_mode); |
| 2080 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2081 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 2082 | { |
| 2083 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2084 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2085 | return -EAGAIN; |
| 2086 | } |
| 2087 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2088 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2089 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
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 | { |
| 2092 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2093 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2094 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2095 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2096 | if (!old) |
| 2097 | return -ENOENT; |
| 2098 | |
| 2099 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2100 | |
| 2101 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2102 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2103 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2104 | return -EINVAL; |
| 2105 | } |
| 2106 | |
| 2107 | pAdapter->sessionCtx.ap.beacon = new; |
| 2108 | |
| 2109 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2110 | } |
| 2111 | |
| 2112 | EXIT(); |
| 2113 | return status; |
| 2114 | } |
| 2115 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2116 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2117 | |
| 2118 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2119 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2120 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2121 | #else |
| 2122 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2123 | struct net_device *dev) |
| 2124 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2125 | { |
| 2126 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2127 | hdd_context_t *pHddCtx = NULL; |
| 2128 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2129 | hdd_adapter_t *staAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2130 | VOS_STATUS status = 0; |
| 2131 | |
| 2132 | ENTER(); |
| 2133 | |
| 2134 | if (NULL == pAdapter) |
| 2135 | { |
| 2136 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2137 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2138 | return -ENODEV; |
| 2139 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2140 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2141 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2142 | if (NULL == pHddCtx) |
| 2143 | { |
| 2144 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2145 | "%s: HDD context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2146 | return -ENODEV; |
| 2147 | } |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2148 | if (pHddCtx->isLogpInProgress) |
| 2149 | { |
| 2150 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2151 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2152 | return -EAGAIN; |
| 2153 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2154 | |
| 2155 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2156 | if (NULL == staAdapter) |
| 2157 | { |
| 2158 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2159 | if (NULL == staAdapter) |
| 2160 | { |
| 2161 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2162 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2163 | return -ENODEV; |
| 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | pScanInfo = &pHddCtx->scan_info; |
| 2168 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2169 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2170 | { |
| 2171 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2172 | return -EAGAIN; |
| 2173 | } |
| 2174 | |
| 2175 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2176 | |
| 2177 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2178 | __func__,pAdapter->device_mode); |
| 2179 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2180 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2181 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2182 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2183 | hdd_abort_mac_scan(staAdapter->pHddCtx); |
| 2184 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2185 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2186 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2187 | if (!status) |
| 2188 | { |
| 2189 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2190 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2191 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2192 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2193 | return 0; |
| 2194 | } |
| 2195 | } |
| 2196 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2197 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2198 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2199 | ) |
| 2200 | { |
| 2201 | beacon_data_t *old; |
| 2202 | |
| 2203 | old = pAdapter->sessionCtx.ap.beacon; |
| 2204 | |
| 2205 | if (!old) |
| 2206 | return -ENOENT; |
| 2207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2208 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2209 | |
| 2210 | mutex_lock(&pHddCtx->sap_lock); |
| 2211 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2212 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2213 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2214 | { |
| 2215 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2216 | |
| 2217 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2218 | |
| 2219 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2220 | { |
| 2221 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2222 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2223 | VOS_ASSERT(0); |
| 2224 | } |
| 2225 | } |
| 2226 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2227 | } |
| 2228 | mutex_unlock(&pHddCtx->sap_lock); |
| 2229 | |
| 2230 | if(status != VOS_STATUS_SUCCESS) |
| 2231 | { |
| 2232 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2233 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2234 | return -EINVAL; |
| 2235 | } |
| 2236 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2237 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2238 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2239 | ==eHAL_STATUS_FAILURE) |
| 2240 | { |
| 2241 | hddLog(LOGE, |
| 2242 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2243 | } |
| 2244 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2245 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2246 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2247 | eANI_BOOLEAN_FALSE) ) |
| 2248 | { |
| 2249 | hddLog(LOGE, |
| 2250 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2251 | } |
| 2252 | |
| 2253 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2254 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2255 | |
| 2256 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2257 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2258 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2259 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2260 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2261 | { |
| 2262 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2263 | "GO got removed"); |
| 2264 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2265 | } |
| 2266 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2267 | } |
| 2268 | EXIT(); |
| 2269 | return status; |
| 2270 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2271 | |
| 2272 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2273 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2274 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2275 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2276 | struct cfg80211_ap_settings *params) |
| 2277 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2278 | hdd_adapter_t *pAdapter; |
| 2279 | hdd_context_t *pHddCtx; |
| 2280 | int status = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2281 | |
| 2282 | ENTER(); |
| 2283 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2284 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2285 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2286 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2287 | "%s: Device is Null", __func__); |
| 2288 | return -ENODEV; |
| 2289 | } |
| 2290 | |
| 2291 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2292 | if (NULL == pAdapter) |
| 2293 | { |
| 2294 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2295 | "%s: HDD adapter is Null", __func__); |
| 2296 | return -ENODEV; |
| 2297 | } |
| 2298 | |
| 2299 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2300 | { |
| 2301 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2302 | "%s: HDD adapter magic is invalid", __func__); |
| 2303 | return -ENODEV; |
| 2304 | } |
| 2305 | |
| 2306 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2307 | if (NULL == pHddCtx) |
| 2308 | { |
| 2309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2310 | "%s: HDD context is Null", __func__); |
| 2311 | return -ENODEV; |
| 2312 | } |
| 2313 | |
| 2314 | if (pHddCtx->isLogpInProgress) |
| 2315 | { |
| 2316 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2317 | "%s: LOGP in Progress. Ignore!!!", __func__); |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2318 | return -EAGAIN; |
| 2319 | } |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2320 | |
| 2321 | if (pHddCtx->isLoadUnloadInProgress) |
| 2322 | { |
| 2323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2324 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 2325 | return -EAGAIN; |
| 2326 | } |
| 2327 | |
| 2328 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2329 | __func__, pAdapter->device_mode); |
| 2330 | |
| 2331 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2332 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2333 | ) |
| 2334 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2335 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2336 | |
| 2337 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2338 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2339 | if (old) |
| 2340 | return -EALREADY; |
| 2341 | |
| 2342 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2343 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2344 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2345 | { |
| 2346 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2347 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2348 | return -EINVAL; |
| 2349 | } |
| 2350 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2351 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2352 | wlan_hdd_cfg80211_set_channel(wiphy, dev, params->channel, params->channel_type); |
| 2353 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2354 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2355 | params->ssid_len, params->hidden_ssid); |
| 2356 | } |
| 2357 | |
| 2358 | EXIT(); |
| 2359 | return status; |
| 2360 | } |
| 2361 | |
| 2362 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2363 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2364 | struct net_device *dev, |
| 2365 | struct cfg80211_beacon_data *params) |
| 2366 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2367 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2368 | int status=VOS_STATUS_SUCCESS; |
| 2369 | |
| 2370 | ENTER(); |
| 2371 | |
| 2372 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2373 | __func__, pAdapter->device_mode); |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2374 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2375 | { |
| 2376 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2377 | return -EAGAIN; |
| 2378 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2379 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2380 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2381 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2382 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2383 | { |
| 2384 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2385 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2386 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2387 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2388 | if (!old) |
| 2389 | return -ENOENT; |
| 2390 | |
| 2391 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2392 | |
| 2393 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2394 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2395 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2396 | return -EINVAL; |
| 2397 | } |
| 2398 | |
| 2399 | pAdapter->sessionCtx.ap.beacon = new; |
| 2400 | |
| 2401 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2402 | } |
| 2403 | |
| 2404 | EXIT(); |
| 2405 | return status; |
| 2406 | } |
| 2407 | |
| 2408 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2409 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2410 | |
| 2411 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2412 | struct net_device *dev, |
| 2413 | struct bss_parameters *params) |
| 2414 | { |
| 2415 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2416 | |
| 2417 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2418 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2419 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2420 | __func__,pAdapter->device_mode); |
| 2421 | |
| 2422 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2423 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2424 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2425 | { |
| 2426 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2427 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2428 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2429 | { |
| 2430 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2431 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2432 | } |
| 2433 | |
| 2434 | EXIT(); |
| 2435 | return 0; |
| 2436 | } |
| 2437 | |
| 2438 | /* |
| 2439 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2440 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2441 | */ |
| 2442 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2443 | struct net_device *ndev, |
| 2444 | enum nl80211_iftype type, |
| 2445 | u32 *flags, |
| 2446 | struct vif_params *params |
| 2447 | ) |
| 2448 | { |
| 2449 | struct wireless_dev *wdev; |
| 2450 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2451 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2452 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2453 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2454 | eCsrRoamBssType LastBSSType; |
| 2455 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 2456 | eMib_dot11DesiredBssType connectedBssType; |
| 2457 | VOS_STATUS status; |
| 2458 | |
| 2459 | ENTER(); |
| 2460 | |
| 2461 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2462 | { |
| 2463 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2464 | return -EAGAIN; |
| 2465 | } |
| 2466 | |
| 2467 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2468 | __func__, pAdapter->device_mode); |
| 2469 | |
| 2470 | wdev = ndev->ieee80211_ptr; |
| 2471 | |
| 2472 | #ifdef WLAN_BTAMP_FEATURE |
| 2473 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2474 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2475 | (NL80211_IFTYPE_AP == type)|| |
| 2476 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2477 | { |
| 2478 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2479 | // stop AMP traffic |
| 2480 | status = WLANBAP_StopAmp(); |
| 2481 | if(VOS_STATUS_SUCCESS != status ) |
| 2482 | { |
| 2483 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2484 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2485 | "%s: Failed to stop AMP", __func__); |
| 2486 | return -EINVAL; |
| 2487 | } |
| 2488 | } |
| 2489 | #endif //WLAN_BTAMP_FEATURE |
| 2490 | /* Reset the current device mode bit mask*/ |
| 2491 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2492 | |
| 2493 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2494 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2495 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2496 | ) |
| 2497 | { |
| 2498 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2499 | pRoamProfile = &pWextState->roamProfile; |
| 2500 | LastBSSType = pRoamProfile->BSSType; |
| 2501 | |
| 2502 | switch (type) |
| 2503 | { |
| 2504 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2505 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2506 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2507 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2508 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2509 | #ifdef WLAN_FEATURE_11AC |
| 2510 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2511 | { |
| 2512 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2513 | } |
| 2514 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2515 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2516 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2517 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2518 | //Check for sub-string p2p to confirm its a p2p interface |
| 2519 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2520 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2521 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2522 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2523 | } |
| 2524 | else |
| 2525 | { |
| 2526 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2527 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2528 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2529 | break; |
| 2530 | case NL80211_IFTYPE_ADHOC: |
| 2531 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2532 | "%s: setting interface Type to ADHOC", __func__); |
| 2533 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2534 | pRoamProfile->phyMode = |
| 2535 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2536 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2537 | wdev->iftype = type; |
| 2538 | break; |
| 2539 | |
| 2540 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2541 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2542 | { |
| 2543 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2544 | "%s: setting interface Type to %s", __func__, |
| 2545 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2546 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2547 | //Cancel any remain on channel for GO mode |
| 2548 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2549 | { |
| 2550 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2551 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2552 | if (NL80211_IFTYPE_AP == type) |
| 2553 | { |
| 2554 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2555 | * address. This will take one HW STA and the max number of clients |
| 2556 | * that can connect to softAP will be reduced by one. so while changing |
| 2557 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2558 | * interface as it is not required in SoftAP mode. |
| 2559 | */ |
| 2560 | |
| 2561 | // Get P2P Adapter |
| 2562 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2563 | |
| 2564 | if (pP2pAdapter) |
| 2565 | { |
| 2566 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2567 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2568 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2569 | } |
| 2570 | } |
| 2571 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2572 | //De-init the adapter. |
| 2573 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2574 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2575 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2576 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2577 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2578 | |
| 2579 | //Disable BMPS and IMPS if enabled |
| 2580 | //before starting Go |
| 2581 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2582 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2583 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2584 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2585 | { |
| 2586 | //Fail to Exit BMPS |
| 2587 | VOS_ASSERT(0); |
| 2588 | } |
| 2589 | } |
| 2590 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2591 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2592 | (pConfig->apRandomBssidEnabled)) |
| 2593 | { |
| 2594 | /* To meet Android requirements create a randomized |
| 2595 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2596 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2597 | ndev->dev_addr[0] = 0x02; |
| 2598 | ndev->dev_addr[1] = 0x1A; |
| 2599 | ndev->dev_addr[2] = 0x11; |
| 2600 | ndev->dev_addr[3] |= 0xF0; |
| 2601 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2602 | VOS_MAC_ADDR_SIZE); |
| 2603 | pr_info("wlan: Generated HotSpot BSSID " |
| 2604 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2605 | ndev->dev_addr[0], |
| 2606 | ndev->dev_addr[1], |
| 2607 | ndev->dev_addr[2], |
| 2608 | ndev->dev_addr[3], |
| 2609 | ndev->dev_addr[4], |
| 2610 | ndev->dev_addr[5]); |
| 2611 | } |
| 2612 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2613 | hdd_set_ap_ops( pAdapter->dev ); |
| 2614 | |
| 2615 | status = hdd_init_ap_mode(pAdapter); |
| 2616 | if(status != VOS_STATUS_SUCCESS) |
| 2617 | { |
| 2618 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2619 | "%s: Error initializing the ap mode", __func__); |
| 2620 | return -EINVAL; |
| 2621 | } |
| 2622 | hdd_set_conparam(1); |
| 2623 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2624 | /*interface type changed update in wiphy structure*/ |
| 2625 | if(wdev) |
| 2626 | { |
| 2627 | wdev->iftype = type; |
| 2628 | pHddCtx->change_iface = type; |
| 2629 | } |
| 2630 | else |
| 2631 | { |
| 2632 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2633 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2634 | return -EINVAL; |
| 2635 | } |
| 2636 | goto done; |
| 2637 | } |
| 2638 | |
| 2639 | default: |
| 2640 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2641 | __func__); |
| 2642 | return -EOPNOTSUPP; |
| 2643 | } |
| 2644 | } |
| 2645 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2646 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2647 | ) |
| 2648 | { |
| 2649 | switch(type) |
| 2650 | { |
| 2651 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2652 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2653 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2654 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2655 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2656 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2657 | //Check for sub-string p2p to confirm its a p2p interface |
| 2658 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2659 | { |
| 2660 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2661 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2662 | } |
| 2663 | else |
| 2664 | { |
| 2665 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2666 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2667 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2668 | hdd_set_conparam(0); |
| 2669 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2670 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2671 | hdd_set_station_ops( pAdapter->dev ); |
| 2672 | status = hdd_init_station_mode( pAdapter ); |
| 2673 | if( VOS_STATUS_SUCCESS != status ) |
| 2674 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2675 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2676 | * This is the right place to enable back bmps_imps() |
| 2677 | */ |
| 2678 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2679 | goto done; |
| 2680 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2681 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2682 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2683 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2684 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2685 | goto done; |
| 2686 | default: |
| 2687 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2688 | __func__); |
| 2689 | return -EOPNOTSUPP; |
| 2690 | |
| 2691 | } |
| 2692 | |
| 2693 | } |
| 2694 | else |
| 2695 | { |
| 2696 | return -EOPNOTSUPP; |
| 2697 | } |
| 2698 | |
| 2699 | |
| 2700 | if(pRoamProfile) |
| 2701 | { |
| 2702 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2703 | { |
| 2704 | /*interface type changed update in wiphy structure*/ |
| 2705 | wdev->iftype = type; |
| 2706 | |
| 2707 | /*the BSS mode changed, We need to issue disconnect |
| 2708 | if connected or in IBSS disconnect state*/ |
| 2709 | if ( hdd_connGetConnectedBssType( |
| 2710 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2711 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2712 | { |
| 2713 | /*need to issue a disconnect to CSR.*/ |
| 2714 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2715 | if( eHAL_STATUS_SUCCESS == |
| 2716 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2717 | pAdapter->sessionId, |
| 2718 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2719 | { |
| 2720 | wait_for_completion_interruptible_timeout( |
| 2721 | &pAdapter->disconnect_comp_var, |
| 2722 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2723 | } |
| 2724 | } |
| 2725 | } |
| 2726 | } |
| 2727 | |
| 2728 | done: |
| 2729 | /*set bitmask based on updated value*/ |
| 2730 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2731 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2732 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2733 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2734 | { |
| 2735 | //we are ok to do AMP |
| 2736 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2737 | } |
| 2738 | #endif //WLAN_BTAMP_FEATURE |
| 2739 | EXIT(); |
| 2740 | return 0; |
| 2741 | } |
| 2742 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2743 | #ifdef FEATURE_WLAN_TDLS |
| 2744 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2745 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2746 | { |
| 2747 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2748 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2749 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2750 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2751 | |
| 2752 | ENTER(); |
| 2753 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2754 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2755 | { |
| 2756 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2757 | "Invalid arguments"); |
| 2758 | return -EINVAL; |
| 2759 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2760 | |
| 2761 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2762 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2763 | { |
| 2764 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2765 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2766 | MAC_ADDRESS_STR " Request declined.", |
| 2767 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2768 | return -ENOTSUPP; |
| 2769 | } |
| 2770 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2771 | if (pHddCtx->isLogpInProgress) |
| 2772 | { |
| 2773 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2774 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2775 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2776 | return -EBUSY; |
| 2777 | } |
| 2778 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2779 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2780 | |
| 2781 | if ( NULL == pTdlsPeer ) { |
| 2782 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2783 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2784 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2785 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2786 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2787 | |
| 2788 | /* in add station, we accept existing valid staId if there is */ |
| 2789 | if ((0 == update) && |
| 2790 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2791 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2792 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2793 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2794 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2795 | " link_status %d. staId %d. add station ignored.", |
| 2796 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2797 | return 0; |
| 2798 | } |
| 2799 | /* in change station, we accept only when staId is valid */ |
| 2800 | if ((1 == update) && |
| 2801 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2802 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2803 | { |
| 2804 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2805 | "%s: " MAC_ADDRESS_STR |
| 2806 | " link status %d. staId %d. change station %s.", |
| 2807 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2808 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2809 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2810 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2811 | |
| 2812 | /* 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] | 2813 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2814 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2815 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2816 | "%s: " MAC_ADDRESS_STR |
| 2817 | " TDLS setup is ongoing. Request declined.", |
| 2818 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2819 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2820 | } |
| 2821 | |
| 2822 | /* first to check if we reached to maximum supported TDLS peer. |
| 2823 | TODO: for now, return -EPERM looks working fine, |
| 2824 | but need to check if any other errno fit into this category.*/ |
| 2825 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2826 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2827 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2828 | "%s: " MAC_ADDRESS_STR |
| 2829 | " TDLS Max peer already connected. Request declined.", |
| 2830 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2831 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2832 | } |
| 2833 | else |
| 2834 | { |
| 2835 | hddTdlsPeer_t *pTdlsPeer; |
| 2836 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2837 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2838 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2839 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2840 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2841 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2842 | return -EPERM; |
| 2843 | } |
| 2844 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2845 | if (0 == update) |
| 2846 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2847 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2848 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2849 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2850 | { |
| 2851 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2852 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2853 | if(StaParams->htcap_present) |
| 2854 | { |
| 2855 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2856 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 2857 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2858 | "ht_capa->extended_capabilities: %0x", |
| 2859 | StaParams->HTCap.extendedHtCapInfo); |
| 2860 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2861 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2862 | "params->capability: %0x",StaParams->capability); |
| 2863 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2864 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2865 | if(StaParams->vhtcap_present) |
| 2866 | { |
| 2867 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2868 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 2869 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 2870 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 2871 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2872 | { |
| 2873 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2874 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2875 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 2876 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2877 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 2878 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 2879 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2880 | else if ((1 == update) && (NULL == StaParams)) |
| 2881 | { |
| 2882 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2883 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 2884 | return -EPERM; |
| 2885 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2886 | |
| 2887 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 2888 | |
| 2889 | if (!update) |
| 2890 | { |
| 2891 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2892 | pAdapter->sessionId, mac); |
| 2893 | } |
| 2894 | else |
| 2895 | { |
| 2896 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2897 | pAdapter->sessionId, mac, StaParams); |
| 2898 | } |
| 2899 | |
| 2900 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 2901 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 2902 | |
| 2903 | if (!status) |
| 2904 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2905 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2906 | "%s: timeout waiting for tdls add station indication", |
| 2907 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2908 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2909 | } |
| 2910 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 2911 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2912 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2913 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2914 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2915 | } |
| 2916 | |
| 2917 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2918 | |
| 2919 | error: |
| 2920 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 2921 | return -EPERM; |
| 2922 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2923 | } |
| 2924 | #endif |
| 2925 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2926 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 2927 | struct net_device *dev, |
| 2928 | u8 *mac, |
| 2929 | struct station_parameters *params) |
| 2930 | { |
| 2931 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2932 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2933 | hdd_context_t *pHddCtx; |
| 2934 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2935 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2936 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2937 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2938 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 2939 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2940 | ENTER(); |
| 2941 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2942 | if ((NULL == pAdapter)) |
| 2943 | { |
| 2944 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2945 | "invalid adapter "); |
| 2946 | return -EINVAL; |
| 2947 | } |
| 2948 | |
| 2949 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2950 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2951 | |
| 2952 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 2953 | { |
| 2954 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2955 | "invalid HDD state or HDD station context"); |
| 2956 | return -EINVAL; |
| 2957 | } |
| 2958 | |
| 2959 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2960 | { |
| 2961 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2962 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 2963 | return -EAGAIN; |
| 2964 | } |
| 2965 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2966 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 2967 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2968 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 2969 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2970 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2971 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2972 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2973 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2974 | WLANTL_STA_AUTHENTICATED); |
| 2975 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2976 | if (status != VOS_STATUS_SUCCESS) |
| 2977 | { |
| 2978 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2979 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 2980 | return -EINVAL; |
| 2981 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2982 | } |
| 2983 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2984 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 2985 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 2986 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2987 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 2988 | StaParams.capability = params->capability; |
| 2989 | StaParams.uapsd_queues = params->uapsd_queues; |
| 2990 | StaParams.max_sp = params->max_sp; |
| 2991 | |
| 2992 | if (0 != params->ext_capab_len) |
| 2993 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 2994 | sizeof(StaParams.extn_capability)); |
| 2995 | |
| 2996 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 2997 | { |
| 2998 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2999 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3000 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3001 | |
| 3002 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3003 | |
| 3004 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3005 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3006 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3007 | * modified to send more rates. |
| 3008 | */ |
| 3009 | |
| 3010 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3011 | */ |
| 3012 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3013 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3014 | |
| 3015 | if (0 != StaParams.supported_rates_len) { |
| 3016 | int i = 0; |
| 3017 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3018 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3019 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3020 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3021 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3022 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3023 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3024 | } |
| 3025 | |
| 3026 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3027 | { |
| 3028 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3029 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3030 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3031 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3032 | if (0 != params->ext_capab_len ) { |
| 3033 | /*Define A Macro : TODO Sunil*/ |
| 3034 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3035 | isBufSta = 1; |
| 3036 | } |
| 3037 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3038 | //status = wlan_hdd_tdls_set_peer_caps( mac, params->uapsd_queues, |
| 3039 | // params->max_sp, isBufSta); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3040 | //if (VOS_STATUS_SUCCESS != status) { |
| 3041 | // VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3042 | // "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3043 | // return -EINVAL; |
| 3044 | //} |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3045 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3046 | |
| 3047 | if (VOS_STATUS_SUCCESS != status) { |
| 3048 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3049 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3050 | return -EINVAL; |
| 3051 | } |
| 3052 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3053 | #endif |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3054 | if(params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
| 3055 | { |
| 3056 | status = WLANTL_ChangeSTAState(pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ], |
| 3057 | WLANTL_STA_AUTHENTICATED); |
| 3058 | if (status != VOS_STATUS_SUCCESS) |
| 3059 | { |
| 3060 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3061 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3062 | return -EINVAL; |
| 3063 | } |
| 3064 | pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE; |
| 3065 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3066 | "%s: TL Moving to Authenticated state", __func__); |
| 3067 | } |
| 3068 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3069 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3070 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3071 | return status; |
| 3072 | } |
| 3073 | |
| 3074 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3075 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3076 | * This function is used to initialize the key information |
| 3077 | */ |
| 3078 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3079 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3080 | struct net_device *ndev, |
| 3081 | u8 key_index, bool pairwise, |
| 3082 | const u8 *mac_addr, |
| 3083 | struct key_params *params |
| 3084 | ) |
| 3085 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3086 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3087 | struct net_device *ndev, |
| 3088 | u8 key_index, const u8 *mac_addr, |
| 3089 | struct key_params *params |
| 3090 | ) |
| 3091 | #endif |
| 3092 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3093 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3094 | tCsrRoamSetKey setKey; |
| 3095 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3096 | int status = 0; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3097 | v_U32_t roamId= 0xFF; |
| 3098 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3099 | hdd_hostapd_state_t *pHostapdState; |
| 3100 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3101 | eHalStatus halStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3102 | |
| 3103 | ENTER(); |
| 3104 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3105 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 3106 | { |
| 3107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3108 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3109 | return -EAGAIN; |
| 3110 | } |
| 3111 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3112 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3113 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3114 | |
| 3115 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3116 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3117 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3118 | key_index); |
| 3119 | |
| 3120 | return -EINVAL; |
| 3121 | } |
| 3122 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3123 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3124 | { |
| 3125 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3126 | params->key_len); |
| 3127 | |
| 3128 | return -EINVAL; |
| 3129 | } |
| 3130 | |
| 3131 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3132 | "%s: called with key index = %d & key length %d", |
| 3133 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3134 | |
| 3135 | /*extract key idx, key len and key*/ |
| 3136 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3137 | setKey.keyId = key_index; |
| 3138 | setKey.keyLength = params->key_len; |
| 3139 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3140 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3141 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3142 | { |
| 3143 | case WLAN_CIPHER_SUITE_WEP40: |
| 3144 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3145 | break; |
| 3146 | |
| 3147 | case WLAN_CIPHER_SUITE_WEP104: |
| 3148 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3149 | break; |
| 3150 | |
| 3151 | case WLAN_CIPHER_SUITE_TKIP: |
| 3152 | { |
| 3153 | u8 *pKey = &setKey.Key[0]; |
| 3154 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3155 | |
| 3156 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3157 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3158 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3159 | |
| 3160 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3161 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3162 | |--------------|----------|----------| |
| 3163 | <---16bytes---><--8bytes--><--8bytes--> |
| 3164 | |
| 3165 | */ |
| 3166 | /*Sme expects the 32 bytes key to be in the below order |
| 3167 | |
| 3168 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3169 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3170 | |--------------|----------|----------| |
| 3171 | <---16bytes---><--8bytes--><--8bytes--> |
| 3172 | */ |
| 3173 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3174 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3175 | |
| 3176 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3177 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3178 | |
| 3179 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3180 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3181 | |
| 3182 | |
| 3183 | break; |
| 3184 | } |
| 3185 | |
| 3186 | case WLAN_CIPHER_SUITE_CCMP: |
| 3187 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3188 | break; |
| 3189 | |
| 3190 | #ifdef FEATURE_WLAN_WAPI |
| 3191 | case WLAN_CIPHER_SUITE_SMS4: |
| 3192 | { |
| 3193 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3194 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3195 | params->key, params->key_len); |
| 3196 | return 0; |
| 3197 | } |
| 3198 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3199 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3200 | #ifdef FEATURE_WLAN_CCX |
| 3201 | case WLAN_CIPHER_SUITE_KRK: |
| 3202 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3203 | break; |
| 3204 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3205 | |
| 3206 | #ifdef WLAN_FEATURE_11W |
| 3207 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3208 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3209 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3210 | #endif |
| 3211 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3212 | default: |
| 3213 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3214 | __func__, params->cipher); |
| 3215 | return -EOPNOTSUPP; |
| 3216 | } |
| 3217 | |
| 3218 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3219 | __func__, setKey.encType); |
| 3220 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3221 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3222 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3223 | (!pairwise) |
| 3224 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3225 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3226 | #endif |
| 3227 | ) |
| 3228 | { |
| 3229 | /* set group key*/ |
| 3230 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 3231 | "%s- %d: setting Broadcast key", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3232 | __func__, __LINE__); |
| 3233 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3234 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3235 | } |
| 3236 | else |
| 3237 | { |
| 3238 | /* set pairwise key*/ |
| 3239 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3240 | "%s- %d: setting pairwise key", |
| 3241 | __func__, __LINE__); |
| 3242 | setKey.keyDirection = eSIR_TX_RX; |
| 3243 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3244 | } |
| 3245 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3246 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3247 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3248 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3249 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3250 | if( pHostapdState->bssState == BSS_START ) |
| 3251 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3252 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3253 | |
| 3254 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3255 | { |
| 3256 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3257 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3258 | __LINE__, status ); |
| 3259 | } |
| 3260 | } |
| 3261 | |
| 3262 | /* Saving WEP keys */ |
| 3263 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3264 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3265 | { |
| 3266 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3267 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3268 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3269 | } |
| 3270 | else |
| 3271 | { |
| 3272 | //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] | 3273 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3274 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3275 | } |
| 3276 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3277 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3278 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3279 | { |
| 3280 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3281 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3282 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3283 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3284 | if (!pairwise) |
| 3285 | #else |
| 3286 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3287 | #endif |
| 3288 | { |
| 3289 | /* set group key*/ |
| 3290 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3291 | { |
| 3292 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3293 | "%s- %d: Perform Set key Complete", |
| 3294 | __func__, __LINE__); |
| 3295 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3296 | } |
| 3297 | } |
| 3298 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3299 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3300 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3301 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3302 | |
| 3303 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3304 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3305 | params->key, params->key_len); |
| 3306 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3307 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3308 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3309 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3310 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3311 | "%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] | 3312 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3313 | setKey.peerMac[2], setKey.peerMac[3], |
| 3314 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3315 | setKey.keyDirection); |
| 3316 | |
| 3317 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3318 | |
| 3319 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3320 | { |
| 3321 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3322 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3323 | __LINE__, vos_status ); |
| 3324 | |
| 3325 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3326 | |
| 3327 | return -EINVAL; |
| 3328 | |
| 3329 | } |
| 3330 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3331 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3332 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3333 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3334 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3335 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3336 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3337 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3338 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3339 | "%s: Update PreAuth Key success", __func__); |
| 3340 | return 0; |
| 3341 | } |
| 3342 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3343 | { |
| 3344 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3345 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3346 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3347 | } |
| 3348 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3349 | |
| 3350 | /* issue set key request to SME*/ |
| 3351 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3352 | pAdapter->sessionId, &setKey, &roamId ); |
| 3353 | |
| 3354 | if ( 0 != status ) |
| 3355 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3356 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3357 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3358 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3359 | return -EINVAL; |
| 3360 | } |
| 3361 | |
| 3362 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3363 | /* in case of IBSS as there was no information available about WEP keys during |
| 3364 | * 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] | 3365 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3366 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3367 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3368 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3369 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3370 | ) |
| 3371 | && |
| 3372 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3373 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3374 | ) |
| 3375 | ) |
| 3376 | { |
| 3377 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3378 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3379 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3380 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3381 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3382 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3383 | setKey.peerMac[2], setKey.peerMac[3], |
| 3384 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3385 | setKey.keyDirection); |
| 3386 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3387 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3388 | pAdapter->sessionId, &setKey, &roamId ); |
| 3389 | |
| 3390 | if ( 0 != status ) |
| 3391 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3392 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3393 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3394 | __func__, status); |
| 3395 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3396 | return -EINVAL; |
| 3397 | } |
| 3398 | } |
| 3399 | } |
| 3400 | |
| 3401 | return 0; |
| 3402 | } |
| 3403 | |
| 3404 | /* |
| 3405 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3406 | * This function is used to get the key information |
| 3407 | */ |
| 3408 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3409 | static int wlan_hdd_cfg80211_get_key( |
| 3410 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3411 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3412 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3413 | const u8 *mac_addr, void *cookie, |
| 3414 | void (*callback)(void *cookie, struct key_params*) |
| 3415 | ) |
| 3416 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3417 | static int wlan_hdd_cfg80211_get_key( |
| 3418 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3419 | struct net_device *ndev, |
| 3420 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3421 | void (*callback)(void *cookie, struct key_params*) |
| 3422 | ) |
| 3423 | #endif |
| 3424 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3425 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3426 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3427 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3428 | struct key_params params; |
| 3429 | |
| 3430 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3431 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3432 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3433 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3434 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3435 | memset(¶ms, 0, sizeof(params)); |
| 3436 | |
| 3437 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3438 | { |
| 3439 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3440 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3441 | |
| 3442 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3443 | { |
| 3444 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3445 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3446 | break; |
| 3447 | |
| 3448 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3449 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3450 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3451 | break; |
| 3452 | |
| 3453 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3454 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3455 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3456 | break; |
| 3457 | |
| 3458 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3459 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3460 | break; |
| 3461 | |
| 3462 | case eCSR_ENCRYPT_TYPE_AES: |
| 3463 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3464 | break; |
| 3465 | |
| 3466 | default: |
| 3467 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3468 | break; |
| 3469 | } |
| 3470 | |
| 3471 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3472 | params.seq_len = 0; |
| 3473 | params.seq = NULL; |
| 3474 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3475 | callback(cookie, ¶ms); |
| 3476 | return 0; |
| 3477 | } |
| 3478 | |
| 3479 | /* |
| 3480 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3481 | * This function is used to delete the key information |
| 3482 | */ |
| 3483 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3484 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3485 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3486 | u8 key_index, |
| 3487 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3488 | const u8 *mac_addr |
| 3489 | ) |
| 3490 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3491 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3492 | struct net_device *ndev, |
| 3493 | u8 key_index, |
| 3494 | const u8 *mac_addr |
| 3495 | ) |
| 3496 | #endif |
| 3497 | { |
| 3498 | int status = 0; |
| 3499 | |
| 3500 | //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] | 3501 | //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] | 3502 | //it is observed that this is invalidating peer |
| 3503 | //key index whenever re-key is done. This is affecting data link. |
| 3504 | //It should be ok to ignore del_key. |
| 3505 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3506 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3507 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3508 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3509 | tCsrRoamSetKey setKey; |
| 3510 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3511 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3512 | ENTER(); |
| 3513 | |
| 3514 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3515 | __func__,pAdapter->device_mode); |
| 3516 | |
| 3517 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3518 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3519 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3520 | key_index); |
| 3521 | |
| 3522 | return -EINVAL; |
| 3523 | } |
| 3524 | |
| 3525 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3526 | setKey.keyId = key_index; |
| 3527 | |
| 3528 | if (mac_addr) |
| 3529 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3530 | else |
| 3531 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3532 | |
| 3533 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3534 | |
| 3535 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3536 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3537 | ) |
| 3538 | { |
| 3539 | |
| 3540 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3541 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3542 | if( pHostapdState->bssState == BSS_START) |
| 3543 | { |
| 3544 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3545 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3546 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3547 | { |
| 3548 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3549 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3550 | __LINE__, status ); |
| 3551 | } |
| 3552 | } |
| 3553 | } |
| 3554 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3555 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3556 | ) |
| 3557 | { |
| 3558 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3559 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3560 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3561 | |
| 3562 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3563 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3564 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3565 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3566 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3567 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3568 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3569 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3570 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3571 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3572 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3573 | if ( 0 != status ) |
| 3574 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3575 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3576 | "%s: sme_RoamSetKey failure, returned %d", |
| 3577 | __func__, status); |
| 3578 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3579 | return -EINVAL; |
| 3580 | } |
| 3581 | } |
| 3582 | } |
| 3583 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3584 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3585 | return status; |
| 3586 | } |
| 3587 | |
| 3588 | /* |
| 3589 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3590 | * This function is used to set the default tx key index |
| 3591 | */ |
| 3592 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3593 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3594 | struct net_device *ndev, |
| 3595 | u8 key_index, |
| 3596 | bool unicast, bool multicast) |
| 3597 | #else |
| 3598 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3599 | struct net_device *ndev, |
| 3600 | u8 key_index) |
| 3601 | #endif |
| 3602 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3603 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3604 | int status = 0; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3605 | hdd_wext_state_t *pWextState; |
| 3606 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3607 | |
| 3608 | ENTER(); |
| 3609 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3610 | if ((NULL == pAdapter)) |
| 3611 | { |
| 3612 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3613 | "invalid adapter"); |
| 3614 | return -EINVAL; |
| 3615 | } |
| 3616 | |
| 3617 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3618 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3619 | |
| 3620 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3621 | { |
| 3622 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3623 | "invalid Wext state or HDD context"); |
| 3624 | return -EINVAL; |
| 3625 | } |
| 3626 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3627 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3628 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3629 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3630 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3631 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3632 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3633 | key_index); |
| 3634 | |
| 3635 | return -EINVAL; |
| 3636 | } |
| 3637 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3638 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 3639 | { |
| 3640 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3641 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3642 | return -EAGAIN; |
| 3643 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3644 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3645 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3646 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3647 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3648 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3649 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3650 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3651 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3652 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3653 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3654 | { |
| 3655 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3656 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3657 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3658 | tCsrRoamSetKey setKey; |
| 3659 | v_U32_t roamId= 0xFF; |
| 3660 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3661 | |
| 3662 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3663 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3664 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3665 | Keys->defaultIndex = (u8)key_index; |
| 3666 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3667 | setKey.keyId = key_index; |
| 3668 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3669 | |
| 3670 | vos_mem_copy(&setKey.Key[0], |
| 3671 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3672 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3673 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3674 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3675 | |
| 3676 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3677 | &pHddStaCtx->conn_info.bssId[0], |
| 3678 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3679 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3680 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3681 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3682 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3683 | { |
| 3684 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3685 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3686 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3687 | type(104) and switching encryption type to 40*/ |
| 3688 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3689 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3690 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3691 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3692 | } |
| 3693 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3694 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3695 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3696 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3697 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3698 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3699 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3700 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3701 | if ( 0 != status ) |
| 3702 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3703 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3704 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3705 | status); |
| 3706 | return -EINVAL; |
| 3707 | } |
| 3708 | } |
| 3709 | } |
| 3710 | |
| 3711 | /* In SoftAp mode setting key direction for default mode */ |
| 3712 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3713 | { |
| 3714 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3715 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3716 | (eCSR_ENCRYPT_TYPE_AES != |
| 3717 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3718 | ) |
| 3719 | { |
| 3720 | /* Saving key direction for default key index to TX default */ |
| 3721 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3722 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3723 | } |
| 3724 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3725 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3726 | return status; |
| 3727 | } |
| 3728 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3729 | /* |
| 3730 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3731 | * This function is used to inform the BSS details to nl80211 interface. |
| 3732 | */ |
| 3733 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3734 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3735 | { |
| 3736 | struct net_device *dev = pAdapter->dev; |
| 3737 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3738 | struct wiphy *wiphy = wdev->wiphy; |
| 3739 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3740 | int chan_no; |
| 3741 | int ie_length; |
| 3742 | const char *ie; |
| 3743 | unsigned int freq; |
| 3744 | struct ieee80211_channel *chan; |
| 3745 | int rssi = 0; |
| 3746 | struct cfg80211_bss *bss = NULL; |
| 3747 | |
| 3748 | ENTER(); |
| 3749 | |
| 3750 | if( NULL == pBssDesc ) |
| 3751 | { |
| 3752 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3753 | return bss; |
| 3754 | } |
| 3755 | |
| 3756 | chan_no = pBssDesc->channelId; |
| 3757 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3758 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3759 | |
| 3760 | if( NULL == ie ) |
| 3761 | { |
| 3762 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3763 | return bss; |
| 3764 | } |
| 3765 | |
| 3766 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3767 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3768 | { |
| 3769 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3770 | } |
| 3771 | else |
| 3772 | { |
| 3773 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3774 | } |
| 3775 | #else |
| 3776 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3777 | #endif |
| 3778 | |
| 3779 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3780 | |
| 3781 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3782 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3783 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3784 | if (bss == NULL) |
| 3785 | { |
| 3786 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3787 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3788 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3789 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3790 | pBssDesc->capabilityInfo, |
| 3791 | pBssDesc->beaconInterval, ie, ie_length, |
| 3792 | rssi, GFP_KERNEL )); |
| 3793 | } |
| 3794 | else |
| 3795 | { |
| 3796 | return bss; |
| 3797 | } |
| 3798 | } |
| 3799 | |
| 3800 | |
| 3801 | |
| 3802 | /* |
| 3803 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3804 | * This function is used to inform the BSS details to nl80211 interface. |
| 3805 | */ |
| 3806 | struct cfg80211_bss* |
| 3807 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3808 | tSirBssDescription *bss_desc |
| 3809 | ) |
| 3810 | { |
| 3811 | /* |
| 3812 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3813 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3814 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3815 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3816 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3817 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3818 | cfg80211_inform_bss_frame. |
| 3819 | */ |
| 3820 | struct net_device *dev = pAdapter->dev; |
| 3821 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3822 | struct wiphy *wiphy = wdev->wiphy; |
| 3823 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3824 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3825 | qcom_ie_age *qie_age = NULL; |
| 3826 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3827 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3828 | 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] | 3829 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3830 | const char *ie = |
| 3831 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3832 | unsigned int freq; |
| 3833 | struct ieee80211_channel *chan; |
| 3834 | struct ieee80211_mgmt *mgmt = |
| 3835 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 3836 | struct cfg80211_bss *bss_status = NULL; |
| 3837 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 3838 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3839 | #ifdef WLAN_OPEN_SOURCE |
| 3840 | struct timespec ts; |
| 3841 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3842 | |
| 3843 | ENTER(); |
| 3844 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 3845 | if (!mgmt) |
| 3846 | return NULL; |
| 3847 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3848 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3849 | |
| 3850 | #ifdef WLAN_OPEN_SOURCE |
| 3851 | /* Android does not want the timestamp from the frame. |
| 3852 | Instead it wants a monotonic increasing value */ |
| 3853 | get_monotonic_boottime(&ts); |
| 3854 | mgmt->u.probe_resp.timestamp = |
| 3855 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 3856 | #else |
| 3857 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3858 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 3859 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3860 | |
| 3861 | #endif |
| 3862 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3863 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 3864 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3865 | |
| 3866 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3867 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 3868 | /* Assuming this is the last IE, copy at the end */ |
| 3869 | ie_length -=sizeof(qcom_ie_age); |
| 3870 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 3871 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 3872 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 3873 | qie_age->oui_1 = QCOM_OUI1; |
| 3874 | qie_age->oui_2 = QCOM_OUI2; |
| 3875 | qie_age->oui_3 = QCOM_OUI3; |
| 3876 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 3877 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 3878 | #endif |
| 3879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3880 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
| 3881 | |
| 3882 | mgmt->frame_control |= |
| 3883 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 3884 | |
| 3885 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3886 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3887 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 3888 | { |
| 3889 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3890 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3891 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3892 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 3893 | |
| 3894 | { |
| 3895 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3896 | } |
| 3897 | else |
| 3898 | { |
| 3899 | kfree(mgmt); |
| 3900 | return NULL; |
| 3901 | } |
| 3902 | #else |
| 3903 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3904 | #endif |
| 3905 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3906 | /*when the band is changed on the fly using the GUI, three things are done |
| 3907 | * 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) |
| 3908 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 3909 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 3910 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 3911 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 3912 | * 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 |
| 3913 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 3914 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 3915 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 3916 | * So drop the bss and continue to next bss. |
| 3917 | */ |
| 3918 | if(chan == NULL) |
| 3919 | { |
| 3920 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 3921 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 3922 | return NULL; |
| 3923 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3924 | /*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] | 3925 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3926 | * */ |
| 3927 | if (( eConnectionState_Associated == |
| 3928 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 3929 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 3930 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 3931 | WNI_CFG_BSSID_LEN))) |
| 3932 | { |
| 3933 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 3934 | rssi = (pAdapter->rssi * 100); |
| 3935 | } |
| 3936 | else |
| 3937 | { |
| 3938 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 3939 | } |
| 3940 | |
| 3941 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 3942 | frame_len, rssi, GFP_KERNEL); |
| 3943 | kfree(mgmt); |
| 3944 | return bss_status; |
| 3945 | } |
| 3946 | |
| 3947 | /* |
| 3948 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 3949 | * This function is used to update the BSS data base of CFG8011 |
| 3950 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3951 | 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] | 3952 | tCsrRoamInfo *pRoamInfo |
| 3953 | ) |
| 3954 | { |
| 3955 | tCsrRoamConnectedProfile roamProfile; |
| 3956 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3957 | struct cfg80211_bss *bss = NULL; |
| 3958 | |
| 3959 | ENTER(); |
| 3960 | |
| 3961 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 3962 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 3963 | |
| 3964 | if (NULL != roamProfile.pBssDesc) |
| 3965 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3966 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3967 | &roamProfile); |
| 3968 | |
| 3969 | if (NULL == bss) |
| 3970 | { |
| 3971 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 3972 | __func__); |
| 3973 | } |
| 3974 | |
| 3975 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 3976 | } |
| 3977 | else |
| 3978 | { |
| 3979 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 3980 | __func__); |
| 3981 | } |
| 3982 | return bss; |
| 3983 | } |
| 3984 | |
| 3985 | /* |
| 3986 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 3987 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3988 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 3989 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3990 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3991 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3992 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3993 | tCsrScanResultInfo *pScanResult; |
| 3994 | eHalStatus status = 0; |
| 3995 | tScanResultHandle pResult; |
| 3996 | struct cfg80211_bss *bss_status = NULL; |
| 3997 | |
| 3998 | ENTER(); |
| 3999 | |
| 4000 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4001 | { |
| 4002 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4003 | return -EAGAIN; |
| 4004 | } |
| 4005 | |
| 4006 | /* |
| 4007 | * start getting scan results and populate cgf80211 BSS database |
| 4008 | */ |
| 4009 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4010 | |
| 4011 | /* no scan results */ |
| 4012 | if (NULL == pResult) |
| 4013 | { |
| 4014 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 4015 | return status; |
| 4016 | } |
| 4017 | |
| 4018 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4019 | |
| 4020 | while (pScanResult) |
| 4021 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4022 | /* |
| 4023 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4024 | * entry already exists in bss data base of cfg80211 for that |
| 4025 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4026 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4027 | * mgmt packet as input. As of now there is no possibility to get |
| 4028 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4029 | * ieee80211_mgmt(probe response) and passing to c |
| 4030 | * fg80211_inform_bss_frame. |
| 4031 | * */ |
| 4032 | |
| 4033 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4034 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4035 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4036 | |
| 4037 | if (NULL == bss_status) |
| 4038 | { |
| 4039 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4040 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 4041 | } |
| 4042 | else |
| 4043 | { |
| 4044 | cfg80211_put_bss(bss_status); |
| 4045 | } |
| 4046 | |
| 4047 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4048 | } |
| 4049 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4050 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4051 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4052 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4053 | } |
| 4054 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4055 | void |
| 4056 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4057 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4058 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4059 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4060 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 4061 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4062 | } /****** end hddPrintMacAddr() ******/ |
| 4063 | |
| 4064 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4065 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4066 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4067 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4068 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4069 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4070 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4071 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4072 | } /****** end hddPrintPmkId() ******/ |
| 4073 | |
| 4074 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4075 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4076 | |
| 4077 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4078 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4079 | |
| 4080 | #define dump_bssid(bssid) \ |
| 4081 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4082 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4083 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 4084 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | #define dump_pmkid(pMac, pmkid) \ |
| 4088 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4089 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4090 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4091 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4092 | } |
| 4093 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4094 | #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] | 4095 | /* |
| 4096 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4097 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4098 | */ |
| 4099 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4100 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4101 | int index, bool preauth ) |
| 4102 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4103 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4104 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4105 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4106 | |
| 4107 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4108 | 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] | 4109 | |
| 4110 | if( NULL == pRoamInfo ) |
| 4111 | { |
| 4112 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4113 | return -EINVAL; |
| 4114 | } |
| 4115 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4116 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4117 | { |
| 4118 | dump_bssid(pRoamInfo->bssid); |
| 4119 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4120 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4121 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4122 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4123 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4124 | } |
| 4125 | #endif //FEATURE_WLAN_LFR |
| 4126 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4127 | /* |
| 4128 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4129 | * scanning callback function, called after finishing scan |
| 4130 | * |
| 4131 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4132 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4133 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4134 | { |
| 4135 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4136 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4137 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4138 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4139 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4140 | struct cfg80211_scan_request *req = NULL; |
| 4141 | int ret = 0; |
| 4142 | |
| 4143 | ENTER(); |
| 4144 | |
| 4145 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4146 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4147 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4148 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4149 | |
| 4150 | //Block on scan req completion variable. Can't wait forever though. |
| 4151 | ret = wait_for_completion_interruptible_timeout( |
| 4152 | &pScanInfo->scan_req_completion_event, |
| 4153 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4154 | if (!ret) |
| 4155 | { |
| 4156 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4157 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4158 | } |
| 4159 | |
| 4160 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4161 | { |
| 4162 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4163 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4164 | } |
| 4165 | |
| 4166 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4167 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4168 | { |
| 4169 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4170 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4171 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4172 | (int) scanId); |
| 4173 | } |
| 4174 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4175 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4176 | pAdapter); |
| 4177 | |
| 4178 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4179 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4180 | |
| 4181 | |
| 4182 | /* If any client wait scan result through WEXT |
| 4183 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4184 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4185 | { |
| 4186 | /* The other scan request waiting for current scan finish |
| 4187 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4188 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4189 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4190 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4191 | } |
| 4192 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4193 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4194 | { |
| 4195 | struct net_device *dev = pAdapter->dev; |
| 4196 | union iwreq_data wrqu; |
| 4197 | int we_event; |
| 4198 | char *msg; |
| 4199 | |
| 4200 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4201 | we_event = SIOCGIWSCAN; |
| 4202 | msg = NULL; |
| 4203 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4204 | } |
| 4205 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4206 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4207 | |
| 4208 | /* Get the Scan Req */ |
| 4209 | req = pAdapter->request; |
| 4210 | |
| 4211 | if (!req) |
| 4212 | { |
| 4213 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4214 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4215 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4216 | } |
| 4217 | |
| 4218 | /* |
| 4219 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4220 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4221 | req->n_ssids = 0; |
| 4222 | req->n_channels = 0; |
| 4223 | req->ie = 0; |
| 4224 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4225 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4226 | /* Scan is no longer pending */ |
| 4227 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4228 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4229 | /* |
| 4230 | * cfg80211_scan_done informing NL80211 about completion |
| 4231 | * of scanning |
| 4232 | */ |
| 4233 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4234 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4235 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4236 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4237 | /* release the wake lock at the end of the scan*/ |
| 4238 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4239 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4240 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4241 | * immediatly after the driver gets connect request(i.e after scan) |
| 4242 | * from supplicant, this result in app's is suspending and not able |
| 4243 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4244 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4245 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4246 | #ifdef FEATURE_WLAN_TDLS |
| 4247 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4248 | #endif |
| 4249 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4250 | EXIT(); |
| 4251 | return 0; |
| 4252 | } |
| 4253 | |
| 4254 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4255 | * FUNCTION: hdd_isScanAllowed |
| 4256 | * Go through each adapter and check if scan allowed |
| 4257 | * |
| 4258 | */ |
| 4259 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4260 | { |
| 4261 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4262 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4263 | hdd_adapter_t *pAdapter = NULL; |
| 4264 | VOS_STATUS status = 0; |
| 4265 | v_U8_t staId = 0; |
| 4266 | v_U8_t *staMac = NULL; |
| 4267 | |
| 4268 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4269 | |
| 4270 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4271 | { |
| 4272 | pAdapter = pAdapterNode->pAdapter; |
| 4273 | |
| 4274 | if( pAdapter ) |
| 4275 | { |
| 4276 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4277 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4278 | __func__, pAdapter->device_mode); |
| 4279 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4280 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4281 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4282 | { |
| 4283 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4284 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4285 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4286 | { |
| 4287 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4288 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4289 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4290 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4291 | staMac[0], staMac[1], staMac[2], |
| 4292 | staMac[3], staMac[4], staMac[5]); |
| 4293 | return VOS_FALSE; |
| 4294 | } |
| 4295 | } |
| 4296 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4297 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4298 | { |
| 4299 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4300 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4301 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4302 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4303 | { |
| 4304 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4305 | |
| 4306 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4307 | "%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] | 4308 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4309 | staMac[0], staMac[1], staMac[2], |
| 4310 | staMac[3], staMac[4], staMac[5]); |
| 4311 | return VOS_FALSE; |
| 4312 | } |
| 4313 | } |
| 4314 | } |
| 4315 | } |
| 4316 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4317 | pAdapterNode = pNext; |
| 4318 | } |
| 4319 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4320 | "%s: Scan allowed", __func__); |
| 4321 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4322 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4323 | |
| 4324 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4325 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4326 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4327 | * later, scan dump command can be used to recieve scan results |
| 4328 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4329 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4330 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4331 | struct net_device *dev, |
| 4332 | #endif |
| 4333 | struct cfg80211_scan_request *request) |
| 4334 | { |
| 4335 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4336 | struct net_device *dev = request->wdev->netdev; |
| 4337 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4338 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4339 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4340 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4341 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 4342 | tCsrScanRequest scanRequest; |
| 4343 | tANI_U8 *channelList = NULL, i; |
| 4344 | v_U32_t scanId = 0; |
| 4345 | int status = 0; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4346 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4347 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4348 | |
| 4349 | ENTER(); |
| 4350 | |
| 4351 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4352 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4353 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4354 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4355 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4356 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4357 | { |
| 4358 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4359 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4360 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4361 | return -EBUSY; |
| 4362 | } |
| 4363 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4364 | #ifdef WLAN_BTAMP_FEATURE |
| 4365 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4366 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4367 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4368 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4369 | "%s: No scanning when AMP is on", __func__); |
| 4370 | return -EOPNOTSUPP; |
| 4371 | } |
| 4372 | #endif |
| 4373 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4374 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4375 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4376 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4377 | "%s: Not scanning on device_mode = %d", |
| 4378 | __func__, pAdapter->device_mode); |
| 4379 | return -EOPNOTSUPP; |
| 4380 | } |
| 4381 | |
| 4382 | if (TRUE == pScanInfo->mScanPending) |
| 4383 | { |
| 4384 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4385 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4386 | } |
| 4387 | |
| 4388 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4389 | { |
| 4390 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4391 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 4392 | return -EAGAIN; |
| 4393 | } |
| 4394 | |
Mohit Khanna | 6c52bbf | 2012-09-11 15:10:12 -0700 | [diff] [blame] | 4395 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLoadUnloadInProgress) |
| 4396 | { |
| 4397 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4398 | "%s:Unloading/Loading in Progress. Ignore!!!", __func__); |
| 4399 | return -EAGAIN; |
| 4400 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4401 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4402 | //Channel and action frame is pending |
| 4403 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4404 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4405 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4406 | { |
| 4407 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4408 | return -EBUSY; |
| 4409 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4410 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4411 | /* if tdls disagree scan right now, return immediately. |
| 4412 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4413 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4414 | */ |
| 4415 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4416 | wiphy, |
| 4417 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4418 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4419 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4420 | request); |
| 4421 | if(status <= 0) |
| 4422 | { |
| 4423 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4424 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4425 | } |
| 4426 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4427 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4428 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4429 | { |
| 4430 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4431 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4432 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4433 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4434 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4435 | { |
| 4436 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4437 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4438 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4439 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4440 | } |
| 4441 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4442 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4443 | /* Check if scan is allowed at this point of time. |
| 4444 | */ |
| 4445 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4446 | { |
| 4447 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4448 | return -EBUSY; |
| 4449 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4450 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4451 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4452 | |
| 4453 | if (NULL != request) |
| 4454 | { |
| 4455 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4456 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4457 | |
| 4458 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4459 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4460 | * is not aging out the scan results. |
| 4461 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4462 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4463 | { |
| 4464 | request->n_ssids = 0; |
| 4465 | } |
| 4466 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4467 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4468 | { |
| 4469 | tCsrSSIDInfo *SsidInfo; |
| 4470 | int j; |
| 4471 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4472 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4473 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4474 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4475 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4476 | |
| 4477 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4478 | { |
| 4479 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4480 | "memory alloc failed SSIDInfo buffer"); |
| 4481 | return -ENOMEM; |
| 4482 | } |
| 4483 | |
| 4484 | /* copy all the ssid's and their length */ |
| 4485 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4486 | { |
| 4487 | /* get the ssid length */ |
| 4488 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4489 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4490 | SsidInfo->SSID.length); |
| 4491 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4492 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4493 | j, SsidInfo->SSID.ssId); |
| 4494 | } |
| 4495 | /* set the scan type to active */ |
| 4496 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4497 | } |
| 4498 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4499 | { |
| 4500 | /* set the scan type to active */ |
| 4501 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4502 | } |
| 4503 | else |
| 4504 | { |
| 4505 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4506 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4507 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4508 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4509 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4510 | } |
| 4511 | else |
| 4512 | { |
| 4513 | /* set the scan type to active */ |
| 4514 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4515 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4516 | |
| 4517 | /* set min and max channel time to zero */ |
| 4518 | scanRequest.minChnTime = 0; |
| 4519 | scanRequest.maxChnTime = 0; |
| 4520 | } |
| 4521 | |
| 4522 | /* set BSSType to default type */ |
| 4523 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4524 | |
| 4525 | /*TODO: scan the requested channels only*/ |
| 4526 | |
| 4527 | /*Right now scanning all the channels */ |
| 4528 | if( request ) |
| 4529 | { |
| 4530 | if( request->n_channels ) |
| 4531 | { |
| 4532 | channelList = vos_mem_malloc( request->n_channels ); |
| 4533 | if( NULL == channelList ) |
| 4534 | { |
| 4535 | status = -ENOMEM; |
| 4536 | goto free_mem; |
| 4537 | } |
| 4538 | |
| 4539 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4540 | channelList[i] = request->channels[i]->hw_value; |
| 4541 | } |
| 4542 | |
| 4543 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4544 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4545 | |
| 4546 | /* set requestType to full scan */ |
| 4547 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4548 | |
| 4549 | /* 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] | 4550 | * 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] | 4551 | * 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] | 4552 | */ |
| 4553 | |
| 4554 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4555 | * and in that case driver shoudnt flush scan results. If |
| 4556 | * driver flushes the scan results here and unfortunately if |
| 4557 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4558 | * fails which is not desired |
| 4559 | */ |
| 4560 | |
| 4561 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4562 | { |
| 4563 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4564 | pAdapter->sessionId ); |
| 4565 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4566 | |
| 4567 | if( request->ie_len ) |
| 4568 | { |
| 4569 | /* save this for future association (join requires this) */ |
| 4570 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4571 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4572 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4573 | |
| 4574 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4575 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4576 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4577 | ) |
| 4578 | { |
| 4579 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4580 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4581 | } |
| 4582 | |
| 4583 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4584 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4585 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4586 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4587 | request->ie_len); |
| 4588 | if (pP2pIe != NULL) |
| 4589 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4590 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4591 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4592 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4593 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4594 | { |
| 4595 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4596 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4597 | "Go nego completed to Connection is started"); |
| 4598 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4599 | "for 8way Handshake"); |
| 4600 | } |
| 4601 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4602 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4603 | { |
| 4604 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4605 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4606 | "Disconnected state to Connection is started"); |
| 4607 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4608 | "for 4way Handshake"); |
| 4609 | } |
| 4610 | #endif |
| 4611 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4612 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4613 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4614 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4615 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4616 | "%s: This is a P2P Search", __func__); |
| 4617 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4618 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4619 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4620 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4621 | /* set requestType to P2P Discovery */ |
| 4622 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4623 | } |
| 4624 | |
| 4625 | /* |
| 4626 | Skip Dfs Channel in case of P2P Search |
| 4627 | if it is set in ini file |
| 4628 | */ |
| 4629 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4630 | { |
| 4631 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4632 | } |
| 4633 | else |
| 4634 | { |
| 4635 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4636 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4637 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4638 | } |
| 4639 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4640 | } |
| 4641 | } |
| 4642 | |
| 4643 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4644 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4645 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4646 | * address the following issues. |
| 4647 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4648 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4649 | * for long time, this result in apps running at full power for long time. |
| 4650 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4651 | * be stuck in full power because of resume BMPS |
| 4652 | */ |
| 4653 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4654 | |
| 4655 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4656 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4657 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4658 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4659 | if (eHAL_STATUS_SUCCESS != status) |
| 4660 | { |
| 4661 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4662 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4663 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4664 | if(eHAL_STATUS_RESOURCES == status) |
| 4665 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4666 | 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] | 4667 | status = -EBUSY; |
| 4668 | } else { |
| 4669 | status = -EIO; |
| 4670 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4671 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4672 | goto free_mem; |
| 4673 | } |
| 4674 | |
| 4675 | pScanInfo->mScanPending = TRUE; |
| 4676 | pAdapter->request = request; |
| 4677 | pScanInfo->scanId = scanId; |
| 4678 | |
| 4679 | complete(&pScanInfo->scan_req_completion_event); |
| 4680 | |
| 4681 | free_mem: |
| 4682 | if( scanRequest.SSIDs.SSIDList ) |
| 4683 | { |
| 4684 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4685 | } |
| 4686 | |
| 4687 | if( channelList ) |
| 4688 | vos_mem_free( channelList ); |
| 4689 | |
| 4690 | EXIT(); |
| 4691 | |
| 4692 | return status; |
| 4693 | } |
| 4694 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4695 | |
| 4696 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 4697 | { |
| 4698 | v_U8_t iniDot11Mode = |
| 4699 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 4700 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 4701 | |
| 4702 | switch ( iniDot11Mode ) |
| 4703 | { |
| 4704 | case eHDD_DOT11_MODE_AUTO: |
| 4705 | case eHDD_DOT11_MODE_11ac: |
| 4706 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 4707 | #ifdef WLAN_FEATURE_11AC |
| 4708 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 4709 | #else |
| 4710 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4711 | #endif |
| 4712 | break; |
| 4713 | case eHDD_DOT11_MODE_11n: |
| 4714 | case eHDD_DOT11_MODE_11n_ONLY: |
| 4715 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4716 | break; |
| 4717 | default: |
| 4718 | hddDot11Mode = iniDot11Mode; |
| 4719 | break; |
| 4720 | } |
| 4721 | /* This call decides required channel bonding mode */ |
| 4722 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 4723 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 4724 | operationChannel); |
| 4725 | } |
| 4726 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4727 | /* |
| 4728 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4729 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4730 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4731 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4732 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4733 | { |
| 4734 | int status = 0; |
| 4735 | hdd_wext_state_t *pWextState; |
| 4736 | v_U32_t roamId; |
| 4737 | tCsrRoamProfile *pRoamProfile; |
| 4738 | eMib_dot11DesiredBssType connectedBssType; |
| 4739 | eCsrAuthType RSNAuthType; |
| 4740 | |
| 4741 | ENTER(); |
| 4742 | |
| 4743 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4744 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4745 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4746 | { |
| 4747 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4748 | return -EINVAL; |
| 4749 | } |
| 4750 | |
| 4751 | pRoamProfile = &pWextState->roamProfile; |
| 4752 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4753 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4754 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4755 | int ret = 0; |
| 4756 | hdd_station_ctx_t *pHddStaCtx; |
| 4757 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4758 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4759 | |
| 4760 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4761 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4762 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4763 | { |
| 4764 | /* Issue disconnect to CSR */ |
| 4765 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4766 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4767 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4768 | pAdapter->sessionId, |
| 4769 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4770 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4771 | ret = wait_for_completion_interruptible_timeout( |
| 4772 | &pAdapter->disconnect_comp_var, |
| 4773 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4774 | if (0 == ret) |
| 4775 | { |
| 4776 | VOS_ASSERT(0); |
| 4777 | } |
| 4778 | } |
| 4779 | } |
| 4780 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4781 | { |
| 4782 | ret = wait_for_completion_interruptible_timeout( |
| 4783 | &pAdapter->disconnect_comp_var, |
| 4784 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4785 | if (0 == ret) |
| 4786 | { |
| 4787 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4788 | } |
| 4789 | } |
| 4790 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4791 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4792 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4793 | { |
| 4794 | /*QoS not enabled in cfg file*/ |
| 4795 | pRoamProfile->uapsd_mask = 0; |
| 4796 | } |
| 4797 | else |
| 4798 | { |
| 4799 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4800 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4801 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4802 | } |
| 4803 | |
| 4804 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4805 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4806 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4807 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4808 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4809 | ssid, ssid_len); |
| 4810 | |
| 4811 | if (bssid) |
| 4812 | { |
| 4813 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4814 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4815 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4816 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4817 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4818 | case of join failure we should send valid BSSID to supplicant |
| 4819 | */ |
| 4820 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4821 | WNI_CFG_BSSID_LEN); |
| 4822 | } |
| 4823 | |
| 4824 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 4825 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4826 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4827 | /*set gen ie*/ |
| 4828 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 4829 | /*set auth*/ |
| 4830 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 4831 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4832 | #ifdef FEATURE_WLAN_WAPI |
| 4833 | if (pAdapter->wapi_info.nWapiMode) |
| 4834 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4835 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4836 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 4837 | { |
| 4838 | case WAPI_AUTH_MODE_PSK: |
| 4839 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4840 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4841 | pAdapter->wapi_info.wapiAuthMode); |
| 4842 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 4843 | break; |
| 4844 | } |
| 4845 | case WAPI_AUTH_MODE_CERT: |
| 4846 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4847 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4848 | pAdapter->wapi_info.wapiAuthMode); |
| 4849 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 4850 | break; |
| 4851 | } |
| 4852 | } // End of switch |
| 4853 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 4854 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 4855 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4856 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4857 | pRoamProfile->AuthType.numEntries = 1; |
| 4858 | pRoamProfile->EncryptionType.numEntries = 1; |
| 4859 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4860 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 4861 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 4862 | } |
| 4863 | } |
| 4864 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 4865 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 4866 | /* Initializing gtkOffloadRequestParams */ |
| 4867 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4868 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4869 | { |
| 4870 | pHddStaCtx->gtkOffloadRequestParams.requested = FALSE; |
| 4871 | memset(&pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams, |
| 4872 | 0, sizeof (tSirGtkOffloadParams)); |
| 4873 | } |
| 4874 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4875 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 4876 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4877 | if( operatingChannel ) |
| 4878 | { |
| 4879 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 4880 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 4881 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 4882 | else |
| 4883 | { |
| 4884 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4885 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4886 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4887 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 4888 | { |
| 4889 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 4890 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4891 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 4892 | * 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] | 4893 | * 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] | 4894 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4895 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 4896 | */ |
| 4897 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 4898 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 4899 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4900 | |
| 4901 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4902 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 4903 | |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4904 | if( (eHAL_STATUS_SUCCESS != status) && |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4905 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 4906 | |
| 4907 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4908 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 4909 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 4910 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4911 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4912 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 4913 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 4914 | |
| 4915 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 4916 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 4917 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4918 | } |
| 4919 | else |
| 4920 | { |
| 4921 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 4922 | return -EINVAL; |
| 4923 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4924 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4925 | return status; |
| 4926 | } |
| 4927 | |
| 4928 | /* |
| 4929 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 4930 | * This function is used to set the authentication type (OPEN/SHARED). |
| 4931 | * |
| 4932 | */ |
| 4933 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 4934 | enum nl80211_auth_type auth_type) |
| 4935 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4936 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4937 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4938 | |
| 4939 | ENTER(); |
| 4940 | |
| 4941 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4942 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4943 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4944 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4945 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4946 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 4947 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 4948 | break; |
| 4949 | |
| 4950 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 4951 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4952 | case NL80211_AUTHTYPE_FT: |
| 4953 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4954 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4955 | "%s: set authentication type to OPEN", __func__); |
| 4956 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 4957 | break; |
| 4958 | |
| 4959 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4960 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4961 | "%s: set authentication type to SHARED", __func__); |
| 4962 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 4963 | break; |
| 4964 | #ifdef FEATURE_WLAN_CCX |
| 4965 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4966 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4967 | "%s: set authentication type to CCKM WPA", __func__); |
| 4968 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 4969 | break; |
| 4970 | #endif |
| 4971 | |
| 4972 | |
| 4973 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4974 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4975 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4976 | auth_type); |
| 4977 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 4978 | return -EINVAL; |
| 4979 | } |
| 4980 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4981 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4982 | pHddStaCtx->conn_info.authType; |
| 4983 | return 0; |
| 4984 | } |
| 4985 | |
| 4986 | /* |
| 4987 | * FUNCTION: wlan_hdd_set_akm_suite |
| 4988 | * This function is used to set the key mgmt type(PSK/8021x). |
| 4989 | * |
| 4990 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4991 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4992 | u32 key_mgmt |
| 4993 | ) |
| 4994 | { |
| 4995 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4996 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4997 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4998 | /*set key mgmt type*/ |
| 4999 | switch(key_mgmt) |
| 5000 | { |
| 5001 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5002 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5003 | case WLAN_AKM_SUITE_FT_PSK: |
| 5004 | #endif |
| 5005 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5006 | __func__); |
| 5007 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5008 | break; |
| 5009 | |
| 5010 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5011 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5012 | case WLAN_AKM_SUITE_FT_8021X: |
| 5013 | #endif |
| 5014 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5015 | __func__); |
| 5016 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5017 | break; |
| 5018 | #ifdef FEATURE_WLAN_CCX |
| 5019 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5020 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5021 | case WLAN_AKM_SUITE_CCKM: |
| 5022 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5023 | __func__); |
| 5024 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5025 | break; |
| 5026 | #endif |
| 5027 | |
| 5028 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5029 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5030 | __func__, key_mgmt); |
| 5031 | return -EINVAL; |
| 5032 | |
| 5033 | } |
| 5034 | return 0; |
| 5035 | } |
| 5036 | |
| 5037 | /* |
| 5038 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5039 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5040 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5041 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5042 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5043 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5044 | bool ucast |
| 5045 | ) |
| 5046 | { |
| 5047 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5048 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5049 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5050 | |
| 5051 | ENTER(); |
| 5052 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5053 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5054 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5055 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5056 | __func__, cipher); |
| 5057 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5058 | } |
| 5059 | else |
| 5060 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5061 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5062 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5063 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5064 | { |
| 5065 | case IW_AUTH_CIPHER_NONE: |
| 5066 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5067 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5068 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5069 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5070 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5071 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5072 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5073 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5074 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5075 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5076 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5077 | case WLAN_CIPHER_SUITE_TKIP: |
| 5078 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5079 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5080 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5081 | case WLAN_CIPHER_SUITE_CCMP: |
| 5082 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5083 | break; |
| 5084 | #ifdef FEATURE_WLAN_WAPI |
| 5085 | case WLAN_CIPHER_SUITE_SMS4: |
| 5086 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5087 | break; |
| 5088 | #endif |
| 5089 | |
| 5090 | #ifdef FEATURE_WLAN_CCX |
| 5091 | case WLAN_CIPHER_SUITE_KRK: |
| 5092 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5093 | break; |
| 5094 | #endif |
| 5095 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5096 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5097 | __func__, cipher); |
| 5098 | return -EOPNOTSUPP; |
| 5099 | } |
| 5100 | } |
| 5101 | |
| 5102 | if (ucast) |
| 5103 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5104 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5105 | __func__, encryptionType); |
| 5106 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5107 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5108 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | encryptionType; |
| 5110 | } |
| 5111 | else |
| 5112 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5113 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5114 | __func__, encryptionType); |
| 5115 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5116 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5117 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5118 | } |
| 5119 | |
| 5120 | return 0; |
| 5121 | } |
| 5122 | |
| 5123 | |
| 5124 | /* |
| 5125 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5126 | * This function is used to parse WPA/RSN IE's. |
| 5127 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5128 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5129 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5130 | size_t ie_len |
| 5131 | ) |
| 5132 | { |
| 5133 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5134 | u8 *genie = ie; |
| 5135 | v_U16_t remLen = ie_len; |
| 5136 | #ifdef FEATURE_WLAN_WAPI |
| 5137 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5138 | u16 *tmp; |
| 5139 | v_U16_t akmsuiteCount; |
| 5140 | int *akmlist; |
| 5141 | #endif |
| 5142 | ENTER(); |
| 5143 | |
| 5144 | /* clear previous assocAddIE */ |
| 5145 | pWextState->assocAddIE.length = 0; |
| 5146 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5147 | |
| 5148 | while (remLen >= 2) |
| 5149 | { |
| 5150 | v_U16_t eLen = 0; |
| 5151 | v_U8_t elementId; |
| 5152 | elementId = *genie++; |
| 5153 | eLen = *genie++; |
| 5154 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5155 | |
| 5156 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5157 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5158 | |
| 5159 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5160 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5161 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5162 | 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] | 5163 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5164 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5165 | "%s: Invalid WPA IE", __func__); |
| 5166 | return -EINVAL; |
| 5167 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5168 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5169 | { |
| 5170 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5171 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5172 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5173 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5174 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5175 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5176 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5177 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5178 | VOS_ASSERT(0); |
| 5179 | return -ENOMEM; |
| 5180 | } |
| 5181 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5182 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5183 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5184 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5185 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5186 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5187 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5188 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5189 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5190 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5191 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5192 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5193 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5194 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5195 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5196 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5197 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5198 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5199 | /*Consider P2P IE, only for P2P Client */ |
| 5200 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5201 | { |
| 5202 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5203 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5204 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5205 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5206 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5207 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5208 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5209 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5210 | VOS_ASSERT(0); |
| 5211 | return -ENOMEM; |
| 5212 | } |
| 5213 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5214 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5215 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5216 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5217 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5218 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5219 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5220 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5221 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5222 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5223 | /*Consider WFD IE, only for P2P Client */ |
| 5224 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5225 | { |
| 5226 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5227 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5228 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5229 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5230 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5231 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5232 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5233 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5234 | VOS_ASSERT(0); |
| 5235 | return -ENOMEM; |
| 5236 | } |
| 5237 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5238 | // WPS IE + P2P IE + WFD IE |
| 5239 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5240 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5241 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5242 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5243 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5244 | } |
| 5245 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5246 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5247 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5248 | HS20_OUI_TYPE_SIZE)) ) |
| 5249 | { |
| 5250 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5251 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5252 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5253 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5254 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5255 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5256 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5257 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5258 | VOS_ASSERT(0); |
| 5259 | return -ENOMEM; |
| 5260 | } |
| 5261 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5262 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5263 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5264 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5265 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5266 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5268 | break; |
| 5269 | case DOT11F_EID_RSN: |
| 5270 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5271 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5272 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5273 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5274 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5275 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5276 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5277 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5278 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5279 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5280 | 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] | 5281 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5282 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5283 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5284 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5285 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5286 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5287 | VOS_ASSERT(0); |
| 5288 | return -ENOMEM; |
| 5289 | } |
| 5290 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5291 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5292 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5293 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5294 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5295 | break; |
| 5296 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5297 | #ifdef FEATURE_WLAN_WAPI |
| 5298 | case WLAN_EID_WAPI: |
| 5299 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5300 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5301 | pAdapter->wapi_info.nWapiMode); |
| 5302 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5303 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5304 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5305 | tmp = tmp + 1; |
| 5306 | akmlist = (int *)(tmp); |
| 5307 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5308 | { |
| 5309 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5310 | } |
| 5311 | else |
| 5312 | { |
| 5313 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5314 | VOS_ASSERT(0); |
| 5315 | return -EINVAL; |
| 5316 | } |
| 5317 | |
| 5318 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5319 | { |
| 5320 | 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] | 5321 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5322 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5323 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5324 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5325 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5326 | 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] | 5327 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5328 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5329 | } |
| 5330 | break; |
| 5331 | #endif |
| 5332 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5333 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5334 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5335 | /* when Unknown IE is received we should break and continue |
| 5336 | * to the next IE in the buffer instead we were returning |
| 5337 | * so changing this to break */ |
| 5338 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5339 | } |
| 5340 | genie += eLen; |
| 5341 | remLen -= eLen; |
| 5342 | } |
| 5343 | EXIT(); |
| 5344 | return 0; |
| 5345 | } |
| 5346 | |
| 5347 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5348 | * FUNCTION: hdd_isWPAIEPresent |
| 5349 | * Parse the received IE to find the WPA IE |
| 5350 | * |
| 5351 | */ |
| 5352 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5353 | { |
| 5354 | v_U8_t eLen = 0; |
| 5355 | v_U16_t remLen = ie_len; |
| 5356 | v_U8_t elementId = 0; |
| 5357 | |
| 5358 | while (remLen >= 2) |
| 5359 | { |
| 5360 | elementId = *ie++; |
| 5361 | eLen = *ie++; |
| 5362 | remLen -= 2; |
| 5363 | if (eLen > remLen) |
| 5364 | { |
| 5365 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5366 | "%s: IE length is wrong %d", __func__, eLen); |
| 5367 | return FALSE; |
| 5368 | } |
| 5369 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5370 | { |
| 5371 | /* OUI - 0x00 0X50 0XF2 |
| 5372 | WPA Information Element - 0x01 |
| 5373 | WPA version - 0x01*/ |
| 5374 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5375 | return TRUE; |
| 5376 | } |
| 5377 | ie += eLen; |
| 5378 | remLen -= eLen; |
| 5379 | } |
| 5380 | return FALSE; |
| 5381 | } |
| 5382 | |
| 5383 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5384 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5385 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5386 | * parameters during connect operation. |
| 5387 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5388 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | struct cfg80211_connect_params *req |
| 5390 | ) |
| 5391 | { |
| 5392 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5393 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5394 | ENTER(); |
| 5395 | |
| 5396 | /*set wpa version*/ |
| 5397 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5398 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5399 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5400 | { |
| 5401 | if ( (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5402 | && ( (req->ie_len) |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5403 | && (hdd_isWPAIEPresent(req->ie, req->ie_len) ) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5404 | // Make sure that it is including a WPA IE. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5405 | /* Currently NL is putting WPA version 1 even for open, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5406 | * since p2p ie is also put in same buffer. |
| 5407 | * */ |
| 5408 | { |
| 5409 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5410 | } |
| 5411 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5412 | { |
| 5413 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5414 | } |
| 5415 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5416 | |
| 5417 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5418 | pWextState->wpaVersion); |
| 5419 | |
| 5420 | /*set authentication type*/ |
| 5421 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5422 | |
| 5423 | if (0 > status) |
| 5424 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5425 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5426 | "%s: failed to set authentication type ", __func__); |
| 5427 | return status; |
| 5428 | } |
| 5429 | |
| 5430 | /*set key mgmt type*/ |
| 5431 | if (req->crypto.n_akm_suites) |
| 5432 | { |
| 5433 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5434 | if (0 > status) |
| 5435 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5436 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5437 | __func__); |
| 5438 | return status; |
| 5439 | } |
| 5440 | } |
| 5441 | |
| 5442 | /*set pairwise cipher type*/ |
| 5443 | if (req->crypto.n_ciphers_pairwise) |
| 5444 | { |
| 5445 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5446 | req->crypto.ciphers_pairwise[0], true); |
| 5447 | if (0 > status) |
| 5448 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5449 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5450 | "%s: failed to set unicast cipher type", __func__); |
| 5451 | return status; |
| 5452 | } |
| 5453 | } |
| 5454 | else |
| 5455 | { |
| 5456 | /*Reset previous cipher suite to none*/ |
| 5457 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5458 | if (0 > status) |
| 5459 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5460 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5461 | "%s: failed to set unicast cipher type", __func__); |
| 5462 | return status; |
| 5463 | } |
| 5464 | } |
| 5465 | |
| 5466 | /*set group cipher type*/ |
| 5467 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5468 | false); |
| 5469 | |
| 5470 | if (0 > status) |
| 5471 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5472 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5473 | __func__); |
| 5474 | return status; |
| 5475 | } |
| 5476 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5477 | #ifdef WLAN_FEATURE_11W |
| 5478 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5479 | #endif |
| 5480 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5481 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5482 | if (req->ie_len) |
| 5483 | { |
| 5484 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5485 | if ( 0 > status) |
| 5486 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5487 | 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] | 5488 | __func__); |
| 5489 | return status; |
| 5490 | } |
| 5491 | } |
| 5492 | |
| 5493 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5494 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5495 | { |
| 5496 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5497 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5498 | ) |
| 5499 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5500 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5501 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5502 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5503 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5504 | __func__); |
| 5505 | return -EOPNOTSUPP; |
| 5506 | } |
| 5507 | else |
| 5508 | { |
| 5509 | u8 key_len = req->key_len; |
| 5510 | u8 key_idx = req->key_idx; |
| 5511 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5512 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5513 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5514 | ) |
| 5515 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5516 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5517 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5518 | __func__, key_idx, key_len); |
| 5519 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5520 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5521 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5522 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5523 | (u8)key_len; |
| 5524 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5525 | } |
| 5526 | } |
| 5527 | } |
| 5528 | } |
| 5529 | |
| 5530 | return status; |
| 5531 | } |
| 5532 | |
| 5533 | /* |
| 5534 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5535 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5536 | * parameters during connect operation. |
| 5537 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5538 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5539 | struct net_device *ndev, |
| 5540 | struct cfg80211_connect_params *req |
| 5541 | ) |
| 5542 | { |
| 5543 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5544 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5545 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5546 | hdd_context_t *pHddCtx = NULL; |
| 5547 | |
| 5548 | ENTER(); |
| 5549 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5550 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5551 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5552 | |
| 5553 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5554 | { |
| 5555 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5556 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5557 | return -EAGAIN; |
| 5558 | } |
| 5559 | |
| 5560 | #ifdef WLAN_BTAMP_FEATURE |
| 5561 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5562 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5563 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5564 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5565 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5566 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5567 | } |
| 5568 | #endif |
| 5569 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5570 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5571 | |
| 5572 | if ( 0 > status) |
| 5573 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5574 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5575 | __func__); |
| 5576 | return status; |
| 5577 | } |
| 5578 | |
| 5579 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5580 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5581 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5582 | (vos_concurrent_sessions_running())) |
| 5583 | { |
| 5584 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 5585 | |
| 5586 | if (NULL != pVosContext) |
| 5587 | { |
| 5588 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 5589 | if(NULL != pHddCtx) |
| 5590 | { |
| 5591 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 5592 | } |
| 5593 | } |
| 5594 | } |
| 5595 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5596 | if ( req->channel ) |
| 5597 | { |
| 5598 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5599 | req->ssid_len, req->bssid, |
| 5600 | req->channel->hw_value); |
| 5601 | } |
| 5602 | else |
| 5603 | { |
| 5604 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5605 | req->ssid_len, req->bssid, |
| 5606 | 0); |
| 5607 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5608 | |
| 5609 | if (0 > status) |
| 5610 | { |
| 5611 | //ReEnable BMPS if disabled |
| 5612 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5613 | (NULL != pHddCtx)) |
| 5614 | { |
| 5615 | //ReEnable Bmps and Imps back |
| 5616 | hdd_enable_bmps_imps(pHddCtx); |
| 5617 | } |
| 5618 | |
| 5619 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5620 | return status; |
| 5621 | } |
| 5622 | (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE; |
| 5623 | EXIT(); |
| 5624 | return status; |
| 5625 | } |
| 5626 | |
| 5627 | |
| 5628 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5629 | * FUNCTION: wlan_hdd_disconnect |
| 5630 | * This function is used to issue a disconnect request to SME |
| 5631 | */ |
| 5632 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 5633 | { |
| 5634 | int status = 0; |
| 5635 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5636 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5637 | (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_TRUE; |
| 5638 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5639 | /*issue disconnect*/ |
| 5640 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5641 | pAdapter->sessionId, reason); |
| 5642 | |
| 5643 | if ( 0 != status ) |
| 5644 | { |
| 5645 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5646 | "%s csrRoamDisconnect failure, returned %d \n", |
| 5647 | __func__, (int)status ); |
| 5648 | return -EINVAL; |
| 5649 | } |
| 5650 | wait_for_completion_interruptible_timeout( |
| 5651 | &pAdapter->disconnect_comp_var, |
| 5652 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5653 | /*stop tx queues*/ |
| 5654 | netif_tx_disable(pAdapter->dev); |
| 5655 | netif_carrier_off(pAdapter->dev); |
| 5656 | return status; |
| 5657 | } |
| 5658 | |
| 5659 | |
| 5660 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5661 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5662 | * This function is used to issue a disconnect request to SME |
| 5663 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5664 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5665 | struct net_device *dev, |
| 5666 | u16 reason |
| 5667 | ) |
| 5668 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5669 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5670 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5671 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
| 5672 | int status = 0; |
| 5673 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5674 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5675 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5676 | tANI_U8 staIdx; |
| 5677 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5678 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5679 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5680 | |
| 5681 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5682 | __func__,pAdapter->device_mode); |
| 5683 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5684 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5685 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5686 | |
| 5687 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 5688 | { |
| 5689 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5690 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 5691 | return -EAGAIN; |
| 5692 | } |
| 5693 | if (NULL != pRoamProfile) |
| 5694 | { |
| 5695 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5696 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5697 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5698 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5699 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5700 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5701 | switch(reason) |
| 5702 | { |
| 5703 | case WLAN_REASON_MIC_FAILURE: |
| 5704 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5705 | break; |
| 5706 | |
| 5707 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5708 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5709 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5710 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5711 | break; |
| 5712 | |
| 5713 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5714 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5715 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5716 | break; |
| 5717 | |
| 5718 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5719 | default: |
| 5720 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5721 | break; |
| 5722 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5723 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5724 | pScanInfo = &pHddCtx->scan_info; |
| 5725 | if (pScanInfo->mScanPending) |
| 5726 | { |
| 5727 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 5728 | "Aborting Scan"); |
| 5729 | hdd_abort_mac_scan(pHddCtx); |
| 5730 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5731 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5732 | #ifdef FEATURE_WLAN_TDLS |
| 5733 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5734 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5735 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5736 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5737 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5738 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5739 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5740 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5741 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5742 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5743 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5744 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5745 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5746 | pAdapter->sessionId, |
| 5747 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5748 | } |
| 5749 | } |
| 5750 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5751 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 5752 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5753 | { |
| 5754 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5755 | "%s wlan_hdd_disconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5756 | __func__, (int)status ); |
| 5757 | return -EINVAL; |
| 5758 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5759 | } |
| 5760 | } |
| 5761 | else |
| 5762 | { |
| 5763 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5764 | } |
| 5765 | |
| 5766 | return status; |
| 5767 | } |
| 5768 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5769 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5770 | /* |
| 5771 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5772 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5773 | * settings in IBSS mode. |
| 5774 | */ |
| 5775 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5776 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5777 | struct cfg80211_ibss_params *params |
| 5778 | ) |
| 5779 | { |
| 5780 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5781 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5782 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5783 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5784 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5785 | ENTER(); |
| 5786 | |
| 5787 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5788 | |
| 5789 | if (params->ie_len && ( NULL != params->ie) ) |
| 5790 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5791 | if (WLAN_EID_RSN == params->ie[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5792 | { |
| 5793 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5794 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5795 | } |
| 5796 | else |
| 5797 | { |
| 5798 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5799 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5800 | } |
| 5801 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 5802 | |
| 5803 | if (0 > status) |
| 5804 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5805 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5806 | __func__); |
| 5807 | return status; |
| 5808 | } |
| 5809 | } |
| 5810 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5811 | pWextState->roamProfile.AuthType.authType[0] = |
| 5812 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5813 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5814 | |
| 5815 | if (params->privacy) |
| 5816 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5817 | /* Security enabled IBSS, At this time there is no information available |
| 5818 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5819 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5820 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5821 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5822 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5823 | *enable privacy bit in beacons */ |
| 5824 | |
| 5825 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5826 | } |
| 5827 | |
| 5828 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5829 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 5830 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
| 5831 | |
| 5832 | return status; |
| 5833 | } |
| 5834 | |
| 5835 | /* |
| 5836 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5837 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5838 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5839 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5840 | struct net_device *dev, |
| 5841 | struct cfg80211_ibss_params *params |
| 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 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5845 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5846 | tCsrRoamProfile *pRoamProfile; |
| 5847 | int status; |
| 5848 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5849 | |
| 5850 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5851 | |
| 5852 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5853 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5854 | |
| 5855 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5856 | { |
| 5857 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5858 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5859 | return -EAGAIN; |
| 5860 | } |
| 5861 | |
| 5862 | if (NULL == pWextState) |
| 5863 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5864 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5865 | __func__); |
| 5866 | return -EIO; |
| 5867 | } |
| 5868 | |
| 5869 | pRoamProfile = &pWextState->roamProfile; |
| 5870 | |
| 5871 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 5872 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5873 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5874 | "%s Interface type is not set to IBSS \n", __func__); |
| 5875 | return -EINVAL; |
| 5876 | } |
| 5877 | |
| 5878 | /* Set Channel */ |
| 5879 | if (NULL != params->channel) |
| 5880 | { |
| 5881 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5882 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 5883 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5884 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5885 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5886 | |
| 5887 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5888 | channelNum = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5889 | ieee80211_frequency_to_channel(params->channel->center_freq); |
| 5890 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5891 | |
| 5892 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 5893 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5894 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5895 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 5896 | __func__); |
| 5897 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5898 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5899 | |
| 5900 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5901 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5902 | if (channelNum == validChan[indx]) |
| 5903 | { |
| 5904 | break; |
| 5905 | } |
| 5906 | } |
| 5907 | if (indx >= numChans) |
| 5908 | { |
| 5909 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5910 | __func__, channelNum); |
| 5911 | return -EINVAL; |
| 5912 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5913 | /* Set the Operational Channel */ |
| 5914 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 5915 | channelNum); |
| 5916 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5917 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 5918 | pRoamProfile->ChannelInfo.ChannelList = |
| 5919 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5920 | } |
| 5921 | |
| 5922 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5923 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5924 | if (status < 0) |
| 5925 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5926 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5927 | __func__); |
| 5928 | return status; |
| 5929 | } |
| 5930 | |
| 5931 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5932 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5933 | params->ssid_len, params->bssid, |
| 5934 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5935 | |
| 5936 | if (0 > status) |
| 5937 | { |
| 5938 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5939 | return status; |
| 5940 | } |
| 5941 | |
| 5942 | return 0; |
| 5943 | } |
| 5944 | |
| 5945 | /* |
| 5946 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5947 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5948 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5949 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5950 | struct net_device *dev |
| 5951 | ) |
| 5952 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5953 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5954 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5955 | tCsrRoamProfile *pRoamProfile; |
| 5956 | |
| 5957 | ENTER(); |
| 5958 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5959 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 5960 | { |
| 5961 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5962 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 5963 | return -EAGAIN; |
| 5964 | } |
| 5965 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5966 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5967 | if (NULL == pWextState) |
| 5968 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5969 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5970 | __func__); |
| 5971 | return -EIO; |
| 5972 | } |
| 5973 | |
| 5974 | pRoamProfile = &pWextState->roamProfile; |
| 5975 | |
| 5976 | /* Issue disconnect only if interface type is set to IBSS */ |
| 5977 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 5978 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5979 | 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] | 5980 | __func__); |
| 5981 | return -EINVAL; |
| 5982 | } |
| 5983 | |
| 5984 | /* Issue Disconnect request */ |
| 5985 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5986 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 5987 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 5988 | |
| 5989 | return 0; |
| 5990 | } |
| 5991 | |
| 5992 | /* |
| 5993 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 5994 | * This function is used to set the phy parameters |
| 5995 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 5996 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5997 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5998 | u32 changed) |
| 5999 | { |
| 6000 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6001 | tHalHandle hHal = pHddCtx->hHal; |
| 6002 | |
| 6003 | ENTER(); |
| 6004 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6005 | if ( pHddCtx->isLogpInProgress ) |
| 6006 | { |
| 6007 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6008 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6009 | return -EAGAIN; |
| 6010 | } |
| 6011 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6012 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6013 | { |
| 6014 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6015 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6016 | wiphy->rts_threshold; |
| 6017 | |
| 6018 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6019 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6020 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6021 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6022 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6023 | __func__, rts_threshold); |
| 6024 | return -EINVAL; |
| 6025 | } |
| 6026 | |
| 6027 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6028 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6029 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6030 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6031 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6032 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6033 | __func__, rts_threshold); |
| 6034 | return -EIO; |
| 6035 | } |
| 6036 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6037 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6038 | rts_threshold); |
| 6039 | } |
| 6040 | |
| 6041 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6042 | { |
| 6043 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6044 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6045 | wiphy->frag_threshold; |
| 6046 | |
| 6047 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6048 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6049 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6050 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6051 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6052 | frag_threshold); |
| 6053 | return -EINVAL; |
| 6054 | } |
| 6055 | |
| 6056 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6057 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6058 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6059 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6060 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6061 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6062 | __func__, frag_threshold); |
| 6063 | return -EIO; |
| 6064 | } |
| 6065 | |
| 6066 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6067 | frag_threshold); |
| 6068 | } |
| 6069 | |
| 6070 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6071 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6072 | { |
| 6073 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6074 | wiphy->retry_short : |
| 6075 | wiphy->retry_long; |
| 6076 | |
| 6077 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6078 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6079 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6080 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6081 | __func__, retry_value); |
| 6082 | return -EINVAL; |
| 6083 | } |
| 6084 | |
| 6085 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6086 | { |
| 6087 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6088 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6089 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6090 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6091 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6092 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6093 | __func__, retry_value); |
| 6094 | return -EIO; |
| 6095 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6096 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6097 | __func__, retry_value); |
| 6098 | } |
| 6099 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6100 | { |
| 6101 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6102 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6103 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6104 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6105 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6106 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6107 | __func__, retry_value); |
| 6108 | return -EIO; |
| 6109 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6110 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6111 | __func__, retry_value); |
| 6112 | } |
| 6113 | } |
| 6114 | |
| 6115 | return 0; |
| 6116 | } |
| 6117 | |
| 6118 | /* |
| 6119 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6120 | * This function is used to set the txpower |
| 6121 | */ |
| 6122 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
| 6123 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6124 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6125 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6126 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6127 | #endif |
| 6128 | int dbm) |
| 6129 | { |
| 6130 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6131 | tHalHandle hHal = pHddCtx->hHal; |
| 6132 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6133 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6134 | |
| 6135 | ENTER(); |
| 6136 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6137 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6138 | dbm, ccmCfgSetCallback, |
| 6139 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6140 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6141 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6142 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6143 | return -EIO; |
| 6144 | } |
| 6145 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6146 | if ( pHddCtx->isLogpInProgress ) |
| 6147 | { |
| 6148 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6149 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6150 | return -EAGAIN; |
| 6151 | } |
| 6152 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6153 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6154 | dbm); |
| 6155 | |
| 6156 | switch(type) |
| 6157 | { |
| 6158 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6159 | /* Fall through */ |
| 6160 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6161 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6162 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6163 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6164 | __func__); |
| 6165 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6166 | } |
| 6167 | break; |
| 6168 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6169 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6170 | __func__); |
| 6171 | return -EOPNOTSUPP; |
| 6172 | break; |
| 6173 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6174 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6175 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6176 | return -EIO; |
| 6177 | } |
| 6178 | |
| 6179 | return 0; |
| 6180 | } |
| 6181 | |
| 6182 | /* |
| 6183 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6184 | * This function is used to read the txpower |
| 6185 | */ |
| 6186 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) |
| 6187 | { |
| 6188 | |
| 6189 | hdd_adapter_t *pAdapter; |
| 6190 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6191 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6192 | ENTER(); |
| 6193 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6194 | if (NULL == pHddCtx) |
| 6195 | { |
| 6196 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__); |
| 6197 | *dbm = 0; |
| 6198 | return -ENOENT; |
| 6199 | } |
| 6200 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6201 | if ( pHddCtx->isLogpInProgress ) |
| 6202 | { |
| 6203 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6204 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6205 | return -EAGAIN; |
| 6206 | } |
| 6207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6208 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6209 | if (NULL == pAdapter) |
| 6210 | { |
| 6211 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6212 | return -ENOENT; |
| 6213 | } |
| 6214 | |
| 6215 | wlan_hdd_get_classAstats(pAdapter); |
| 6216 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6217 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6218 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6219 | return 0; |
| 6220 | } |
| 6221 | |
| 6222 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6223 | u8* mac, struct station_info *sinfo) |
| 6224 | { |
| 6225 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6226 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6227 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6228 | tANI_U8 rate_flags; |
| 6229 | |
| 6230 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6231 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6232 | |
| 6233 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6234 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6235 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6236 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6237 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6238 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6239 | tANI_U16 maxRate = 0; |
| 6240 | tANI_U16 myRate; |
| 6241 | tANI_U16 currentRate = 0; |
| 6242 | tANI_U8 maxSpeedMCS = 0; |
| 6243 | tANI_U8 maxMCSIdx = 0; |
| 6244 | tANI_U8 rateFlag = 1; |
| 6245 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6246 | tANI_U16 temp; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6247 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6248 | #ifdef WLAN_FEATURE_11AC |
| 6249 | tANI_U32 vht_mcs_map; |
| 6250 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6251 | #endif /* WLAN_FEATURE_11AC */ |
| 6252 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6253 | ENTER(); |
| 6254 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6255 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6256 | (0 == ssidlen)) |
| 6257 | { |
| 6258 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6259 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6260 | /*To keep GUI happy*/ |
| 6261 | return 0; |
| 6262 | } |
| 6263 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6264 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6265 | { |
| 6266 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6267 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6268 | return -EAGAIN; |
| 6269 | } |
| 6270 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6271 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6272 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6273 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6274 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6275 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6276 | |
| 6277 | //convert to the UI units of 100kbps |
| 6278 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6279 | |
| 6280 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6281 | 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] | 6282 | sinfo->signal, |
| 6283 | pCfg->reportMaxLinkSpeed, |
| 6284 | myRate, |
| 6285 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6286 | (int) pCfg->linkSpeedRssiMid, |
| 6287 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6288 | (int) rate_flags, |
| 6289 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6290 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6291 | |
| 6292 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6293 | { |
| 6294 | // we do not want to necessarily report the current speed |
| 6295 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6296 | { |
| 6297 | // report the max possible speed |
| 6298 | rssidx = 0; |
| 6299 | } |
| 6300 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6301 | { |
| 6302 | // report the max possible speed with RSSI scaling |
| 6303 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6304 | { |
| 6305 | // report the max possible speed |
| 6306 | rssidx = 0; |
| 6307 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6308 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6309 | { |
| 6310 | // report middle speed |
| 6311 | rssidx = 1; |
| 6312 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6313 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6314 | { |
| 6315 | // report middle speed |
| 6316 | rssidx = 2; |
| 6317 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6318 | else |
| 6319 | { |
| 6320 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6321 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6322 | } |
| 6323 | } |
| 6324 | else |
| 6325 | { |
| 6326 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6327 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6328 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6329 | __func__, pCfg->reportMaxLinkSpeed); |
| 6330 | rssidx = 0; |
| 6331 | } |
| 6332 | |
| 6333 | maxRate = 0; |
| 6334 | |
| 6335 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6336 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6337 | OperationalRates, &ORLeng)) |
| 6338 | { |
| 6339 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6340 | /*To keep GUI happy*/ |
| 6341 | return 0; |
| 6342 | } |
| 6343 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6344 | for (i = 0; i < ORLeng; i++) |
| 6345 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6346 | 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] | 6347 | { |
| 6348 | /* Validate Rate Set */ |
| 6349 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6350 | { |
| 6351 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6352 | break; |
| 6353 | } |
| 6354 | } |
| 6355 | /* Update MAX rate */ |
| 6356 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6357 | } |
| 6358 | |
| 6359 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6360 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6361 | ExtendedRates, &ERLeng)) |
| 6362 | { |
| 6363 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6364 | /*To keep GUI happy*/ |
| 6365 | return 0; |
| 6366 | } |
| 6367 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6368 | for (i = 0; i < ERLeng; i++) |
| 6369 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6370 | 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] | 6371 | { |
| 6372 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6373 | { |
| 6374 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6375 | break; |
| 6376 | } |
| 6377 | } |
| 6378 | /* Update MAX rate */ |
| 6379 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6380 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6381 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6382 | rates or if we are always reporting max speed or if we have |
| 6383 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6384 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6385 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6386 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6387 | MCSRates, &MCSLeng)) |
| 6388 | { |
| 6389 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6390 | /*To keep GUI happy*/ |
| 6391 | return 0; |
| 6392 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6393 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6394 | #ifdef WLAN_FEATURE_11AC |
| 6395 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6396 | 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] | 6397 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6398 | 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] | 6399 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6400 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6401 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6402 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6403 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6404 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6405 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6406 | maxMCSIdx = 7; |
| 6407 | } |
| 6408 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6409 | { |
| 6410 | maxMCSIdx = 8; |
| 6411 | } |
| 6412 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6413 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6414 | //VHT20 is supporting 0~8 |
| 6415 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6416 | maxMCSIdx = 8; |
| 6417 | else |
| 6418 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6419 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6420 | |
| 6421 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6422 | { |
| 6423 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6424 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6425 | } |
| 6426 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6427 | { |
| 6428 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6429 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6430 | } |
| 6431 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6432 | { |
| 6433 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6434 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6435 | } |
| 6436 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6437 | maxSpeedMCS = 1; |
| 6438 | if (currentRate > maxRate) |
| 6439 | { |
| 6440 | maxRate = currentRate; |
| 6441 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6442 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6443 | } |
| 6444 | else |
| 6445 | #endif /* WLAN_FEATURE_11AC */ |
| 6446 | { |
| 6447 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6448 | { |
| 6449 | rateFlag |= 1; |
| 6450 | } |
| 6451 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6452 | { |
| 6453 | rateFlag |= 2; |
| 6454 | } |
| 6455 | |
| 6456 | for (i = 0; i < MCSLeng; i++) |
| 6457 | { |
| 6458 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6459 | for (j = 0; j < temp; j++) |
| 6460 | { |
| 6461 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6462 | { |
| 6463 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6464 | break; |
| 6465 | } |
| 6466 | } |
| 6467 | if ((j < temp) && (currentRate > maxRate)) |
| 6468 | { |
| 6469 | maxRate = currentRate; |
| 6470 | maxSpeedMCS = 1; |
| 6471 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6472 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6473 | } |
| 6474 | } |
| 6475 | } |
| 6476 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6477 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6478 | { |
| 6479 | maxRate = myRate; |
| 6480 | maxSpeedMCS = 1; |
| 6481 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6482 | } |
| 6483 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6484 | // 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] | 6485 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6486 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6487 | { |
| 6488 | maxRate = myRate; |
| 6489 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6490 | { |
| 6491 | maxSpeedMCS = 0; |
| 6492 | } |
| 6493 | else |
| 6494 | { |
| 6495 | maxSpeedMCS = 1; |
| 6496 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6497 | } |
| 6498 | } |
| 6499 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6500 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6501 | { |
| 6502 | sinfo->txrate.legacy = maxRate; |
| 6503 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6504 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6505 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6506 | } |
| 6507 | else |
| 6508 | { |
| 6509 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6510 | #ifdef WLAN_FEATURE_11AC |
| 6511 | sinfo->txrate.nss = 1; |
| 6512 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6513 | { |
| 6514 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6515 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6516 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6517 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6518 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6519 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6520 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6521 | } |
| 6522 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6523 | { |
| 6524 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6525 | } |
| 6526 | #endif /* WLAN_FEATURE_11AC */ |
| 6527 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6528 | { |
| 6529 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6530 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6531 | { |
| 6532 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6533 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6534 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6535 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6536 | { |
| 6537 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6538 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6539 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6540 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6541 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6542 | sinfo->txrate.mcs, |
| 6543 | sinfo->txrate.flags ); |
| 6544 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6545 | } |
| 6546 | } |
| 6547 | else |
| 6548 | { |
| 6549 | // report current rate instead of max rate |
| 6550 | |
| 6551 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6552 | { |
| 6553 | //provide to the UI in units of 100kbps |
| 6554 | sinfo->txrate.legacy = myRate; |
| 6555 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6556 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6557 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6558 | } |
| 6559 | else |
| 6560 | { |
| 6561 | //must be MCS |
| 6562 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6563 | #ifdef WLAN_FEATURE_11AC |
| 6564 | sinfo->txrate.nss = 1; |
| 6565 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6566 | { |
| 6567 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6568 | } |
| 6569 | else |
| 6570 | #endif /* WLAN_FEATURE_11AC */ |
| 6571 | { |
| 6572 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6573 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6574 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6575 | { |
| 6576 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6577 | } |
| 6578 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6579 | { |
| 6580 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6581 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6582 | #ifdef WLAN_FEATURE_11AC |
| 6583 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6584 | { |
| 6585 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6586 | } |
| 6587 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6588 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6589 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6590 | sinfo->txrate.mcs, |
| 6591 | sinfo->txrate.flags ); |
| 6592 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6593 | } |
| 6594 | } |
| 6595 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6596 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6597 | sinfo->tx_packets = |
| 6598 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6599 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6600 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6601 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6602 | |
| 6603 | sinfo->tx_retries = |
| 6604 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6605 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6606 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6607 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6608 | |
| 6609 | sinfo->tx_failed = |
| 6610 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6611 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6612 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6613 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6614 | |
| 6615 | sinfo->filled |= |
| 6616 | STATION_INFO_TX_PACKETS | |
| 6617 | STATION_INFO_TX_RETRIES | |
| 6618 | STATION_INFO_TX_FAILED; |
| 6619 | |
| 6620 | EXIT(); |
| 6621 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6622 | } |
| 6623 | |
| 6624 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 6625 | struct net_device *dev, bool mode, v_SINT_t timeout) |
| 6626 | { |
| 6627 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6628 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6629 | VOS_STATUS vos_status; |
| 6630 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6631 | ENTER(); |
| 6632 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6633 | if (NULL == pAdapter) |
| 6634 | { |
| 6635 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6636 | return -ENODEV; |
| 6637 | } |
| 6638 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6639 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6640 | if (NULL == pHddCtx) |
| 6641 | { |
| 6642 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD context is NULL\n", __func__); |
| 6643 | return -ENODEV; |
| 6644 | } |
| 6645 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6646 | if ( pHddCtx->isLogpInProgress ) |
| 6647 | { |
| 6648 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6649 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6650 | return -EAGAIN; |
| 6651 | } |
| 6652 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6653 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6654 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6655 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6656 | (eConnectionState_Associated == |
| 6657 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6658 | { |
| 6659 | vos_status = hdd_conf_hostarpoffload(pAdapter, TRUE); |
| 6660 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6661 | { |
| 6662 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6663 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6664 | __func__, vos_status); |
| 6665 | } |
| 6666 | } |
| 6667 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6668 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6669 | *on successful execution of the function call |
| 6670 | *we are oppositely mapped w.r.t mode in the driver |
| 6671 | **/ |
| 6672 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6673 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6674 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6675 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6676 | { |
| 6677 | return -EINVAL; |
| 6678 | } |
| 6679 | return 0; |
| 6680 | } |
| 6681 | |
| 6682 | |
| 6683 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6684 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6685 | struct net_device *netdev, |
| 6686 | u8 key_index) |
| 6687 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6688 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6689 | return 0; |
| 6690 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6691 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6692 | |
| 6693 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6694 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6695 | struct net_device *dev, |
| 6696 | struct ieee80211_txq_params *params) |
| 6697 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6698 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6699 | return 0; |
| 6700 | } |
| 6701 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6702 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6703 | struct ieee80211_txq_params *params) |
| 6704 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6705 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6706 | return 0; |
| 6707 | } |
| 6708 | #endif //LINUX_VERSION_CODE |
| 6709 | |
| 6710 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6711 | struct net_device *dev, u8 *mac) |
| 6712 | { |
| 6713 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6714 | VOS_STATUS vos_status; |
| 6715 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6716 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6717 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6718 | if ( NULL == pAdapter || NULL == pAdapter->pHddCtx) |
| 6719 | { |
| 6720 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__); |
| 6721 | return -EINVAL; |
| 6722 | } |
| 6723 | |
| 6724 | if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress) |
| 6725 | { |
| 6726 | hddLog( LOGE, |
| 6727 | "%s: Wlan Load/Unload is in progress", __func__); |
| 6728 | return -EBUSY; |
| 6729 | } |
| 6730 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6731 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6732 | { |
| 6733 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6734 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6735 | return -EAGAIN; |
| 6736 | } |
| 6737 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6738 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6739 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6740 | ) |
| 6741 | { |
| 6742 | if( NULL == mac ) |
| 6743 | { |
| 6744 | v_U16_t i; |
| 6745 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6746 | { |
| 6747 | if(pAdapter->aStaInfo[i].isUsed) |
| 6748 | { |
| 6749 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6750 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6751 | "%s: Delete STA with MAC::" |
| 6752 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6753 | __func__, |
| 6754 | macAddr[0], macAddr[1], macAddr[2], |
| 6755 | macAddr[3], macAddr[4], macAddr[5]); |
| 6756 | hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6757 | } |
| 6758 | } |
| 6759 | } |
| 6760 | else |
| 6761 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6762 | |
| 6763 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6764 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6765 | { |
| 6766 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6767 | "%s: Skip this DEL STA as this is not used::" |
| 6768 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6769 | __func__, |
| 6770 | mac[0], mac[1], mac[2], |
| 6771 | mac[3], mac[4], mac[5]); |
| 6772 | return -ENOENT; |
| 6773 | } |
| 6774 | |
| 6775 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 6776 | { |
| 6777 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6778 | "%s: Skip this DEL STA as deauth is in progress::" |
| 6779 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6780 | __func__, |
| 6781 | mac[0], mac[1], mac[2], |
| 6782 | mac[3], mac[4], mac[5]); |
| 6783 | return -ENOENT; |
| 6784 | } |
| 6785 | |
| 6786 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 6787 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6788 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6789 | "%s: Delete STA with MAC::" |
| 6790 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6791 | __func__, |
| 6792 | mac[0], mac[1], mac[2], |
| 6793 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6794 | |
| 6795 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 6796 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6797 | { |
| 6798 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 6799 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6800 | "%s: STA removal failed for ::" |
| 6801 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6802 | __func__, |
| 6803 | mac[0], mac[1], mac[2], |
| 6804 | mac[3], mac[4], mac[5]); |
| 6805 | return -ENOENT; |
| 6806 | } |
| 6807 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6808 | } |
| 6809 | } |
| 6810 | |
| 6811 | EXIT(); |
| 6812 | |
| 6813 | return 0; |
| 6814 | } |
| 6815 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6816 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 6817 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 6818 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6819 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6820 | #ifdef FEATURE_WLAN_TDLS |
| 6821 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6822 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6823 | mask = params->sta_flags_mask; |
| 6824 | |
| 6825 | set = params->sta_flags_set; |
| 6826 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6827 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 6828 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6829 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 6830 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 6831 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6832 | |
| 6833 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 6834 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 6835 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 6836 | } |
| 6837 | } |
| 6838 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6839 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6840 | } |
| 6841 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6842 | |
| 6843 | #ifdef FEATURE_WLAN_LFR |
| 6844 | 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] | 6845 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6846 | { |
| 6847 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 6848 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6849 | static tANI_U32 i; // HDD Local Cache index |
| 6850 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6851 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6852 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6853 | eHalStatus result; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6854 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6855 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6856 | ENTER(); |
| 6857 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6858 | // Validate pAdapter |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6859 | if ( NULL == pAdapter || NULL == pAdapter->pHddCtx) |
| 6860 | { |
| 6861 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__); |
| 6862 | return -EINVAL; |
| 6863 | } |
| 6864 | |
| 6865 | if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress) |
| 6866 | { |
| 6867 | hddLog( LOGE, |
| 6868 | "%s: Wlan Load/Unload is in progress", __func__); |
| 6869 | return -EBUSY; |
| 6870 | } |
| 6871 | |
| 6872 | if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress ) |
| 6873 | { |
| 6874 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6875 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 6876 | return -EAGAIN; |
| 6877 | } |
| 6878 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6879 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6880 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6881 | |
| 6882 | for (j = 0; j < i; j++) |
| 6883 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6884 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6885 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 6886 | { |
| 6887 | /* BSSID matched previous entry. Overwrite it. */ |
| 6888 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6889 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6890 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6891 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 6892 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6893 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6894 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6895 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6896 | dump_bssid(pmksa->bssid); |
| 6897 | dump_pmkid(halHandle, pmksa->pmkid); |
| 6898 | break; |
| 6899 | } |
| 6900 | } |
| 6901 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 6902 | /* Check we compared all entries,if then take the first slot now */ |
| 6903 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 6904 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6905 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6906 | { |
| 6907 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 6908 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 6909 | pmksa->bssid, ETHER_ADDR_LEN); |
| 6910 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 6911 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6912 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6913 | 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] | 6914 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6915 | dump_bssid(pmksa->bssid); |
| 6916 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6917 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6918 | // 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] | 6919 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6920 | } |
| 6921 | |
| 6922 | |
| 6923 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6924 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6925 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6926 | 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] | 6927 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6928 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6929 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 6930 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6931 | i ); |
| 6932 | return 0; |
| 6933 | } |
| 6934 | |
| 6935 | |
| 6936 | 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] | 6937 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6938 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6939 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6940 | // TODO: Implement this later. |
| 6941 | return 0; |
| 6942 | } |
| 6943 | |
| 6944 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 6945 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6946 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6947 | // TODO: Implement this later. |
| 6948 | return 0; |
| 6949 | } |
| 6950 | #endif |
| 6951 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6952 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6953 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6954 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 6955 | { |
| 6956 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6957 | hdd_station_ctx_t *pHddStaCtx; |
| 6958 | |
| 6959 | if (NULL == pAdapter) |
| 6960 | { |
| 6961 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6962 | return -ENODEV; |
| 6963 | } |
| 6964 | |
| 6965 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6966 | |
| 6967 | // Added for debug on reception of Re-assoc Req. |
| 6968 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6969 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6970 | 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] | 6971 | ftie->ie_len); |
| 6972 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 6973 | } |
| 6974 | |
| 6975 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6976 | 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] | 6977 | ftie->ie_len); |
| 6978 | #endif |
| 6979 | |
| 6980 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 6981 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6982 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 6983 | ftie->ie_len); |
| 6984 | return 0; |
| 6985 | } |
| 6986 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6987 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 6988 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 6989 | |
| 6990 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 6991 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 6992 | { |
| 6993 | int ret; |
| 6994 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 6995 | hdd_context_t *pHddCtx; |
| 6996 | |
| 6997 | if (NULL == pAdapter) |
| 6998 | { |
| 6999 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7000 | "%s: HDD adapter is Null", __func__); |
| 7001 | return ; |
| 7002 | } |
| 7003 | |
| 7004 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7005 | if (NULL == pHddCtx) |
| 7006 | { |
| 7007 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7008 | "%s: HDD context is Null!!!", __func__); |
| 7009 | return ; |
| 7010 | } |
| 7011 | |
| 7012 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7013 | |
| 7014 | if (0 > ret) |
| 7015 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7016 | |
| 7017 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
| 7018 | } |
| 7019 | |
| 7020 | /* |
| 7021 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7022 | * NL interface to enable PNO |
| 7023 | */ |
| 7024 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7025 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7026 | { |
| 7027 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7028 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7029 | hdd_context_t *pHddCtx; |
| 7030 | tHalHandle hHal; |
| 7031 | v_U32_t i, indx, num_ch; |
| 7032 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7033 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7034 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7035 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7036 | |
| 7037 | if (NULL == pAdapter) |
| 7038 | { |
| 7039 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7040 | "%s: HDD adapter is Null", __func__); |
| 7041 | return -ENODEV; |
| 7042 | } |
| 7043 | |
| 7044 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7045 | if (NULL == pHddCtx) |
| 7046 | { |
| 7047 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7048 | "%s: HDD context is Null!!!", __func__); |
| 7049 | return -ENODEV; |
| 7050 | } |
| 7051 | |
| 7052 | if (pHddCtx->isLogpInProgress) |
| 7053 | { |
| 7054 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7055 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7056 | return -EAGAIN; |
| 7057 | } |
| 7058 | |
| 7059 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7060 | if (NULL == hHal) |
| 7061 | { |
| 7062 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7063 | "%s: HAL context is Null!!!", __func__); |
| 7064 | return -EAGAIN; |
| 7065 | } |
| 7066 | |
| 7067 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7068 | if (NULL == pPnoRequest) |
| 7069 | { |
| 7070 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7071 | "%s: vos_mem_malloc failed", __func__); |
| 7072 | return -ENODEV; |
| 7073 | } |
| 7074 | |
| 7075 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 7076 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 7077 | |
| 7078 | if (( !pPnoRequest->ucNetworksCount ) || |
| 7079 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 7080 | { |
| 7081 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7082 | "Network input is not correct"); |
| 7083 | goto error; |
| 7084 | } |
| 7085 | |
| 7086 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 7087 | { |
| 7088 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7089 | "Incorrect number of channels"); |
| 7090 | goto error; |
| 7091 | } |
| 7092 | |
| 7093 | /* Framework provides one set of channels(all) |
| 7094 | * common for all saved profile */ |
| 7095 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 7096 | channels_allowed, &num_channels_allowed)) |
| 7097 | { |
| 7098 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7099 | "%s: failed to get valid channel list", __func__); |
| 7100 | goto error; |
| 7101 | } |
| 7102 | /* Checking each channel against allowed channel list */ |
| 7103 | num_ch = 0; |
| 7104 | for (i = 0; i < request->n_channels; i++) |
| 7105 | { |
| 7106 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 7107 | { |
| 7108 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 7109 | { |
| 7110 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 7111 | break ; |
| 7112 | } |
| 7113 | } |
| 7114 | } |
| 7115 | |
| 7116 | /* Filling per profile params */ |
| 7117 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 7118 | { |
| 7119 | pPnoRequest->aNetworks[i].ssId.length = |
| 7120 | request->match_sets[i].ssid.ssid_len; |
| 7121 | |
| 7122 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 7123 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 7124 | { |
| 7125 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7126 | "SSID Len %d is not correct for network %d", |
| 7127 | pPnoRequest->aNetworks[i].ssId.length, i); |
| 7128 | goto error; |
| 7129 | } |
| 7130 | |
| 7131 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 7132 | request->match_sets[i].ssid.ssid, |
| 7133 | request->match_sets[i].ssid.ssid_len); |
| 7134 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 7135 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 7136 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 7137 | |
| 7138 | /*Copying list of valid channel into request */ |
| 7139 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 7140 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 7141 | |
| 7142 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 7143 | } |
| 7144 | |
| 7145 | /* framework provides interval in ms */ |
| 7146 | pPnoRequest->scanTimers.ucScanTimersCount = 1; |
| 7147 | pPnoRequest->scanTimers.aTimerValues[0].uTimerValue = |
| 7148 | (request->interval)/1000; |
| 7149 | pPnoRequest->scanTimers.aTimerValues[0].uTimerRepeat = 0; |
| 7150 | pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND; |
| 7151 | |
| 7152 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7153 | pPnoRequest, pAdapter->sessionId, |
| 7154 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 7155 | if (eHAL_STATUS_SUCCESS != status) |
| 7156 | { |
| 7157 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7158 | "Failed to enable PNO"); |
| 7159 | goto error; |
| 7160 | } |
| 7161 | |
| 7162 | error: |
| 7163 | vos_mem_free(pPnoRequest); |
| 7164 | return status; |
| 7165 | } |
| 7166 | |
| 7167 | /* |
| 7168 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 7169 | * NL interface to disable PNO |
| 7170 | */ |
| 7171 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 7172 | struct net_device *dev) |
| 7173 | { |
| 7174 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7175 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7176 | hdd_context_t *pHddCtx; |
| 7177 | tHalHandle hHal; |
| 7178 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7179 | |
| 7180 | ENTER(); |
| 7181 | |
| 7182 | if (NULL == pAdapter) |
| 7183 | { |
| 7184 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7185 | "%s: HDD adapter is Null", __func__); |
| 7186 | return -ENODEV; |
| 7187 | } |
| 7188 | |
| 7189 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7190 | if (NULL == pHddCtx) |
| 7191 | { |
| 7192 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7193 | "%s: HDD context is Null!!!", __func__); |
| 7194 | return -ENODEV; |
| 7195 | } |
| 7196 | |
| 7197 | if (pHddCtx->isLogpInProgress) |
| 7198 | { |
| 7199 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7200 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7201 | return -EAGAIN; |
| 7202 | } |
| 7203 | |
| 7204 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7205 | if (NULL == hHal) |
| 7206 | { |
| 7207 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7208 | "%s: HAL context is Null!!!", __func__); |
| 7209 | return -EAGAIN; |
| 7210 | } |
| 7211 | |
| 7212 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7213 | if (NULL == pPnoRequest) |
| 7214 | { |
| 7215 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7216 | "%s: vos_mem_malloc failed", __func__); |
| 7217 | return -ENODEV; |
| 7218 | } |
| 7219 | |
| 7220 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 7221 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 7222 | pPnoRequest->ucNetworksCount = 0; |
| 7223 | |
| 7224 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 7225 | pAdapter->sessionId, |
| 7226 | NULL, pAdapter); |
| 7227 | if (eHAL_STATUS_SUCCESS != status) |
| 7228 | { |
| 7229 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7230 | "Failed to disabled PNO"); |
| 7231 | } |
| 7232 | |
| 7233 | vos_mem_free(pPnoRequest); |
| 7234 | |
| 7235 | EXIT(); |
| 7236 | return status; |
| 7237 | } |
| 7238 | |
| 7239 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 7240 | |
| 7241 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7242 | #ifdef FEATURE_WLAN_TDLS |
| 7243 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 7244 | u8 *peer, u8 action_code, u8 dialog_token, |
| 7245 | u16 status_code, const u8 *buf, size_t len) |
| 7246 | { |
| 7247 | |
| 7248 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7249 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7250 | u8 peerMac[6]; |
| 7251 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7252 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7253 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7254 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7255 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7256 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7257 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7258 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7259 | "Invalid arguments"); |
| 7260 | return -EINVAL; |
| 7261 | } |
| 7262 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7263 | if (pHddCtx->isLogpInProgress) |
| 7264 | { |
| 7265 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7266 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7267 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7268 | return -EBUSY; |
| 7269 | } |
| 7270 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7271 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7272 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7273 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7274 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7275 | MAC_ADDRESS_STR " action %d declined.", |
| 7276 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7277 | return -ENOTSUPP; |
| 7278 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7279 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7280 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 7281 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 7282 | { |
| 7283 | /* if tdls_mode is disabled to respond to peer's request */ |
| 7284 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 7285 | { |
| 7286 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7287 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7288 | " TDLS mode is disabled. action %d declined.", |
| 7289 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7290 | |
| 7291 | return -ENOTSUPP; |
| 7292 | } |
| 7293 | } |
| 7294 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7295 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 7296 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 7297 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7298 | { |
| 7299 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7300 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7301 | " TDLS setup is ongoing. action %d declined.", |
| 7302 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7303 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7304 | } |
| 7305 | } |
| 7306 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7307 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 7308 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7309 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7310 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7311 | { |
| 7312 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 7313 | we return error code at 'add_station()'. Hence we have this |
| 7314 | check again in addtion to add_station(). |
| 7315 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7316 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7317 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7318 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7319 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7320 | " TDLS Max peer already connected. action %d declined.", |
| 7321 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7322 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7323 | } |
| 7324 | else |
| 7325 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7326 | /* maximum reached. tweak to send error code to peer and return |
| 7327 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7328 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7329 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7330 | "%s: " MAC_ADDRESS_STR |
| 7331 | " TDLS Max peer already connected send response status %d", |
| 7332 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7333 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7334 | /* fall through to send setup resp with failure status |
| 7335 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7336 | } |
| 7337 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7338 | else |
| 7339 | { |
| 7340 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7341 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7342 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7343 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7344 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7345 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 7346 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7347 | return -EPERM; |
| 7348 | } |
| 7349 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7350 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7351 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7352 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7353 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7354 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7355 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 7356 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 7357 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7358 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7359 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7360 | /*Except teardown responder will not be used so just make 0*/ |
| 7361 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7362 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7363 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7364 | |
| 7365 | hddTdlsPeer_t *pTdlsPeer; |
| 7366 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 7367 | |
| 7368 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 7369 | responder = pTdlsPeer->is_responder; |
| 7370 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7371 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7372 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7373 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 7374 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 7375 | dialog_token, status_code, len); |
| 7376 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7377 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7378 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7379 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7380 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
| 7381 | (SIR_MAC_TDLS_DIS_RSP == action_code)) |
| 7382 | { |
| 7383 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 7384 | { |
| 7385 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7386 | "%s: Sending Disc/Setup Rsp Frame.Disable BMPS", __func__); |
| 7387 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7388 | } |
| 7389 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
| 7390 | } |
| 7391 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7392 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7393 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7394 | { |
| 7395 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7396 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7397 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7398 | return -EBUSY; |
| 7399 | } |
| 7400 | |
| 7401 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7402 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7403 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7404 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7405 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7406 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7407 | if (VOS_STATUS_SUCCESS != status) |
| 7408 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7409 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7410 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7411 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7412 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7413 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7414 | } |
| 7415 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7416 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7417 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7418 | |
| 7419 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7420 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7421 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7422 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7423 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7424 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7425 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7426 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7427 | } |
| 7428 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7429 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7430 | { |
| 7431 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7432 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7433 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7434 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7435 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7436 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7437 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7438 | } |
| 7439 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7440 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7441 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7442 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7443 | |
| 7444 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7445 | error: |
| 7446 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7447 | because we already know that this transaction will be failed, |
| 7448 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7449 | to be safe, do not change the state mahine. |
| 7450 | */ |
| 7451 | if(max_sta_failed == 0 && |
| 7452 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7453 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7454 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7455 | } |
| 7456 | |
| 7457 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7458 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7459 | { |
| 7460 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7461 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7462 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7463 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7464 | int status = 0; |
| 7465 | tANI_U8 staIdx; |
| 7466 | #endif |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7467 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7468 | const char *tdls_oper_str[]= { |
| 7469 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7470 | "NL80211_TDLS_SETUP", |
| 7471 | "NL80211_TDLS_TEARDOWN", |
| 7472 | "NL80211_TDLS_ENABLE_LINK", |
| 7473 | "NL80211_TDLS_DISABLE_LINK", |
| 7474 | "NL80211_TDLS_UNKONW_OPER"}; |
| 7475 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7476 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7477 | |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7478 | if ( NULL == pHddCtx || NULL == pHddCtx->cfg_ini || NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7479 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7480 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7481 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7482 | return -EINVAL; |
| 7483 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7484 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7485 | if (pHddCtx->isLogpInProgress) |
| 7486 | { |
| 7487 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7488 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 7489 | return -EBUSY; |
| 7490 | } |
| 7491 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7492 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7493 | |
| 7494 | if ( NULL == pTdlsPeer ) { |
| 7495 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7496 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7497 | return -EINVAL; |
| 7498 | } |
| 7499 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7500 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7501 | if((int)oper > 4) |
| 7502 | oper = 5; |
| 7503 | |
| 7504 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7505 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7506 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7507 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7508 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7509 | |
| 7510 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7511 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7512 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7513 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7514 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7515 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7516 | return -ENOTSUPP; |
| 7517 | } |
| 7518 | |
| 7519 | switch (oper) { |
| 7520 | case NL80211_TDLS_ENABLE_LINK: |
| 7521 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7522 | VOS_STATUS status; |
| 7523 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7524 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7525 | { |
| 7526 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7527 | MAC_ADDRESS_STR " failed", |
| 7528 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7529 | return -EINVAL; |
| 7530 | } |
| 7531 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7532 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7533 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7534 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7535 | /* start TDLS client registration with TL */ |
| 7536 | status = hdd_roamRegisterTDLSSTA( pAdapter, peer, pTdlsPeer->staId, pTdlsPeer->signature); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7537 | if (VOS_STATUS_SUCCESS == status) |
| 7538 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7539 | if (pTdlsPeer->is_responder == 0) |
| 7540 | { |
| 7541 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7542 | |
| 7543 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7544 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7545 | WAIT_TIME_TDLS_INITIATOR); |
| 7546 | /* suspend initiator TX until it receives direct packet from the |
| 7547 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7548 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7549 | &staId, NULL); |
| 7550 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7551 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7552 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7553 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7554 | } |
| 7555 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7556 | } |
| 7557 | break; |
| 7558 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7559 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7560 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7561 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7562 | long status; |
| 7563 | |
| 7564 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7565 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7566 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7567 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7568 | |
| 7569 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7570 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7571 | if (status <= 0) |
| 7572 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7573 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7574 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7575 | "%s: Del station failed status %ld", |
| 7576 | __func__, status); |
| 7577 | return -EPERM; |
| 7578 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7579 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7580 | } |
| 7581 | else |
| 7582 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7583 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7584 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7585 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 7586 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 7587 | if (pHddTdlsCtx->defer_link_lost_indication) |
| 7588 | { |
| 7589 | if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) && |
| 7590 | (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0)) |
| 7591 | { |
| 7592 | status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7593 | if ( 0 != status) |
| 7594 | { |
| 7595 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7596 | "%s wlan_hdd_disconnect failure, returned %d \n", |
| 7597 | __func__, (int)status ); |
| 7598 | return -EINVAL; |
| 7599 | } |
| 7600 | } |
| 7601 | } |
| 7602 | #endif |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7603 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7604 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7605 | case NL80211_TDLS_TEARDOWN: |
| 7606 | case NL80211_TDLS_SETUP: |
| 7607 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7608 | /* We don't support in-driver setup/teardown/discovery */ |
| 7609 | return -ENOTSUPP; |
| 7610 | default: |
| 7611 | return -ENOTSUPP; |
| 7612 | } |
| 7613 | return 0; |
| 7614 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7615 | |
| 7616 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7617 | struct net_device *dev, u8 *peer) |
| 7618 | { |
| 7619 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7620 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7621 | |
| 7622 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7623 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7624 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7625 | #endif |
| 7626 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7627 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7628 | /* |
| 7629 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7630 | * Callback rountine called upon receiving response for |
| 7631 | * get offload info |
| 7632 | */ |
| 7633 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7634 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7635 | { |
| 7636 | |
| 7637 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
| 7638 | |
| 7639 | ENTER(); |
| 7640 | |
| 7641 | if (NULL == pAdapter) |
| 7642 | { |
| 7643 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7644 | "%s: HDD adapter is Null", __func__); |
| 7645 | return ; |
| 7646 | } |
| 7647 | |
| 7648 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7649 | { |
| 7650 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7651 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7652 | return ; |
| 7653 | } |
| 7654 | |
| 7655 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7656 | { |
| 7657 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7658 | "%s: wlan Failed to get replay counter value", |
| 7659 | __func__); |
| 7660 | return ; |
| 7661 | } |
| 7662 | |
| 7663 | /* Update replay counter to NL */ |
| 7664 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
| 7665 | (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter, GFP_KERNEL); |
| 7666 | } |
| 7667 | |
| 7668 | /* |
| 7669 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 7670 | * This function is used to offload GTK rekeying job to the firmware. |
| 7671 | */ |
| 7672 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 7673 | struct cfg80211_gtk_rekey_data *data) |
| 7674 | { |
| 7675 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7676 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 7677 | hdd_station_ctx_t *pHddStaCtx; |
| 7678 | tHalHandle hHal; |
| 7679 | tpSirGtkOffloadParams pGtkOffloadReqParams; |
| 7680 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7681 | |
| 7682 | ENTER(); |
| 7683 | |
| 7684 | if (NULL == pAdapter) |
| 7685 | { |
| 7686 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7687 | "%s: HDD adapter is Null", __func__); |
| 7688 | return -ENODEV; |
| 7689 | } |
| 7690 | |
| 7691 | if (NULL == pHddCtx) |
| 7692 | { |
| 7693 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7694 | "%s: HDD context is Null!!!", __func__); |
| 7695 | return -ENODEV; |
| 7696 | } |
| 7697 | |
| 7698 | if (pHddCtx->isLogpInProgress) |
| 7699 | { |
| 7700 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7701 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7702 | return -EAGAIN; |
| 7703 | } |
| 7704 | |
| 7705 | if (pHddCtx->isLoadUnloadInProgress) |
| 7706 | { |
| 7707 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7708 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 7709 | return -EAGAIN; |
| 7710 | } |
| 7711 | |
| 7712 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7713 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7714 | if (NULL == hHal) |
| 7715 | { |
| 7716 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7717 | "%s: HAL context is Null!!!", __func__); |
| 7718 | return -EAGAIN; |
| 7719 | } |
| 7720 | |
| 7721 | pGtkOffloadReqParams = |
| 7722 | &pHddStaCtx->gtkOffloadRequestParams.gtkOffloadReqParams; |
| 7723 | |
| 7724 | pGtkOffloadReqParams->ulFlags = GTK_OFFLOAD_ENABLE; |
| 7725 | memcpy(pGtkOffloadReqParams->aKCK, data->kck, NL80211_KCK_LEN); |
| 7726 | memcpy(pGtkOffloadReqParams->aKEK, data->kek, NL80211_KEK_LEN); |
| 7727 | memcpy(pGtkOffloadReqParams->bssId, &pHddStaCtx->conn_info.bssId, |
| 7728 | WNI_CFG_BSSID_LEN); |
| 7729 | memcpy(&pGtkOffloadReqParams->ullKeyReplayCounter, &data->replay_ctr, |
| 7730 | sizeof (tANI_U64)); |
| 7731 | |
| 7732 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 7733 | { |
| 7734 | /* if wlan is suspended, enable GTK offload directly from here */ |
| 7735 | status = sme_SetGTKOffload(hHal, pGtkOffloadReqParams, |
| 7736 | pAdapter->sessionId); |
| 7737 | |
| 7738 | if (eHAL_STATUS_SUCCESS != status) |
| 7739 | { |
| 7740 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7741 | "%s: sme_SetGTKOffload failed, returned %d", |
| 7742 | __func__, status); |
| 7743 | return status; |
| 7744 | } |
| 7745 | pHddStaCtx->gtkOffloadRequestParams.requested = FALSE; |
| 7746 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7747 | "%s: sme_SetGTKOffload successfull", __func__); |
| 7748 | } |
| 7749 | else |
| 7750 | { |
| 7751 | pHddStaCtx->gtkOffloadRequestParams.requested = TRUE; |
| 7752 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7753 | "%s: wlan not suspended GTKOffload request is stored", |
| 7754 | __func__); |
| 7755 | return eHAL_STATUS_SUCCESS; |
| 7756 | } |
| 7757 | return status; |
| 7758 | } |
| 7759 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 7760 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7761 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7762 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7763 | { |
| 7764 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 7765 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 7766 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 7767 | .change_station = wlan_hdd_change_station, |
| 7768 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 7769 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 7770 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 7771 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7772 | #else |
| 7773 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 7774 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 7775 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7776 | #endif |
| 7777 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 7778 | .add_key = wlan_hdd_cfg80211_add_key, |
| 7779 | .get_key = wlan_hdd_cfg80211_get_key, |
| 7780 | .del_key = wlan_hdd_cfg80211_del_key, |
| 7781 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 7782 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7783 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 7784 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7785 | .scan = wlan_hdd_cfg80211_scan, |
| 7786 | .connect = wlan_hdd_cfg80211_connect, |
| 7787 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 7788 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 7789 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 7790 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 7791 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 7792 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7793 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 7794 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 7795 | .mgmt_tx = wlan_hdd_action, |
| 7796 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7797 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 7798 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 7799 | .set_txq_params = wlan_hdd_set_txq_params, |
| 7800 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7801 | .get_station = wlan_hdd_cfg80211_get_station, |
| 7802 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 7803 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7804 | .add_station = wlan_hdd_cfg80211_add_station, |
| 7805 | #ifdef FEATURE_WLAN_LFR |
| 7806 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 7807 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 7808 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 7809 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7810 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 7811 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 7812 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7813 | #ifdef FEATURE_WLAN_TDLS |
| 7814 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 7815 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 7816 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7817 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7818 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 7819 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7820 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7821 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 7822 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 7823 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7824 | }; |
| 7825 | |