Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 21 | |
| 22 | /**======================================================================== |
| 23 | |
| 24 | \file wlan_hdd_cfg80211.c |
| 25 | |
| 26 | \brief WLAN Host Device Driver implementation |
| 27 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 28 | Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 30 | Qualcomm Technologies Confidential and Proprietary. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | |
| 32 | ========================================================================*/ |
| 33 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 34 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 36 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | |
| 38 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 39 | This section contains comments describing changes made to the module. |
| 40 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | |
| 42 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 43 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | |
| 45 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 46 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 48 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 49 | |
| 50 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 51 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | ==========================================================================*/ |
| 53 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | |
| 55 | #include <linux/version.h> |
| 56 | #include <linux/module.h> |
| 57 | #include <linux/kernel.h> |
| 58 | #include <linux/init.h> |
| 59 | #include <linux/wireless.h> |
| 60 | #include <wlan_hdd_includes.h> |
| 61 | #include <net/arp.h> |
| 62 | #include <net/cfg80211.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <wlan_hdd_wowl.h> |
| 65 | #include <aniGlobal.h> |
| 66 | #include "ccmApi.h" |
| 67 | #include "sirParams.h" |
| 68 | #include "dot11f.h" |
| 69 | #include "wlan_hdd_assoc.h" |
| 70 | #include "wlan_hdd_wext.h" |
| 71 | #include "sme_Api.h" |
| 72 | #include "wlan_hdd_p2p.h" |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_hostapd.h" |
| 75 | #include "sapInternal.h" |
| 76 | #include "wlan_hdd_softap_tx_rx.h" |
| 77 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 78 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 79 | #include "wlan_hdd_power.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 80 | #ifdef WLAN_BTAMP_FEATURE |
| 81 | #include "bap_hdd_misc.h" |
| 82 | #endif |
| 83 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 84 | #ifdef FEATURE_WLAN_TDLS |
| 85 | #include "wlan_hdd_tdls.h" |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 86 | #include "wlan_hdd_wmm.h" |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 87 | #include "wlan_qct_wda.h" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 88 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 89 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 90 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 91 | |
| 92 | #define g_mode_rates_size (12) |
| 93 | #define a_mode_rates_size (8) |
| 94 | #define FREQ_BASE_80211G (2407) |
| 95 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 96 | #define MAX_SCAN_SSID 9 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 97 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 98 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 99 | |
| 100 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 101 | .band = IEEE80211_BAND_2GHZ, \ |
| 102 | .center_freq = (freq), \ |
| 103 | .hw_value = (chan),\ |
| 104 | .flags = (flag), \ |
| 105 | .max_antenna_gain = 0 ,\ |
| 106 | .max_power = 30, \ |
| 107 | } |
| 108 | |
| 109 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 110 | .band = IEEE80211_BAND_5GHZ, \ |
| 111 | .center_freq = (freq), \ |
| 112 | .hw_value = (chan),\ |
| 113 | .flags = (flag), \ |
| 114 | .max_antenna_gain = 0 ,\ |
| 115 | .max_power = 30, \ |
| 116 | } |
| 117 | |
| 118 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 119 | {\ |
| 120 | .bitrate = rate, \ |
| 121 | .hw_value = rate_id, \ |
| 122 | .flags = flag, \ |
| 123 | } |
| 124 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 125 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 126 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 127 | #else |
| 128 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 129 | #endif |
| 130 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 131 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 132 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 133 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 134 | #endif |
| 135 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 136 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 137 | { |
| 138 | WLAN_CIPHER_SUITE_WEP40, |
| 139 | WLAN_CIPHER_SUITE_WEP104, |
| 140 | WLAN_CIPHER_SUITE_TKIP, |
| 141 | #ifdef FEATURE_WLAN_CCX |
| 142 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 143 | WLAN_CIPHER_SUITE_KRK, |
| 144 | WLAN_CIPHER_SUITE_CCMP, |
| 145 | #else |
| 146 | WLAN_CIPHER_SUITE_CCMP, |
| 147 | #endif |
| 148 | #ifdef FEATURE_WLAN_WAPI |
| 149 | WLAN_CIPHER_SUITE_SMS4, |
| 150 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 151 | #ifdef WLAN_FEATURE_11W |
| 152 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 153 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 157 | { |
| 158 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 159 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 160 | } |
| 161 | |
| 162 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 163 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 164 | HDD2GHZCHAN(2412, 1, 0) , |
| 165 | HDD2GHZCHAN(2417, 2, 0) , |
| 166 | HDD2GHZCHAN(2422, 3, 0) , |
| 167 | HDD2GHZCHAN(2427, 4, 0) , |
| 168 | HDD2GHZCHAN(2432, 5, 0) , |
| 169 | HDD2GHZCHAN(2437, 6, 0) , |
| 170 | HDD2GHZCHAN(2442, 7, 0) , |
| 171 | HDD2GHZCHAN(2447, 8, 0) , |
| 172 | HDD2GHZCHAN(2452, 9, 0) , |
| 173 | HDD2GHZCHAN(2457, 10, 0) , |
| 174 | HDD2GHZCHAN(2462, 11, 0) , |
| 175 | HDD2GHZCHAN(2467, 12, 0) , |
| 176 | HDD2GHZCHAN(2472, 13, 0) , |
| 177 | HDD2GHZCHAN(2484, 14, 0) , |
| 178 | }; |
| 179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 181 | { |
| 182 | HDD2GHZCHAN(2412, 1, 0) , |
| 183 | HDD2GHZCHAN(2437, 6, 0) , |
| 184 | HDD2GHZCHAN(2462, 11, 0) , |
| 185 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 186 | |
| 187 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 188 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 189 | HDD5GHZCHAN(4920, 240, 0) , |
| 190 | HDD5GHZCHAN(4940, 244, 0) , |
| 191 | HDD5GHZCHAN(4960, 248, 0) , |
| 192 | HDD5GHZCHAN(4980, 252, 0) , |
| 193 | HDD5GHZCHAN(5040, 208, 0) , |
| 194 | HDD5GHZCHAN(5060, 212, 0) , |
| 195 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 196 | HDD5GHZCHAN(5180, 36, 0) , |
| 197 | HDD5GHZCHAN(5200, 40, 0) , |
| 198 | HDD5GHZCHAN(5220, 44, 0) , |
| 199 | HDD5GHZCHAN(5240, 48, 0) , |
| 200 | HDD5GHZCHAN(5260, 52, 0) , |
| 201 | HDD5GHZCHAN(5280, 56, 0) , |
| 202 | HDD5GHZCHAN(5300, 60, 0) , |
| 203 | HDD5GHZCHAN(5320, 64, 0) , |
| 204 | HDD5GHZCHAN(5500,100, 0) , |
| 205 | HDD5GHZCHAN(5520,104, 0) , |
| 206 | HDD5GHZCHAN(5540,108, 0) , |
| 207 | HDD5GHZCHAN(5560,112, 0) , |
| 208 | HDD5GHZCHAN(5580,116, 0) , |
| 209 | HDD5GHZCHAN(5600,120, 0) , |
| 210 | HDD5GHZCHAN(5620,124, 0) , |
| 211 | HDD5GHZCHAN(5640,128, 0) , |
| 212 | HDD5GHZCHAN(5660,132, 0) , |
| 213 | HDD5GHZCHAN(5680,136, 0) , |
| 214 | HDD5GHZCHAN(5700,140, 0) , |
| 215 | HDD5GHZCHAN(5745,149, 0) , |
| 216 | HDD5GHZCHAN(5765,153, 0) , |
| 217 | HDD5GHZCHAN(5785,157, 0) , |
| 218 | HDD5GHZCHAN(5805,161, 0) , |
| 219 | HDD5GHZCHAN(5825,165, 0) , |
| 220 | }; |
| 221 | |
| 222 | static struct ieee80211_rate g_mode_rates[] = |
| 223 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 224 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 225 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 226 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 227 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 228 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 229 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 230 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 231 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 232 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 233 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 234 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 235 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 236 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 237 | |
| 238 | static struct ieee80211_rate a_mode_rates[] = |
| 239 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 240 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 241 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 242 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 243 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 244 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 245 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 246 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 247 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 248 | }; |
| 249 | |
| 250 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 251 | { |
| 252 | .channels = hdd_channels_2_4_GHZ, |
| 253 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 254 | .band = IEEE80211_BAND_2GHZ, |
| 255 | .bitrates = g_mode_rates, |
| 256 | .n_bitrates = g_mode_rates_size, |
| 257 | .ht_cap.ht_supported = 1, |
| 258 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 259 | | IEEE80211_HT_CAP_GRN_FLD |
| 260 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 261 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 262 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 263 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 264 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 265 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 266 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 267 | }; |
| 268 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 269 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 270 | { |
| 271 | .channels = hdd_social_channels_2_4_GHZ, |
| 272 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 273 | .band = IEEE80211_BAND_2GHZ, |
| 274 | .bitrates = g_mode_rates, |
| 275 | .n_bitrates = g_mode_rates_size, |
| 276 | .ht_cap.ht_supported = 1, |
| 277 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 278 | | IEEE80211_HT_CAP_GRN_FLD |
| 279 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 280 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 281 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 282 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 283 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 284 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 285 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 286 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 287 | |
| 288 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 289 | { |
| 290 | .channels = hdd_channels_5_GHZ, |
| 291 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 292 | .band = IEEE80211_BAND_5GHZ, |
| 293 | .bitrates = a_mode_rates, |
| 294 | .n_bitrates = a_mode_rates_size, |
| 295 | .ht_cap.ht_supported = 1, |
| 296 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 297 | | IEEE80211_HT_CAP_GRN_FLD |
| 298 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 299 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 300 | | IEEE80211_HT_CAP_SGI_40 |
| 301 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 302 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 303 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 304 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 305 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 306 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 307 | }; |
| 308 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 309 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 310 | TX/RX direction for each kind of interface */ |
| 311 | static const struct ieee80211_txrx_stypes |
| 312 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 313 | [NL80211_IFTYPE_STATION] = { |
| 314 | .tx = 0xffff, |
| 315 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 316 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 317 | }, |
| 318 | [NL80211_IFTYPE_AP] = { |
| 319 | .tx = 0xffff, |
| 320 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 321 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 322 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 323 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 324 | BIT(SIR_MAC_MGMT_AUTH) | |
| 325 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 326 | BIT(SIR_MAC_MGMT_ACTION), |
| 327 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 328 | [NL80211_IFTYPE_ADHOC] = { |
| 329 | .tx = 0xffff, |
| 330 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 331 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 332 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 333 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 334 | BIT(SIR_MAC_MGMT_AUTH) | |
| 335 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 336 | BIT(SIR_MAC_MGMT_ACTION), |
| 337 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 338 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 339 | .tx = 0xffff, |
| 340 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 341 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 342 | }, |
| 343 | [NL80211_IFTYPE_P2P_GO] = { |
| 344 | /* This is also same as for SoftAP */ |
| 345 | .tx = 0xffff, |
| 346 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 347 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 348 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 349 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 350 | BIT(SIR_MAC_MGMT_AUTH) | |
| 351 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 352 | BIT(SIR_MAC_MGMT_ACTION), |
| 353 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 354 | }; |
| 355 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 356 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 357 | static const struct ieee80211_iface_limit |
| 358 | wlan_hdd_iface_limit[] = { |
| 359 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 360 | /* max = 3 ; Our driver create two interfaces during driver init |
| 361 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 362 | * interface until a group is formed. In JB architecture, once the |
| 363 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 364 | * Client. |
| 365 | * When supplicant remove the group, it first issue a set interface |
| 366 | * cmd to change the mode back to Station. In JB this works fine as |
| 367 | * we advertize two station type interface during driver init. |
| 368 | * Some vendors create separate interface for P2P GO/Client, |
| 369 | * after group formation(Third one). But while group remove |
| 370 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 371 | * But as we advertized only two sta type interfaces nl80211 was |
| 372 | * returning error for the third one which was leading to failure in |
| 373 | * delete interface. Ideally while removing the group, supplicant |
| 374 | * should not try to change the 3rd interface mode to Station type. |
| 375 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 376 | * interface type to 3 |
| 377 | */ |
| 378 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 379 | .types = BIT(NL80211_IFTYPE_STATION), |
| 380 | }, |
| 381 | { |
| 382 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 383 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 384 | }, |
| 385 | { |
| 386 | .max = 1, |
| 387 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 388 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 389 | }, |
| 390 | }; |
| 391 | |
| 392 | /* By default, only single channel concurrency is allowed */ |
| 393 | static struct ieee80211_iface_combination |
| 394 | wlan_hdd_iface_combination = { |
| 395 | .limits = wlan_hdd_iface_limit, |
| 396 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 397 | /* |
| 398 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 399 | * and p2p0 interfaces during driver init |
| 400 | * Some vendors create separate interface for P2P operations. |
| 401 | * wlan0: STA interface |
| 402 | * p2p0: P2P Device interface, action frames goes |
| 403 | * through this interface. |
| 404 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 405 | * created for p2p operations(GO/CLIENT interface). |
| 406 | */ |
| 407 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 408 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 409 | .beacon_int_infra_match = false, |
| 410 | }; |
| 411 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 412 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 413 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 414 | |
| 415 | /* Data rate 100KBPS based on IE Index */ |
| 416 | struct index_data_rate_type |
| 417 | { |
| 418 | v_U8_t beacon_rate_index; |
| 419 | v_U16_t supported_rate[4]; |
| 420 | }; |
| 421 | |
| 422 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 423 | The IDX field is the rate index |
| 424 | The HI field is the rate when RSSI is strong or being ignored |
| 425 | (in this case we report actual rate) |
| 426 | The MID field is the rate when RSSI is moderate |
| 427 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 428 | The LO field is the rate when RSSI is low |
| 429 | (in this case we don't report rates, actual current rate used) |
| 430 | */ |
| 431 | static const struct |
| 432 | { |
| 433 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 434 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 435 | } supported_data_rate[] = |
| 436 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 437 | /* IDX HI HM LM LO (RSSI-based index */ |
| 438 | {2, { 10, 10, 10, 0}}, |
| 439 | {4, { 20, 20, 10, 0}}, |
| 440 | {11, { 55, 20, 10, 0}}, |
| 441 | {12, { 60, 55, 20, 0}}, |
| 442 | {18, { 90, 55, 20, 0}}, |
| 443 | {22, {110, 55, 20, 0}}, |
| 444 | {24, {120, 90, 60, 0}}, |
| 445 | {36, {180, 120, 60, 0}}, |
| 446 | {44, {220, 180, 60, 0}}, |
| 447 | {48, {240, 180, 90, 0}}, |
| 448 | {66, {330, 180, 90, 0}}, |
| 449 | {72, {360, 240, 90, 0}}, |
| 450 | {96, {480, 240, 120, 0}}, |
| 451 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 452 | }; |
| 453 | |
| 454 | /* MCS Based rate table */ |
| 455 | static struct index_data_rate_type supported_mcs_rate[] = |
| 456 | { |
| 457 | /* MCS L20 L40 S20 S40 */ |
| 458 | {0, {65, 135, 72, 150}}, |
| 459 | {1, {130, 270, 144, 300}}, |
| 460 | {2, {195, 405, 217, 450}}, |
| 461 | {3, {260, 540, 289, 600}}, |
| 462 | {4, {390, 810, 433, 900}}, |
| 463 | {5, {520, 1080, 578, 1200}}, |
| 464 | {6, {585, 1215, 650, 1350}}, |
| 465 | {7, {650, 1350, 722, 1500}} |
| 466 | }; |
| 467 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 468 | #ifdef WLAN_FEATURE_11AC |
| 469 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 470 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 471 | |
| 472 | struct index_vht_data_rate_type |
| 473 | { |
| 474 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 475 | v_U16_t supported_VHT80_rate[2]; |
| 476 | v_U16_t supported_VHT40_rate[2]; |
| 477 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 478 | }; |
| 479 | |
| 480 | typedef enum |
| 481 | { |
| 482 | DATA_RATE_11AC_MAX_MCS_7, |
| 483 | DATA_RATE_11AC_MAX_MCS_8, |
| 484 | DATA_RATE_11AC_MAX_MCS_9, |
| 485 | DATA_RATE_11AC_MAX_MCS_NA |
| 486 | } eDataRate11ACMaxMcs; |
| 487 | |
| 488 | /* MCS Based VHT rate table */ |
| 489 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 490 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 491 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 492 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 493 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 494 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 495 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 496 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 497 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 498 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 499 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 500 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 501 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 502 | }; |
| 503 | #endif /* WLAN_FEATURE_11AC */ |
| 504 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 505 | extern struct net_device_ops net_ops_struct; |
| 506 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 507 | #ifdef WLAN_NL80211_TESTMODE |
| 508 | enum wlan_hdd_tm_attr |
| 509 | { |
| 510 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 511 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 512 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 513 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 514 | /* keep last */ |
| 515 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 516 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 517 | }; |
| 518 | |
| 519 | enum wlan_hdd_tm_cmd |
| 520 | { |
| 521 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 522 | }; |
| 523 | |
| 524 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 525 | |
| 526 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 527 | { |
| 528 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 529 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 530 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 531 | }; |
| 532 | #endif /* WLAN_NL80211_TESTMODE */ |
| 533 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 534 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 535 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 536 | * This function is called by hdd_wlan_startup() |
| 537 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 538 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 539 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 540 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 541 | { |
| 542 | struct wiphy *wiphy; |
| 543 | ENTER(); |
| 544 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 545 | /* |
| 546 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 547 | */ |
| 548 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 549 | |
| 550 | if (!wiphy) |
| 551 | { |
| 552 | /* Print error and jump into err label and free the memory */ |
| 553 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 554 | return NULL; |
| 555 | } |
| 556 | |
| 557 | return wiphy; |
| 558 | } |
| 559 | |
| 560 | /* |
| 561 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 562 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 563 | * private ioctl to change the band value |
| 564 | */ |
| 565 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 566 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 567 | int i, j; |
| 568 | eNVChannelEnabledType channelEnabledState; |
| 569 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 570 | ENTER(); |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 571 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 572 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 573 | |
| 574 | if (NULL == wiphy->bands[i]) |
| 575 | { |
| 576 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 577 | __func__, i); |
| 578 | continue; |
| 579 | } |
| 580 | |
| 581 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 582 | { |
| 583 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 584 | |
| 585 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 586 | band->channels[j].hw_value); |
| 587 | |
| 588 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 589 | { |
| 590 | // Enable Social channels for P2P |
| 591 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 592 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 593 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 594 | else |
| 595 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 596 | continue; |
| 597 | } |
| 598 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 599 | { |
| 600 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 601 | continue; |
| 602 | } |
| 603 | |
| 604 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 605 | NV_CHANNEL_INVALID == channelEnabledState) |
| 606 | { |
| 607 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 608 | } |
| 609 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 610 | { |
| 611 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 612 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 613 | } |
| 614 | else |
| 615 | { |
| 616 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 617 | |IEEE80211_CHAN_RADAR); |
| 618 | } |
| 619 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 620 | } |
| 621 | return 0; |
| 622 | } |
| 623 | /* |
| 624 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 625 | * This function is called by hdd_wlan_startup() |
| 626 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 627 | * This function is used to initialize and register wiphy structure. |
| 628 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 629 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 630 | struct wiphy *wiphy, |
| 631 | hdd_config_t *pCfg |
| 632 | ) |
| 633 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 634 | int i, j; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 635 | ENTER(); |
| 636 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 637 | /* Now bind the underlying wlan device with wiphy */ |
| 638 | set_wiphy_dev(wiphy, dev); |
| 639 | |
| 640 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 641 | |
| 642 | /* This will disable updating of NL channels from passive to |
| 643 | * active if a beacon is received on passive channel. */ |
| 644 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Amar Singhal | f007319 | 2013-09-20 12:34:56 -0700 | [diff] [blame^] | 645 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 646 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 647 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 648 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 649 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 650 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 651 | | WIPHY_FLAG_OFFCHAN_TX; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 652 | #endif |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 653 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 654 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 655 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 656 | || pCfg->isFastRoamIniFeatureEnabled |
| 657 | #endif |
| 658 | #ifdef FEATURE_WLAN_CCX |
| 659 | || pCfg->isCcxIniFeatureEnabled |
| 660 | #endif |
| 661 | ) |
| 662 | { |
| 663 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 664 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 665 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 666 | #ifdef FEATURE_WLAN_TDLS |
| 667 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 668 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 669 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 670 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 671 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
Madan Mohan Koyyalamudi | 75de010 | 2013-09-17 14:56:29 +0530 | [diff] [blame] | 672 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 673 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 674 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 675 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 676 | #ifdef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 677 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 678 | driver can still register regulatory callback and |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 679 | it will get regulatory settings in wiphy->band[], but |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 680 | driver need to determine what to do with both |
| 681 | regulatory settings */ |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 682 | |
| 683 | wiphy->reg_notifier = wlan_hdd_linux_reg_notifier; |
| 684 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 685 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 686 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 687 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 688 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 689 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 690 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 691 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 692 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 693 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 694 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 695 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 696 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 697 | | BIT(NL80211_IFTYPE_AP); |
| 698 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 699 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 700 | if( pCfg->enableMCC ) |
| 701 | { |
| 702 | /* Currently, supports up to two channels */ |
| 703 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 704 | |
| 705 | if( !pCfg->allowMCCGODiffBI ) |
| 706 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 707 | |
| 708 | } |
| 709 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 710 | wiphy->n_iface_combinations = 1; |
| 711 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 712 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | /* Before registering we need to update the ht capabilitied based |
| 714 | * on ini values*/ |
| 715 | if( !pCfg->ShortGI20MhzEnable ) |
| 716 | { |
| 717 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 718 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 719 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 720 | } |
| 721 | |
| 722 | if( !pCfg->ShortGI40MhzEnable ) |
| 723 | { |
| 724 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 725 | } |
| 726 | |
| 727 | if( !pCfg->nChannelBondingMode5GHz ) |
| 728 | { |
| 729 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 730 | } |
| 731 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 732 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 733 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 734 | |
| 735 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 736 | { |
| 737 | |
| 738 | if (NULL == wiphy->bands[i]) |
| 739 | { |
| 740 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 741 | __func__, i); |
| 742 | continue; |
| 743 | } |
| 744 | |
| 745 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 746 | { |
| 747 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 748 | |
| 749 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 750 | { |
| 751 | // Enable social channels for P2P |
| 752 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 753 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 754 | else |
| 755 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 756 | continue; |
| 757 | } |
| 758 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 759 | { |
| 760 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 761 | continue; |
| 762 | } |
| 763 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 764 | } |
| 765 | /*Initialise the supported cipher suite details*/ |
| 766 | wiphy->cipher_suites = hdd_cipher_suites; |
| 767 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 768 | |
| 769 | /*signal strength in mBm (100*dBm) */ |
| 770 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 771 | |
| 772 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 773 | wiphy->max_remain_on_channel_duration = 1000; |
| 774 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 775 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 776 | EXIT(); |
| 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | /* In this function we are registering wiphy. */ |
| 781 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 782 | { |
| 783 | ENTER(); |
| 784 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 785 | if (0 > wiphy_register(wiphy)) |
| 786 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 787 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 788 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 789 | return -EIO; |
| 790 | } |
| 791 | |
| 792 | EXIT(); |
| 793 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 794 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 795 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 796 | /* In this function we are updating channel list when, |
| 797 | regulatory domain is FCC and country code is US. |
| 798 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 799 | As per FCC smart phone is not a indoor device. |
| 800 | GO should not opeate on indoor channels */ |
| 801 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 802 | { |
| 803 | int j; |
| 804 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 805 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 806 | //Default counrtycode from NV at the time of wiphy initialization. |
| 807 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 808 | &defaultCountryCode[0])) |
| 809 | { |
| 810 | hddLog(LOGE, FL("%s Failed to get default country code from NV")); |
| 811 | } |
| 812 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 813 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 814 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 815 | { |
| 816 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 817 | return; |
| 818 | } |
| 819 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 820 | { |
| 821 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 822 | // Mark UNII -1 band channel as passive |
| 823 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 824 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 829 | /* In this function we will do all post VOS start initialization. |
| 830 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 831 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 832 | */ |
| 833 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 834 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 835 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 836 | /* Register for all P2P action, public action etc frames */ |
| 837 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 838 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 839 | ENTER(); |
| 840 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 841 | /* Right now we are registering these frame when driver is getting |
| 842 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 843 | frame register ops, we will move this code as a part of that */ |
| 844 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 845 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 846 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 847 | |
| 848 | /* GAS Initial Response */ |
| 849 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 850 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 852 | /* GAS Comeback Request */ |
| 853 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 854 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 855 | |
| 856 | /* GAS Comeback Response */ |
| 857 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 858 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 859 | |
| 860 | /* P2P Public Action */ |
| 861 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 862 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 863 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 864 | |
| 865 | /* P2P Action */ |
| 866 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 867 | (v_U8_t*)P2P_ACTION_FRAME, |
| 868 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 869 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 870 | /* WNM BSS Transition Request frame */ |
| 871 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 872 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 873 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 874 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 875 | #ifdef WLAN_FEATURE_11W |
| 876 | /* SA Query Response Action Frame */ |
| 877 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 878 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 879 | SA_QUERY_FRAME_RSP_SIZE ); |
| 880 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 884 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 885 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 886 | /* Register for all P2P action, public action etc frames */ |
| 887 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 888 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 889 | ENTER(); |
| 890 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 891 | /* Right now we are registering these frame when driver is getting |
| 892 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 893 | frame register ops, we will move this code as a part of that */ |
| 894 | /* GAS Initial Request */ |
| 895 | |
| 896 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 897 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 898 | |
| 899 | /* GAS Initial Response */ |
| 900 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 901 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 902 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 903 | /* GAS Comeback Request */ |
| 904 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 905 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 906 | |
| 907 | /* GAS Comeback Response */ |
| 908 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 909 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 910 | |
| 911 | /* P2P Public Action */ |
| 912 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 913 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 914 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 915 | |
| 916 | /* P2P Action */ |
| 917 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 918 | (v_U8_t*)P2P_ACTION_FRAME, |
| 919 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 920 | |
| 921 | #ifdef WLAN_FEATURE_11W |
| 922 | /* SA Query Response Action Frame */ |
| 923 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 924 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 925 | SA_QUERY_FRAME_RSP_SIZE ); |
| 926 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | #ifdef FEATURE_WLAN_WAPI |
| 930 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 931 | const u8 *mac_addr, u8 *key , int key_Len) |
| 932 | { |
| 933 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 934 | tCsrRoamSetKey setKey; |
| 935 | v_BOOL_t isConnected = TRUE; |
| 936 | int status = 0; |
| 937 | v_U32_t roamId= 0xFF; |
| 938 | tANI_U8 *pKeyPtr = NULL; |
| 939 | int n = 0; |
| 940 | |
| 941 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 942 | __func__,pAdapter->device_mode); |
| 943 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 944 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 945 | setKey.keyId = key_index; // Store Key ID |
| 946 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 947 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 948 | setKey.paeRole = 0 ; // the PAE role |
| 949 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 950 | { |
| 951 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 952 | } |
| 953 | else |
| 954 | { |
| 955 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 956 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 957 | } |
| 958 | setKey.keyLength = key_Len; |
| 959 | pKeyPtr = setKey.Key; |
| 960 | memcpy( pKeyPtr, key, key_Len); |
| 961 | |
| 962 | hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x", |
| 963 | __func__, key_Len); |
| 964 | for (n = 0 ; n < key_Len; n++) |
| 965 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 966 | __func__,n,setKey.Key[n]); |
| 967 | |
| 968 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 969 | if ( isConnected ) |
| 970 | { |
| 971 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 972 | pAdapter->sessionId, &setKey, &roamId ); |
| 973 | } |
| 974 | if ( status != 0 ) |
| 975 | { |
| 976 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 977 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 978 | __LINE__, status ); |
| 979 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 980 | } |
| 981 | } |
| 982 | #endif /* FEATURE_WLAN_WAPI*/ |
| 983 | |
| 984 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 985 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 986 | beacon_data_t **ppBeacon, |
| 987 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 988 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 989 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 990 | beacon_data_t **ppBeacon, |
| 991 | struct cfg80211_beacon_data *params, |
| 992 | int dtim_period) |
| 993 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 994 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 995 | int size; |
| 996 | beacon_data_t *beacon = NULL; |
| 997 | beacon_data_t *old = NULL; |
| 998 | int head_len,tail_len; |
| 999 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1000 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1001 | if (params->head && !params->head_len) |
| 1002 | return -EINVAL; |
| 1003 | |
| 1004 | old = pAdapter->sessionCtx.ap.beacon; |
| 1005 | |
| 1006 | if (!params->head && !old) |
| 1007 | return -EINVAL; |
| 1008 | |
| 1009 | if (params->tail && !params->tail_len) |
| 1010 | return -EINVAL; |
| 1011 | |
| 1012 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 1013 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 1014 | if (!params->dtim_period) |
| 1015 | return -EINVAL; |
| 1016 | #endif |
| 1017 | |
| 1018 | if(params->head) |
| 1019 | head_len = params->head_len; |
| 1020 | else |
| 1021 | head_len = old->head_len; |
| 1022 | |
| 1023 | if(params->tail || !old) |
| 1024 | tail_len = params->tail_len; |
| 1025 | else |
| 1026 | tail_len = old->tail_len; |
| 1027 | |
| 1028 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 1029 | |
| 1030 | beacon = kzalloc(size, GFP_KERNEL); |
| 1031 | |
| 1032 | if( beacon == NULL ) |
| 1033 | return -ENOMEM; |
| 1034 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1035 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1036 | if(params->dtim_period || !old ) |
| 1037 | beacon->dtim_period = params->dtim_period; |
| 1038 | else |
| 1039 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1040 | #else |
| 1041 | if(dtim_period || !old ) |
| 1042 | beacon->dtim_period = dtim_period; |
| 1043 | else |
| 1044 | beacon->dtim_period = old->dtim_period; |
| 1045 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1046 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1047 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 1048 | beacon->tail = beacon->head + head_len; |
| 1049 | beacon->head_len = head_len; |
| 1050 | beacon->tail_len = tail_len; |
| 1051 | |
| 1052 | if(params->head) { |
| 1053 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1054 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1055 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1056 | if(old) |
| 1057 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1058 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1059 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1060 | if(params->tail) { |
| 1061 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1062 | } |
| 1063 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1064 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1065 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1066 | } |
| 1067 | |
| 1068 | *ppBeacon = beacon; |
| 1069 | |
| 1070 | kfree(old); |
| 1071 | |
| 1072 | return 0; |
| 1073 | |
| 1074 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1075 | |
| 1076 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1077 | { |
| 1078 | int left = length; |
| 1079 | v_U8_t *ptr = pIes; |
| 1080 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1081 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1082 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1083 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1084 | elem_id = ptr[0]; |
| 1085 | elem_len = ptr[1]; |
| 1086 | left -= 2; |
| 1087 | if(elem_len > left) |
| 1088 | { |
| 1089 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1090 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1091 | eid,elem_len,left); |
| 1092 | return NULL; |
| 1093 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1094 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1095 | { |
| 1096 | return ptr; |
| 1097 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1098 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1099 | left -= elem_len; |
| 1100 | ptr += (elem_len + 2); |
| 1101 | } |
| 1102 | return NULL; |
| 1103 | } |
| 1104 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1105 | /* Check if rate is 11g rate or not */ |
| 1106 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1107 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 1108 | static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1109 | u8 i; |
| 1110 | for (i = 0; i < 8; i++) |
| 1111 | { |
| 1112 | if(rate == gRateArray[i]) |
| 1113 | return TRUE; |
| 1114 | } |
| 1115 | return FALSE; |
| 1116 | } |
| 1117 | |
| 1118 | /* Check for 11g rate and set proper 11g only mode */ |
| 1119 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1120 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1121 | { |
| 1122 | u8 i, num_rates = pIe[0]; |
| 1123 | |
| 1124 | pIe += 1; |
| 1125 | for ( i = 0; i < num_rates; i++) |
| 1126 | { |
| 1127 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1128 | { |
| 1129 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1130 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1131 | if (pIe[i] & BASIC_RATE_MASK) |
| 1132 | { |
| 1133 | /* If we have 11g rate as basic rate, it means mode |
| 1134 | is 11g only mode. |
| 1135 | */ |
| 1136 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1137 | *pCheckRatesfor11g = FALSE; |
| 1138 | } |
| 1139 | } |
| 1140 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1141 | { |
| 1142 | *require_ht = TRUE; |
| 1143 | } |
| 1144 | } |
| 1145 | return; |
| 1146 | } |
| 1147 | |
| 1148 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1149 | { |
| 1150 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1151 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1152 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1153 | u8 checkRatesfor11g = TRUE; |
| 1154 | u8 require_ht = FALSE; |
| 1155 | u8 *pIe=NULL; |
| 1156 | |
| 1157 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1158 | |
| 1159 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1160 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1161 | if (pIe != NULL) |
| 1162 | { |
| 1163 | pIe += 1; |
| 1164 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1165 | &pConfig->SapHw_mode); |
| 1166 | } |
| 1167 | |
| 1168 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1169 | WLAN_EID_EXT_SUPP_RATES); |
| 1170 | if (pIe != NULL) |
| 1171 | { |
| 1172 | |
| 1173 | pIe += 1; |
| 1174 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1175 | &pConfig->SapHw_mode); |
| 1176 | } |
| 1177 | |
| 1178 | if( pConfig->channel > 14 ) |
| 1179 | { |
| 1180 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1181 | } |
| 1182 | |
| 1183 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1184 | WLAN_EID_HT_CAPABILITY); |
| 1185 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1186 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1187 | { |
| 1188 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1189 | if(require_ht) |
| 1190 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1191 | } |
| 1192 | } |
| 1193 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1194 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1195 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1196 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1197 | v_U16_t ielen = 0; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1198 | v_U8_t *pIe = NULL; |
| 1199 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1200 | |
| 1201 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1202 | pBeacon->tail, pBeacon->tail_len); |
| 1203 | |
| 1204 | if (pIe) |
| 1205 | { |
| 1206 | ielen = pIe[1] + 2; |
| 1207 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1208 | { |
| 1209 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1210 | } |
| 1211 | else |
| 1212 | { |
| 1213 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1214 | return -EINVAL; |
| 1215 | } |
| 1216 | *total_ielen += ielen; |
| 1217 | } |
| 1218 | return 0; |
| 1219 | } |
| 1220 | |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1221 | static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter, |
| 1222 | v_U8_t *genie, v_U8_t *total_ielen) |
| 1223 | { |
| 1224 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1225 | int left = pBeacon->tail_len; |
| 1226 | v_U8_t *ptr = pBeacon->tail; |
| 1227 | v_U8_t elem_id, elem_len; |
| 1228 | v_U16_t ielen = 0; |
| 1229 | |
| 1230 | if ( NULL == ptr || 0 == left ) |
| 1231 | return; |
| 1232 | |
| 1233 | while (left >= 2) |
| 1234 | { |
| 1235 | elem_id = ptr[0]; |
| 1236 | elem_len = ptr[1]; |
| 1237 | left -= 2; |
| 1238 | if (elem_len > left) |
| 1239 | { |
| 1240 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1241 | "****Invalid IEs eid = %d elem_len=%d left=%d*****", |
| 1242 | elem_id, elem_len, left); |
| 1243 | return; |
| 1244 | } |
| 1245 | if (IE_EID_VENDOR == elem_id) |
| 1246 | { |
| 1247 | /* skipping the VSIE's which we don't want to include or |
| 1248 | * it will be included by existing code |
| 1249 | */ |
| 1250 | if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) && |
| 1251 | #ifdef WLAN_FEATURE_WFD |
| 1252 | (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) && |
| 1253 | #endif |
| 1254 | (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1255 | (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1256 | (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) && |
| 1257 | (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1258 | (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0)) |
| 1259 | { |
| 1260 | ielen = ptr[1] + 2; |
| 1261 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1262 | { |
| 1263 | vos_mem_copy(&genie[*total_ielen], ptr, ielen); |
| 1264 | *total_ielen += ielen; |
| 1265 | } |
| 1266 | else |
| 1267 | { |
| 1268 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1269 | "IE Length is too big " |
| 1270 | "IEs eid=%d elem_len=%d total_ie_lent=%d", |
| 1271 | elem_id, elem_len, *total_ielen); |
| 1272 | } |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | left -= elem_len; |
| 1277 | ptr += (elem_len + 2); |
| 1278 | } |
| 1279 | return; |
| 1280 | } |
| 1281 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1282 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1283 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1284 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1285 | #else |
| 1286 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1287 | struct cfg80211_beacon_data *params) |
| 1288 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1289 | { |
| 1290 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1291 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1292 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1293 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1294 | |
| 1295 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1296 | |
| 1297 | if(genie == NULL) { |
| 1298 | |
| 1299 | return -ENOMEM; |
| 1300 | } |
| 1301 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1302 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1303 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1304 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1305 | ret = -EINVAL; |
| 1306 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1310 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1311 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1312 | { |
| 1313 | ret = -EINVAL; |
| 1314 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1315 | } |
| 1316 | #endif |
| 1317 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1318 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1319 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1320 | { |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1321 | ret = -EINVAL; |
| 1322 | goto done; |
| 1323 | } |
| 1324 | |
| 1325 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1326 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1327 | wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1328 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1329 | |
| 1330 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1331 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1332 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1333 | { |
| 1334 | hddLog(LOGE, |
| 1335 | "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] | 1336 | ret = -EINVAL; |
| 1337 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1341 | WNI_CFG_PROBE_RSP_BCN_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_BCN_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 | // Added for ProResp IE |
| 1353 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1354 | { |
| 1355 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1356 | u8 probe_rsp_ie_len[3] = {0}; |
| 1357 | u8 counter = 0; |
| 1358 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1359 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1360 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1361 | Store More then 255 bytes into One Variable. |
| 1362 | */ |
| 1363 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1364 | { |
| 1365 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1366 | { |
| 1367 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1368 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1369 | } |
| 1370 | else |
| 1371 | { |
| 1372 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1373 | rem_probe_resp_ie_len = 0; |
| 1374 | } |
| 1375 | } |
| 1376 | |
| 1377 | rem_probe_resp_ie_len = 0; |
| 1378 | |
| 1379 | if (probe_rsp_ie_len[0] > 0) |
| 1380 | { |
| 1381 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1382 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1383 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1384 | probe_rsp_ie_len[0], NULL, |
| 1385 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1386 | { |
| 1387 | hddLog(LOGE, |
| 1388 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1389 | ret = -EINVAL; |
| 1390 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1391 | } |
| 1392 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1393 | } |
| 1394 | |
| 1395 | if (probe_rsp_ie_len[1] > 0) |
| 1396 | { |
| 1397 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1398 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1399 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1400 | probe_rsp_ie_len[1], NULL, |
| 1401 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1402 | { |
| 1403 | hddLog(LOGE, |
| 1404 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1405 | ret = -EINVAL; |
| 1406 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | } |
| 1408 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1409 | } |
| 1410 | |
| 1411 | if (probe_rsp_ie_len[2] > 0) |
| 1412 | { |
| 1413 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1414 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1415 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1416 | probe_rsp_ie_len[2], NULL, |
| 1417 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1418 | { |
| 1419 | hddLog(LOGE, |
| 1420 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1421 | ret = -EINVAL; |
| 1422 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1423 | } |
| 1424 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1425 | } |
| 1426 | |
| 1427 | if (probe_rsp_ie_len[1] == 0 ) |
| 1428 | { |
| 1429 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1430 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1431 | eANI_BOOLEAN_FALSE) ) |
| 1432 | { |
| 1433 | hddLog(LOGE, |
| 1434 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n"); |
| 1435 | } |
| 1436 | } |
| 1437 | |
| 1438 | if (probe_rsp_ie_len[2] == 0 ) |
| 1439 | { |
| 1440 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1441 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1442 | eANI_BOOLEAN_FALSE) ) |
| 1443 | { |
| 1444 | hddLog(LOGE, |
| 1445 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n"); |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1450 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1451 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1452 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1453 | == eHAL_STATUS_FAILURE) |
| 1454 | { |
| 1455 | hddLog(LOGE, |
| 1456 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1457 | ret = -EINVAL; |
| 1458 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1459 | } |
| 1460 | } |
| 1461 | else |
| 1462 | { |
| 1463 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1464 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1465 | |
| 1466 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1467 | "%s: No Probe Response IE received in set beacon", |
| 1468 | __func__); |
| 1469 | } |
| 1470 | |
| 1471 | // Added for AssocResp IE |
| 1472 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1473 | { |
| 1474 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1475 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1476 | params->assocresp_ies_len, NULL, |
| 1477 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1478 | { |
| 1479 | hddLog(LOGE, |
| 1480 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1481 | ret = -EINVAL; |
| 1482 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1483 | } |
| 1484 | |
| 1485 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1486 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1487 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1488 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1489 | == eHAL_STATUS_FAILURE) |
| 1490 | { |
| 1491 | hddLog(LOGE, |
| 1492 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1493 | ret = -EINVAL; |
| 1494 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1495 | } |
| 1496 | } |
| 1497 | else |
| 1498 | { |
| 1499 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1500 | "%s: No Assoc Response IE received in set beacon", |
| 1501 | __func__); |
| 1502 | |
| 1503 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1504 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1505 | eANI_BOOLEAN_FALSE) ) |
| 1506 | { |
| 1507 | hddLog(LOGE, |
| 1508 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 1509 | } |
| 1510 | } |
| 1511 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1512 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1513 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1514 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1515 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1516 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1517 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1518 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1519 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1520 | * wlan_hdd_cfg80211_set_channel() |
| 1521 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1522 | * channel list. |
| 1523 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 1524 | VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1525 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1526 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1527 | v_U32_t num_ch = 0; |
| 1528 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1529 | u32 indx = 0; |
| 1530 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1531 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1532 | 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] | 1533 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1534 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1535 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1536 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1537 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1538 | /* Validate the channel */ |
| 1539 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1540 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1541 | if ( channel == rfChannels[count].channelNum ) |
| 1542 | { |
| 1543 | fValidChannel = TRUE; |
| 1544 | break; |
| 1545 | } |
| 1546 | } |
| 1547 | if (fValidChannel != TRUE) |
| 1548 | { |
| 1549 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1550 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1551 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1552 | } |
| 1553 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1554 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1555 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1556 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1557 | valid_ch, &num_ch)) |
| 1558 | { |
| 1559 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1560 | "%s: failed to get valid channel list", __func__); |
| 1561 | return VOS_STATUS_E_FAILURE; |
| 1562 | } |
| 1563 | for (indx = 0; indx < num_ch; indx++) |
| 1564 | { |
| 1565 | if (channel == valid_ch[indx]) |
| 1566 | { |
| 1567 | break; |
| 1568 | } |
| 1569 | } |
| 1570 | |
| 1571 | if (indx >= num_ch) |
| 1572 | { |
| 1573 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1574 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1575 | return VOS_STATUS_E_FAILURE; |
| 1576 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1577 | } |
| 1578 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1579 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1580 | } |
| 1581 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1582 | /** |
| 1583 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1584 | * This function is used to set the channel number |
| 1585 | */ |
| 1586 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1587 | struct ieee80211_channel *chan, |
| 1588 | enum nl80211_channel_type channel_type |
| 1589 | ) |
| 1590 | { |
| 1591 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1592 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1593 | hdd_adapter_t *pAdapter = NULL; |
| 1594 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1595 | hdd_context_t *pHddCtx; |
| 1596 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1597 | |
| 1598 | ENTER(); |
| 1599 | |
| 1600 | if( NULL == dev ) |
| 1601 | { |
| 1602 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1603 | "%s: Called with dev = NULL.\n", __func__); |
| 1604 | return -ENODEV; |
| 1605 | } |
| 1606 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1607 | |
| 1608 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1609 | "%s: device_mode = %d freq = %d \n",__func__, |
| 1610 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1611 | |
| 1612 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1613 | status = wlan_hdd_validate_context(pHddCtx); |
| 1614 | |
| 1615 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1616 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1617 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1618 | "%s: HDD context is not valid", __func__); |
| 1619 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1620 | } |
| 1621 | |
| 1622 | /* |
| 1623 | * Do freq to chan conversion |
| 1624 | * TODO: for 11a |
| 1625 | */ |
| 1626 | |
| 1627 | channel = ieee80211_frequency_to_channel(freq); |
| 1628 | |
| 1629 | /* Check freq range */ |
| 1630 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1631 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1632 | { |
| 1633 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1634 | "%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1635 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1636 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1637 | return -EINVAL; |
| 1638 | } |
| 1639 | |
| 1640 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1641 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1642 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1643 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1644 | { |
| 1645 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1646 | { |
| 1647 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1648 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1649 | return -EINVAL; |
| 1650 | } |
| 1651 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1652 | "%s: set channel to [%d] for device mode =%d", |
| 1653 | __func__, channel,pAdapter->device_mode); |
| 1654 | } |
| 1655 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1656 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1657 | ) |
| 1658 | { |
| 1659 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1660 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1661 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1662 | |
| 1663 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1664 | { |
| 1665 | /* Link is up then return cant set channel*/ |
| 1666 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1667 | "%s: IBSS Associated, can't set the channel\n", __func__); |
| 1668 | return -EINVAL; |
| 1669 | } |
| 1670 | |
| 1671 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1672 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1673 | pRoamProfile->ChannelInfo.ChannelList = |
| 1674 | &pHddStaCtx->conn_info.operationChannel; |
| 1675 | } |
| 1676 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1677 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1678 | ) |
| 1679 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1680 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1681 | { |
| 1682 | if(VOS_STATUS_SUCCESS != |
| 1683 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1684 | { |
| 1685 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1686 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1687 | return -EINVAL; |
| 1688 | } |
| 1689 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1690 | } |
| 1691 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1692 | { |
| 1693 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1694 | |
| 1695 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1696 | channel set by supplicant |
| 1697 | */ |
| 1698 | if ( cfg_param->apAutoChannelSelection ) |
| 1699 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1700 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1701 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1702 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1703 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1704 | __func__, pAdapter->device_mode); |
| 1705 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1706 | else |
| 1707 | { |
| 1708 | if(VOS_STATUS_SUCCESS != |
| 1709 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1710 | { |
| 1711 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1712 | "%s: Invalid Channel [%d] \n", __func__, channel); |
| 1713 | return -EINVAL; |
| 1714 | } |
| 1715 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1716 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1717 | } |
| 1718 | } |
| 1719 | else |
| 1720 | { |
| 1721 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1722 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1723 | return -EINVAL; |
| 1724 | } |
| 1725 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1726 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1727 | } |
| 1728 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1729 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1730 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1731 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1732 | #else |
| 1733 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1734 | struct cfg80211_beacon_data *params, |
| 1735 | const u8 *ssid, size_t ssid_len, |
| 1736 | enum nl80211_hidden_ssid hidden_ssid) |
| 1737 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1738 | { |
| 1739 | tsap_Config_t *pConfig; |
| 1740 | beacon_data_t *pBeacon = NULL; |
| 1741 | struct ieee80211_mgmt *pMgmt_frame; |
| 1742 | v_U8_t *pIe=NULL; |
| 1743 | v_U16_t capab_info; |
| 1744 | eCsrAuthType RSNAuthType; |
| 1745 | eCsrEncryptionType RSNEncryptType; |
| 1746 | eCsrEncryptionType mcRSNEncryptType; |
| 1747 | int status = VOS_STATUS_SUCCESS; |
| 1748 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1749 | hdd_hostapd_state_t *pHostapdState; |
| 1750 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1751 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1752 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1753 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1754 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1755 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1756 | |
| 1757 | ENTER(); |
| 1758 | |
| 1759 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1760 | |
| 1761 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1762 | |
| 1763 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1764 | |
| 1765 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1766 | |
| 1767 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1768 | |
| 1769 | //channel is already set in the set_channel Call back |
| 1770 | //pConfig->channel = pCommitConfig->channel; |
| 1771 | |
| 1772 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1773 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1774 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1775 | |
| 1776 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1777 | |
| 1778 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n", |
| 1779 | pConfig->dtim_period); |
| 1780 | |
| 1781 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1782 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1783 | { |
| 1784 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1785 | WLAN_EID_COUNTRY); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1786 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1787 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1788 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1789 | pConfig->ieee80211d = 1; |
| 1790 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1791 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1792 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1793 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1794 | else |
| 1795 | { |
| 1796 | pConfig->ieee80211d = 0; |
| 1797 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1798 | /* |
| 1799 | * If auto channel is configured i.e. channel is 0, |
| 1800 | * so skip channel validation. |
| 1801 | */ |
| 1802 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1803 | { |
| 1804 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1805 | { |
| 1806 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1807 | "%s: Invalid Channel [%d] \n", __func__, pConfig->channel); |
| 1808 | return -EINVAL; |
| 1809 | } |
| 1810 | } |
| 1811 | else |
| 1812 | { |
| 1813 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1814 | { |
| 1815 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1816 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1817 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1818 | } |
| 1819 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1820 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1821 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1822 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1823 | { |
| 1824 | pConfig->ieee80211d = 0; |
| 1825 | } |
| 1826 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1827 | |
| 1828 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1829 | |
| 1830 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1831 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1832 | |
| 1833 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1834 | |
| 1835 | /*Set wps station to configured*/ |
| 1836 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1837 | |
| 1838 | if(pIe) |
| 1839 | { |
| 1840 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1841 | { |
| 1842 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n"); |
| 1843 | return -EINVAL; |
| 1844 | } |
| 1845 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1846 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1847 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1848 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1849 | * WPS state |
| 1850 | */ |
| 1851 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1852 | { |
| 1853 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1854 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1855 | { |
| 1856 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1857 | } |
| 1858 | } |
| 1859 | } |
| 1860 | else |
| 1861 | { |
| 1862 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1863 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1864 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1865 | |
| 1866 | pConfig->RSNWPAReqIELength = 0; |
| 1867 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1868 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1869 | WLAN_EID_RSN); |
| 1870 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1871 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1872 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1873 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1874 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1875 | /* The actual processing may eventually be more extensive than |
| 1876 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1877 | * by the app. |
| 1878 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1879 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1880 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1881 | &RSNEncryptType, |
| 1882 | &mcRSNEncryptType, |
| 1883 | &RSNAuthType, |
| 1884 | pConfig->pRSNWPAReqIE[1]+2, |
| 1885 | pConfig->pRSNWPAReqIE ); |
| 1886 | |
| 1887 | if( VOS_STATUS_SUCCESS == status ) |
| 1888 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1889 | /* Now copy over all the security attributes you have |
| 1890 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1891 | * */ |
| 1892 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1893 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1894 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1895 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1896 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1897 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1898 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1899 | } |
| 1900 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1901 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1902 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1903 | pBeacon->tail, pBeacon->tail_len); |
| 1904 | |
| 1905 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 1906 | { |
| 1907 | if (pConfig->pRSNWPAReqIE) |
| 1908 | { |
| 1909 | /*Mixed mode WPA/WPA2*/ |
| 1910 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 1911 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 1912 | } |
| 1913 | else |
| 1914 | { |
| 1915 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1916 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1917 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1918 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1919 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1920 | &RSNEncryptType, |
| 1921 | &mcRSNEncryptType, |
| 1922 | &RSNAuthType, |
| 1923 | pConfig->pRSNWPAReqIE[1]+2, |
| 1924 | pConfig->pRSNWPAReqIE ); |
| 1925 | |
| 1926 | if( VOS_STATUS_SUCCESS == status ) |
| 1927 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1928 | /* Now copy over all the security attributes you have |
| 1929 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1930 | * */ |
| 1931 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1932 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1933 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1934 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1935 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1936 | "EncryptionType = %d mcEncryptionType = %d\n"), |
| 1937 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 1938 | } |
| 1939 | } |
| 1940 | } |
| 1941 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1942 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 1943 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 1944 | return -EINVAL; |
| 1945 | } |
| 1946 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1947 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 1948 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1949 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1950 | if (params->ssid != NULL) |
| 1951 | { |
| 1952 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 1953 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 1954 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1955 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1956 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1957 | #else |
| 1958 | if (ssid != NULL) |
| 1959 | { |
| 1960 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 1961 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 1962 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 1963 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 1964 | } |
| 1965 | #endif |
| 1966 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1967 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1968 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1969 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1970 | /* default value */ |
| 1971 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 1972 | pConfig->num_accept_mac = 0; |
| 1973 | pConfig->num_deny_mac = 0; |
| 1974 | |
| 1975 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 1976 | pBeacon->tail, pBeacon->tail_len); |
| 1977 | |
| 1978 | /* pIe for black list is following form: |
| 1979 | type : 1 byte |
| 1980 | length : 1 byte |
| 1981 | OUI : 4 bytes |
| 1982 | acl type : 1 byte |
| 1983 | no of mac addr in black list: 1 byte |
| 1984 | 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] | 1985 | */ |
| 1986 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1987 | { |
| 1988 | pConfig->SapMacaddr_acl = pIe[6]; |
| 1989 | pConfig->num_deny_mac = pIe[7]; |
| 1990 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n", |
| 1991 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 1992 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 1993 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1994 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 1995 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 1996 | { |
| 1997 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 1998 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1999 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2000 | } |
| 2001 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 2002 | pBeacon->tail, pBeacon->tail_len); |
| 2003 | |
| 2004 | /* pIe for white list is following form: |
| 2005 | type : 1 byte |
| 2006 | length : 1 byte |
| 2007 | OUI : 4 bytes |
| 2008 | acl type : 1 byte |
| 2009 | no of mac addr in white list: 1 byte |
| 2010 | 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] | 2011 | */ |
| 2012 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2013 | { |
| 2014 | pConfig->SapMacaddr_acl = pIe[6]; |
| 2015 | pConfig->num_accept_mac = pIe[7]; |
| 2016 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n", |
| 2017 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2018 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 2019 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2020 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2021 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 2022 | { |
| 2023 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2024 | acl_entry++; |
| 2025 | } |
| 2026 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2027 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2028 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 2029 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2030 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2031 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
| 2032 | * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini . |
| 2033 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */ |
| 2034 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 2035 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2036 | (((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] | 2037 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
| 2038 | ((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] | 2039 | { |
| 2040 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 2041 | |
| 2042 | /* Disable VHT support in 2.4 GHz band */ |
| 2043 | if (pConfig->channel <= 14 && |
| 2044 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE) |
| 2045 | { |
| 2046 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 2047 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2048 | } |
| 2049 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2050 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 2051 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 2052 | { |
| 2053 | sme_SelectCBMode(hHal, |
| 2054 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 2055 | pConfig->channel); |
| 2056 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2057 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 2058 | pConfig->ht_capab = |
| 2059 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 2060 | |
| 2061 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 2062 | { |
| 2063 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 2064 | return -EINVAL; |
| 2065 | } |
| 2066 | |
| 2067 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2068 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2069 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 2070 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2071 | pConfig->obssProtEnabled = |
| 2072 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2073 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2074 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2075 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2076 | hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2077 | hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int, |
| 2078 | (int)pConfig->channel); |
| 2079 | hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2080 | hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy, |
| 2081 | pConfig->authType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2082 | hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2083 | hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2084 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"), |
| 2085 | pConfig->protEnabled, pConfig->obssProtEnabled); |
| 2086 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2087 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2088 | { |
| 2089 | //Bss already started. just return. |
| 2090 | //TODO Probably it should update some beacon params. |
| 2091 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 2092 | EXIT(); |
| 2093 | return 0; |
| 2094 | } |
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 | pConfig->persona = pHostapdAdapter->device_mode; |
| 2097 | |
| 2098 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 2099 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 2100 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 2101 | { |
| 2102 | hddLog(LOGE,FL("SAP Start Bss fail\n")); |
| 2103 | return -EINVAL; |
| 2104 | } |
| 2105 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2106 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2107 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2108 | |
| 2109 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2110 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2111 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2112 | { |
| 2113 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2114 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2115 | VOS_ASSERT(0); |
| 2116 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2117 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2118 | //Succesfully started Bss update the state bit. |
| 2119 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2120 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2121 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2122 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2123 | { |
| 2124 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2125 | { |
| 2126 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2127 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2128 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2129 | } |
| 2130 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2131 | { |
| 2132 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2133 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2134 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2135 | } |
| 2136 | } |
| 2137 | #endif |
| 2138 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2139 | pHostapdState->bCommit = TRUE; |
| 2140 | EXIT(); |
| 2141 | |
| 2142 | return 0; |
| 2143 | } |
| 2144 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2145 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2146 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2147 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2148 | struct beacon_parameters *params) |
| 2149 | { |
| 2150 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2151 | hdd_context_t *pHddCtx; |
| 2152 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2153 | |
| 2154 | ENTER(); |
| 2155 | |
| 2156 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode); |
| 2157 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2158 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2159 | status = wlan_hdd_validate_context(pHddCtx); |
| 2160 | |
| 2161 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2162 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2164 | "%s: HDD context is not valid", __func__); |
| 2165 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2166 | } |
| 2167 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2168 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2169 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2170 | ) |
| 2171 | { |
| 2172 | beacon_data_t *old,*new; |
| 2173 | |
| 2174 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2175 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2176 | if (old) |
| 2177 | return -EALREADY; |
| 2178 | |
| 2179 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2180 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2181 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2182 | { |
| 2183 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2184 | "%s:Error!!! Allocating the new beacon\n",__func__); |
| 2185 | return -EINVAL; |
| 2186 | } |
| 2187 | |
| 2188 | pAdapter->sessionCtx.ap.beacon = new; |
| 2189 | |
| 2190 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2191 | } |
| 2192 | |
| 2193 | EXIT(); |
| 2194 | return status; |
| 2195 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2196 | |
| 2197 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2198 | struct net_device *dev, |
| 2199 | struct beacon_parameters *params) |
| 2200 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2201 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2202 | hdd_context_t *pHddCtx; |
| 2203 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2204 | |
| 2205 | ENTER(); |
| 2206 | |
| 2207 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2208 | __func__,pAdapter->device_mode); |
| 2209 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2210 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2211 | status = wlan_hdd_validate_context(pHddCtx); |
| 2212 | |
| 2213 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2214 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2215 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2216 | "%s: HDD context is not valid", __func__); |
| 2217 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2218 | } |
| 2219 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2220 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2221 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2222 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2223 | { |
| 2224 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2225 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2226 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2227 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2228 | if (!old) |
| 2229 | return -ENOENT; |
| 2230 | |
| 2231 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2232 | |
| 2233 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2234 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2235 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2236 | return -EINVAL; |
| 2237 | } |
| 2238 | |
| 2239 | pAdapter->sessionCtx.ap.beacon = new; |
| 2240 | |
| 2241 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2242 | } |
| 2243 | |
| 2244 | EXIT(); |
| 2245 | return status; |
| 2246 | } |
| 2247 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2248 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2249 | |
| 2250 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2251 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2252 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2253 | #else |
| 2254 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2255 | struct net_device *dev) |
| 2256 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2257 | { |
| 2258 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2259 | hdd_context_t *pHddCtx = NULL; |
| 2260 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2261 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2262 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2263 | |
| 2264 | ENTER(); |
| 2265 | |
| 2266 | if (NULL == pAdapter) |
| 2267 | { |
| 2268 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2269 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2270 | return -ENODEV; |
| 2271 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2272 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2273 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2274 | status = wlan_hdd_validate_context(pHddCtx); |
| 2275 | |
| 2276 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2277 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2278 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2279 | "%s: HDD context is not valid", __func__); |
| 2280 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2281 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2282 | |
| 2283 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2284 | if (NULL == staAdapter) |
| 2285 | { |
| 2286 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2287 | if (NULL == staAdapter) |
| 2288 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2289 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2290 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2291 | return -ENODEV; |
| 2292 | } |
| 2293 | } |
| 2294 | |
| 2295 | pScanInfo = &pHddCtx->scan_info; |
| 2296 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2297 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2298 | __func__,pAdapter->device_mode); |
| 2299 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2300 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 2301 | { |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2302 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 2303 | hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2304 | status = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2305 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2306 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
| 2307 | if (!status) |
| 2308 | { |
| 2309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 2310 | "%s: Timeout occurred while waiting for abortscan" , |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2311 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2312 | VOS_ASSERT(pScanInfo->mScanPending); |
| 2313 | return 0; |
| 2314 | } |
| 2315 | } |
| 2316 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2317 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2318 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2319 | ) |
| 2320 | { |
| 2321 | beacon_data_t *old; |
| 2322 | |
| 2323 | old = pAdapter->sessionCtx.ap.beacon; |
| 2324 | |
| 2325 | if (!old) |
| 2326 | return -ENOENT; |
| 2327 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2328 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2329 | |
| 2330 | mutex_lock(&pHddCtx->sap_lock); |
| 2331 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2332 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2333 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2334 | { |
| 2335 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2336 | |
| 2337 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2338 | |
| 2339 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2340 | { |
| 2341 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2342 | ("ERROR: HDD vos wait for single_event failed!!\n")); |
| 2343 | VOS_ASSERT(0); |
| 2344 | } |
| 2345 | } |
| 2346 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2347 | } |
| 2348 | mutex_unlock(&pHddCtx->sap_lock); |
| 2349 | |
| 2350 | if(status != VOS_STATUS_SUCCESS) |
| 2351 | { |
| 2352 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2353 | "%s:Error!!! Stopping the BSS\n",__func__); |
| 2354 | return -EINVAL; |
| 2355 | } |
| 2356 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2357 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2358 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2359 | ==eHAL_STATUS_FAILURE) |
| 2360 | { |
| 2361 | hddLog(LOGE, |
| 2362 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n"); |
| 2363 | } |
| 2364 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2365 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2366 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2367 | eANI_BOOLEAN_FALSE) ) |
| 2368 | { |
| 2369 | hddLog(LOGE, |
| 2370 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n"); |
| 2371 | } |
| 2372 | |
| 2373 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2374 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2375 | |
| 2376 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2377 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2378 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2379 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2380 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2381 | { |
| 2382 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2383 | "GO got removed"); |
| 2384 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2385 | } |
| 2386 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2387 | } |
| 2388 | EXIT(); |
| 2389 | return status; |
| 2390 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2391 | |
| 2392 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2393 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2394 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2395 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2396 | struct cfg80211_ap_settings *params) |
| 2397 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2398 | hdd_adapter_t *pAdapter; |
| 2399 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2400 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2401 | |
| 2402 | ENTER(); |
| 2403 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2404 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2405 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2406 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2407 | "%s: Device is Null", __func__); |
| 2408 | return -ENODEV; |
| 2409 | } |
| 2410 | |
| 2411 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2412 | if (NULL == pAdapter) |
| 2413 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2414 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2415 | "%s: HDD adapter is Null", __func__); |
| 2416 | return -ENODEV; |
| 2417 | } |
| 2418 | |
| 2419 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2420 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2421 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2422 | "%s: HDD adapter magic is invalid", __func__); |
| 2423 | return -ENODEV; |
| 2424 | } |
| 2425 | |
| 2426 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2427 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2428 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2429 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2430 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2431 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2432 | "%s: HDD context is not valid", __func__); |
| 2433 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2434 | } |
| 2435 | |
| 2436 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2437 | __func__, pAdapter->device_mode); |
| 2438 | |
| 2439 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2440 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2441 | ) |
| 2442 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2443 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2444 | |
| 2445 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2446 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2447 | if (old) |
| 2448 | return -EALREADY; |
| 2449 | |
| 2450 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2451 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2452 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2453 | { |
| 2454 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2455 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2456 | return -EINVAL; |
| 2457 | } |
| 2458 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2459 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2460 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 2461 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2462 | params->channel, params->channel_type); |
| 2463 | #else |
| 2464 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 2465 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2466 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2467 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2468 | params->ssid_len, params->hidden_ssid); |
| 2469 | } |
| 2470 | |
| 2471 | EXIT(); |
| 2472 | return status; |
| 2473 | } |
| 2474 | |
| 2475 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2476 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2477 | struct net_device *dev, |
| 2478 | struct cfg80211_beacon_data *params) |
| 2479 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2480 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2481 | hdd_context_t *pHddCtx; |
| 2482 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2483 | |
| 2484 | ENTER(); |
| 2485 | |
| 2486 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2487 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2488 | |
| 2489 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2490 | status = wlan_hdd_validate_context(pHddCtx); |
| 2491 | |
| 2492 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2493 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2494 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2495 | "%s: HDD context is not valid", __func__); |
| 2496 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2497 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2498 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2499 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2500 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2501 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2502 | { |
| 2503 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2504 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2505 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2506 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2507 | if (!old) |
| 2508 | return -ENOENT; |
| 2509 | |
| 2510 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2511 | |
| 2512 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2513 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2514 | "%s: Error!!! Allocating the new beacon\n",__func__); |
| 2515 | return -EINVAL; |
| 2516 | } |
| 2517 | |
| 2518 | pAdapter->sessionCtx.ap.beacon = new; |
| 2519 | |
| 2520 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2521 | } |
| 2522 | |
| 2523 | EXIT(); |
| 2524 | return status; |
| 2525 | } |
| 2526 | |
| 2527 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2528 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2529 | |
| 2530 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2531 | struct net_device *dev, |
| 2532 | struct bss_parameters *params) |
| 2533 | { |
| 2534 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2535 | |
| 2536 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2537 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2538 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 2539 | __func__,pAdapter->device_mode); |
| 2540 | |
| 2541 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2542 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2543 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2544 | { |
| 2545 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2546 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2547 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2548 | { |
| 2549 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2550 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2551 | } |
| 2552 | |
| 2553 | EXIT(); |
| 2554 | return 0; |
| 2555 | } |
| 2556 | |
| 2557 | /* |
| 2558 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2559 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2560 | */ |
| 2561 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2562 | struct net_device *ndev, |
| 2563 | enum nl80211_iftype type, |
| 2564 | u32 *flags, |
| 2565 | struct vif_params *params |
| 2566 | ) |
| 2567 | { |
| 2568 | struct wireless_dev *wdev; |
| 2569 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 2570 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2571 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2572 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2573 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2574 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2575 | eMib_dot11DesiredBssType connectedBssType; |
| 2576 | VOS_STATUS status; |
| 2577 | |
| 2578 | ENTER(); |
| 2579 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2580 | status = wlan_hdd_validate_context(pHddCtx); |
| 2581 | |
| 2582 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2583 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2584 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2585 | "%s: HDD context is not valid", __func__); |
| 2586 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2587 | } |
| 2588 | |
| 2589 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2590 | __func__, pAdapter->device_mode); |
| 2591 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2592 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2593 | wdev = ndev->ieee80211_ptr; |
| 2594 | |
| 2595 | #ifdef WLAN_BTAMP_FEATURE |
| 2596 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2597 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2598 | (NL80211_IFTYPE_AP == type)|| |
| 2599 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2600 | { |
| 2601 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2602 | // stop AMP traffic |
| 2603 | status = WLANBAP_StopAmp(); |
| 2604 | if(VOS_STATUS_SUCCESS != status ) |
| 2605 | { |
| 2606 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2607 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2608 | "%s: Failed to stop AMP", __func__); |
| 2609 | return -EINVAL; |
| 2610 | } |
| 2611 | } |
| 2612 | #endif //WLAN_BTAMP_FEATURE |
| 2613 | /* Reset the current device mode bit mask*/ |
| 2614 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2615 | |
| 2616 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2617 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2618 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2619 | ) |
| 2620 | { |
| 2621 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2622 | pRoamProfile = &pWextState->roamProfile; |
| 2623 | LastBSSType = pRoamProfile->BSSType; |
| 2624 | |
| 2625 | switch (type) |
| 2626 | { |
| 2627 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2628 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2629 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2630 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2631 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2632 | #ifdef WLAN_FEATURE_11AC |
| 2633 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2634 | { |
| 2635 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2636 | } |
| 2637 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2638 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2639 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2640 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2641 | //Check for sub-string p2p to confirm its a p2p interface |
| 2642 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2643 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2644 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2645 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2646 | } |
| 2647 | else |
| 2648 | { |
| 2649 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2650 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2651 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2652 | #ifdef FEATURE_WLAN_TDLS |
| 2653 | /* The open adapter for the p2p shall skip initializations in |
| 2654 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 2655 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 2656 | * tdls_init when the change_iface sets the device mode to |
| 2657 | * WLAN_HDD_P2P_CLIENT. |
| 2658 | */ |
| 2659 | |
| 2660 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 2661 | { |
| 2662 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 2663 | { |
| 2664 | return -EINVAL; |
| 2665 | } |
| 2666 | } |
| 2667 | #endif |
| 2668 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2669 | break; |
| 2670 | case NL80211_IFTYPE_ADHOC: |
| 2671 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2672 | "%s: setting interface Type to ADHOC", __func__); |
| 2673 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2674 | pRoamProfile->phyMode = |
| 2675 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2676 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2677 | wdev->iftype = type; |
| 2678 | break; |
| 2679 | |
| 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 | { |
| 2683 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2684 | "%s: setting interface Type to %s", __func__, |
| 2685 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2686 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2687 | //Cancel any remain on channel for GO mode |
| 2688 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2689 | { |
| 2690 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2691 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2692 | if (NL80211_IFTYPE_AP == type) |
| 2693 | { |
| 2694 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2695 | * address. This will take one HW STA and the max number of clients |
| 2696 | * that can connect to softAP will be reduced by one. so while changing |
| 2697 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2698 | * interface as it is not required in SoftAP mode. |
| 2699 | */ |
| 2700 | |
| 2701 | // Get P2P Adapter |
| 2702 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2703 | |
| 2704 | if (pP2pAdapter) |
| 2705 | { |
| 2706 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2707 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2708 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2709 | } |
| 2710 | } |
| 2711 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2712 | //De-init the adapter. |
| 2713 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2714 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2715 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2716 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2717 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2718 | |
| 2719 | //Disable BMPS and IMPS if enabled |
| 2720 | //before starting Go |
| 2721 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2722 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2723 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2724 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2725 | { |
| 2726 | //Fail to Exit BMPS |
| 2727 | VOS_ASSERT(0); |
| 2728 | } |
| 2729 | } |
| 2730 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2731 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2732 | (pConfig->apRandomBssidEnabled)) |
| 2733 | { |
| 2734 | /* To meet Android requirements create a randomized |
| 2735 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2736 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2737 | ndev->dev_addr[0] = 0x02; |
| 2738 | ndev->dev_addr[1] = 0x1A; |
| 2739 | ndev->dev_addr[2] = 0x11; |
| 2740 | ndev->dev_addr[3] |= 0xF0; |
| 2741 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2742 | VOS_MAC_ADDR_SIZE); |
| 2743 | pr_info("wlan: Generated HotSpot BSSID " |
| 2744 | "%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2745 | ndev->dev_addr[0], |
| 2746 | ndev->dev_addr[1], |
| 2747 | ndev->dev_addr[2], |
| 2748 | ndev->dev_addr[3], |
| 2749 | ndev->dev_addr[4], |
| 2750 | ndev->dev_addr[5]); |
| 2751 | } |
| 2752 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2753 | hdd_set_ap_ops( pAdapter->dev ); |
| 2754 | |
| 2755 | status = hdd_init_ap_mode(pAdapter); |
| 2756 | if(status != VOS_STATUS_SUCCESS) |
| 2757 | { |
| 2758 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2759 | "%s: Error initializing the ap mode", __func__); |
| 2760 | return -EINVAL; |
| 2761 | } |
| 2762 | hdd_set_conparam(1); |
| 2763 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2764 | /*interface type changed update in wiphy structure*/ |
| 2765 | if(wdev) |
| 2766 | { |
| 2767 | wdev->iftype = type; |
| 2768 | pHddCtx->change_iface = type; |
| 2769 | } |
| 2770 | else |
| 2771 | { |
| 2772 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2773 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 2774 | return -EINVAL; |
| 2775 | } |
| 2776 | goto done; |
| 2777 | } |
| 2778 | |
| 2779 | default: |
| 2780 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2781 | __func__); |
| 2782 | return -EOPNOTSUPP; |
| 2783 | } |
| 2784 | } |
| 2785 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2786 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2787 | ) |
| 2788 | { |
| 2789 | switch(type) |
| 2790 | { |
| 2791 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2792 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2793 | case NL80211_IFTYPE_ADHOC: |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2794 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2795 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2796 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2797 | //Check for sub-string p2p to confirm its a p2p interface |
| 2798 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2799 | { |
| 2800 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2801 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2802 | } |
| 2803 | else |
| 2804 | { |
| 2805 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2806 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2807 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2808 | hdd_set_conparam(0); |
| 2809 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2810 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 2811 | hdd_set_station_ops( pAdapter->dev ); |
| 2812 | status = hdd_init_station_mode( pAdapter ); |
| 2813 | if( VOS_STATUS_SUCCESS != status ) |
| 2814 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2815 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 2816 | * This is the right place to enable back bmps_imps() |
| 2817 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 2818 | if (pHddCtx->hdd_wlan_suspended) |
| 2819 | { |
| 2820 | hdd_set_pwrparams(pHddCtx); |
| 2821 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2822 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2823 | goto done; |
| 2824 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2825 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2826 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2827 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2828 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2829 | goto done; |
| 2830 | default: |
| 2831 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 2832 | __func__); |
| 2833 | return -EOPNOTSUPP; |
| 2834 | |
| 2835 | } |
| 2836 | |
| 2837 | } |
| 2838 | else |
| 2839 | { |
| 2840 | return -EOPNOTSUPP; |
| 2841 | } |
| 2842 | |
| 2843 | |
| 2844 | if(pRoamProfile) |
| 2845 | { |
| 2846 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 2847 | { |
| 2848 | /*interface type changed update in wiphy structure*/ |
| 2849 | wdev->iftype = type; |
| 2850 | |
| 2851 | /*the BSS mode changed, We need to issue disconnect |
| 2852 | if connected or in IBSS disconnect state*/ |
| 2853 | if ( hdd_connGetConnectedBssType( |
| 2854 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 2855 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 2856 | { |
| 2857 | /*need to issue a disconnect to CSR.*/ |
| 2858 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2859 | if( eHAL_STATUS_SUCCESS == |
| 2860 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2861 | pAdapter->sessionId, |
| 2862 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 2863 | { |
| 2864 | wait_for_completion_interruptible_timeout( |
| 2865 | &pAdapter->disconnect_comp_var, |
| 2866 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2867 | } |
| 2868 | } |
| 2869 | } |
| 2870 | } |
| 2871 | |
| 2872 | done: |
| 2873 | /*set bitmask based on updated value*/ |
| 2874 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 2875 | |
| 2876 | /* Only STA mode support TM now |
| 2877 | * all other mode, TM feature should be disabled */ |
| 2878 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 2879 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 2880 | { |
| 2881 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 2882 | } |
| 2883 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2884 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2885 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2886 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 2887 | { |
| 2888 | //we are ok to do AMP |
| 2889 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2890 | } |
| 2891 | #endif //WLAN_BTAMP_FEATURE |
| 2892 | EXIT(); |
| 2893 | return 0; |
| 2894 | } |
| 2895 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2896 | #ifdef FEATURE_WLAN_TDLS |
| 2897 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 2898 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 2899 | { |
| 2900 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2901 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 2902 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2903 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2904 | |
| 2905 | ENTER(); |
| 2906 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 2907 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2908 | { |
| 2909 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2910 | "Invalid arguments"); |
| 2911 | return -EINVAL; |
| 2912 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2913 | |
| 2914 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2915 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 2916 | { |
| 2917 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2918 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 2919 | MAC_ADDRESS_STR " Request declined.", |
| 2920 | __func__, MAC_ADDR_ARRAY(mac)); |
| 2921 | return -ENOTSUPP; |
| 2922 | } |
| 2923 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2924 | if (pHddCtx->isLogpInProgress) |
| 2925 | { |
| 2926 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2927 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2928 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2929 | return -EBUSY; |
| 2930 | } |
| 2931 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2932 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 2933 | |
| 2934 | if ( NULL == pTdlsPeer ) { |
| 2935 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2936 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 2937 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 2938 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2939 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2940 | |
| 2941 | /* in add station, we accept existing valid staId if there is */ |
| 2942 | if ((0 == update) && |
| 2943 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 2944 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2945 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2946 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2947 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 2948 | " link_status %d. staId %d. add station ignored.", |
| 2949 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 2950 | return 0; |
| 2951 | } |
| 2952 | /* in change station, we accept only when staId is valid */ |
| 2953 | if ((1 == update) && |
| 2954 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 2955 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 2956 | { |
| 2957 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2958 | "%s: " MAC_ADDRESS_STR |
| 2959 | " link status %d. staId %d. change station %s.", |
| 2960 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 2961 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 2962 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2963 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2964 | |
| 2965 | /* 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] | 2966 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2967 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2968 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2969 | "%s: " MAC_ADDRESS_STR |
| 2970 | " TDLS setup is ongoing. Request declined.", |
| 2971 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2972 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2973 | } |
| 2974 | |
| 2975 | /* first to check if we reached to maximum supported TDLS peer. |
| 2976 | TODO: for now, return -EPERM looks working fine, |
| 2977 | but need to check if any other errno fit into this category.*/ |
| 2978 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 2979 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2980 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2981 | "%s: " MAC_ADDRESS_STR |
| 2982 | " TDLS Max peer already connected. Request declined.", |
| 2983 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 2984 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2985 | } |
| 2986 | else |
| 2987 | { |
| 2988 | hddTdlsPeer_t *pTdlsPeer; |
| 2989 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2990 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2991 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2992 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2993 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 2994 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 2995 | return -EPERM; |
| 2996 | } |
| 2997 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2998 | if (0 == update) |
| 2999 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3000 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3001 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3002 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3003 | { |
| 3004 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3005 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3006 | if(StaParams->htcap_present) |
| 3007 | { |
| 3008 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3009 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 3010 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3011 | "ht_capa->extended_capabilities: %0x", |
| 3012 | StaParams->HTCap.extendedHtCapInfo); |
| 3013 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3014 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3015 | "params->capability: %0x",StaParams->capability); |
| 3016 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3017 | "params->ext_capab_len: %0x",StaParams->extn_capability); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3018 | if(StaParams->vhtcap_present) |
| 3019 | { |
| 3020 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3021 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 3022 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 3023 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 3024 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3025 | { |
| 3026 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3027 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3028 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 3029 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3030 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 3031 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3032 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3033 | else if ((1 == update) && (NULL == StaParams)) |
| 3034 | { |
| 3035 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3036 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 3037 | return -EPERM; |
| 3038 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3039 | |
| 3040 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 3041 | |
| 3042 | if (!update) |
| 3043 | { |
| 3044 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3045 | pAdapter->sessionId, mac); |
| 3046 | } |
| 3047 | else |
| 3048 | { |
| 3049 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3050 | pAdapter->sessionId, mac, StaParams); |
| 3051 | } |
| 3052 | |
| 3053 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
| 3054 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 3055 | |
| 3056 | if (!status) |
| 3057 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3058 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3059 | "%s: timeout waiting for tdls add station indication", |
| 3060 | __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3061 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3062 | } |
| 3063 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 3064 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3065 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3066 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3067 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3068 | } |
| 3069 | |
| 3070 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3071 | |
| 3072 | error: |
| 3073 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 3074 | return -EPERM; |
| 3075 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3076 | } |
| 3077 | #endif |
| 3078 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3079 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 3080 | struct net_device *dev, |
| 3081 | u8 *mac, |
| 3082 | struct station_parameters *params) |
| 3083 | { |
| 3084 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 3085 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3086 | hdd_context_t *pHddCtx; |
| 3087 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3088 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3089 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3090 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3091 | tANI_U8 isBufSta = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3092 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3093 | ENTER(); |
| 3094 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3095 | if ((NULL == pAdapter)) |
| 3096 | { |
| 3097 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3098 | "invalid adapter "); |
| 3099 | return -EINVAL; |
| 3100 | } |
| 3101 | |
| 3102 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3103 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3104 | |
| 3105 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 3106 | { |
| 3107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3108 | "invalid HDD state or HDD station context"); |
| 3109 | return -EINVAL; |
| 3110 | } |
| 3111 | |
| 3112 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3113 | { |
| 3114 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3115 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3116 | return -EAGAIN; |
| 3117 | } |
| 3118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3119 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 3120 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3121 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 3122 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3123 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3124 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3125 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3126 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3127 | WLANTL_STA_AUTHENTICATED); |
| 3128 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3129 | if (status != VOS_STATUS_SUCCESS) |
| 3130 | { |
| 3131 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3132 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3133 | return -EINVAL; |
| 3134 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3135 | } |
| 3136 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3137 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3138 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3139 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3140 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3141 | StaParams.capability = params->capability; |
| 3142 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3143 | StaParams.max_sp = params->max_sp; |
| 3144 | |
| 3145 | if (0 != params->ext_capab_len) |
| 3146 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3147 | sizeof(StaParams.extn_capability)); |
| 3148 | |
| 3149 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3150 | { |
| 3151 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3152 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3153 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3154 | |
| 3155 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3156 | |
| 3157 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3158 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3159 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3160 | * modified to send more rates. |
| 3161 | */ |
| 3162 | |
| 3163 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3164 | */ |
| 3165 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3166 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3167 | |
| 3168 | if (0 != StaParams.supported_rates_len) { |
| 3169 | int i = 0; |
| 3170 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3171 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3172 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3173 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3174 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3175 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3176 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3177 | } |
| 3178 | |
| 3179 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3180 | { |
| 3181 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3182 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3183 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3184 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3185 | if (0 != params->ext_capab_len ) { |
| 3186 | /*Define A Macro : TODO Sunil*/ |
| 3187 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3188 | isBufSta = 1; |
| 3189 | } |
| 3190 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3191 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues, |
| 3192 | params->max_sp, isBufSta); |
| 3193 | if (VOS_STATUS_SUCCESS != status) { |
| 3194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3195 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3196 | return -EINVAL; |
| 3197 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3198 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3199 | |
| 3200 | if (VOS_STATUS_SUCCESS != status) { |
| 3201 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3202 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3203 | return -EINVAL; |
| 3204 | } |
| 3205 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3206 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3207 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3208 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3209 | return status; |
| 3210 | } |
| 3211 | |
| 3212 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3213 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3214 | * This function is used to initialize the key information |
| 3215 | */ |
| 3216 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3217 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3218 | struct net_device *ndev, |
| 3219 | u8 key_index, bool pairwise, |
| 3220 | const u8 *mac_addr, |
| 3221 | struct key_params *params |
| 3222 | ) |
| 3223 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3224 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3225 | struct net_device *ndev, |
| 3226 | u8 key_index, const u8 *mac_addr, |
| 3227 | struct key_params *params |
| 3228 | ) |
| 3229 | #endif |
| 3230 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3231 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3232 | tCsrRoamSetKey setKey; |
| 3233 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3234 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3235 | v_U32_t roamId= 0xFF; |
| 3236 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3237 | hdd_hostapd_state_t *pHostapdState; |
| 3238 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3239 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3240 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3241 | |
| 3242 | ENTER(); |
| 3243 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3244 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3245 | status = wlan_hdd_validate_context(pHddCtx); |
| 3246 | |
| 3247 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3248 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3249 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3250 | "%s: HDD context is not valid", __func__); |
| 3251 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3252 | } |
| 3253 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3254 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3255 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3256 | |
| 3257 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3258 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3259 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3260 | key_index); |
| 3261 | |
| 3262 | return -EINVAL; |
| 3263 | } |
| 3264 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3265 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3266 | { |
| 3267 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3268 | params->key_len); |
| 3269 | |
| 3270 | return -EINVAL; |
| 3271 | } |
| 3272 | |
| 3273 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3274 | "%s: called with key index = %d & key length %d", |
| 3275 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3276 | |
| 3277 | /*extract key idx, key len and key*/ |
| 3278 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3279 | setKey.keyId = key_index; |
| 3280 | setKey.keyLength = params->key_len; |
| 3281 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3282 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3283 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3284 | { |
| 3285 | case WLAN_CIPHER_SUITE_WEP40: |
| 3286 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3287 | break; |
| 3288 | |
| 3289 | case WLAN_CIPHER_SUITE_WEP104: |
| 3290 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3291 | break; |
| 3292 | |
| 3293 | case WLAN_CIPHER_SUITE_TKIP: |
| 3294 | { |
| 3295 | u8 *pKey = &setKey.Key[0]; |
| 3296 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3297 | |
| 3298 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3299 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3300 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3301 | |
| 3302 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3303 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3304 | |--------------|----------|----------| |
| 3305 | <---16bytes---><--8bytes--><--8bytes--> |
| 3306 | |
| 3307 | */ |
| 3308 | /*Sme expects the 32 bytes key to be in the below order |
| 3309 | |
| 3310 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3311 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3312 | |--------------|----------|----------| |
| 3313 | <---16bytes---><--8bytes--><--8bytes--> |
| 3314 | */ |
| 3315 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3316 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3317 | |
| 3318 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3319 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3320 | |
| 3321 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3322 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3323 | |
| 3324 | |
| 3325 | break; |
| 3326 | } |
| 3327 | |
| 3328 | case WLAN_CIPHER_SUITE_CCMP: |
| 3329 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3330 | break; |
| 3331 | |
| 3332 | #ifdef FEATURE_WLAN_WAPI |
| 3333 | case WLAN_CIPHER_SUITE_SMS4: |
| 3334 | { |
| 3335 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3336 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3337 | params->key, params->key_len); |
| 3338 | return 0; |
| 3339 | } |
| 3340 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3341 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3342 | #ifdef FEATURE_WLAN_CCX |
| 3343 | case WLAN_CIPHER_SUITE_KRK: |
| 3344 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3345 | break; |
| 3346 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3347 | |
| 3348 | #ifdef WLAN_FEATURE_11W |
| 3349 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3350 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3351 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3352 | #endif |
| 3353 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3354 | default: |
| 3355 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu", |
| 3356 | __func__, params->cipher); |
| 3357 | return -EOPNOTSUPP; |
| 3358 | } |
| 3359 | |
| 3360 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3361 | __func__, setKey.encType); |
| 3362 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3363 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3364 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3365 | (!pairwise) |
| 3366 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3367 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3368 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3369 | ) |
| 3370 | { |
| 3371 | /* set group key*/ |
| 3372 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3373 | "%s- %d: setting Broadcast key", |
| 3374 | __func__, __LINE__); |
| 3375 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3376 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3377 | } |
| 3378 | else |
| 3379 | { |
| 3380 | /* set pairwise key*/ |
| 3381 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3382 | "%s- %d: setting pairwise key", |
| 3383 | __func__, __LINE__); |
| 3384 | setKey.keyDirection = eSIR_TX_RX; |
| 3385 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3386 | } |
| 3387 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3388 | { |
| 3389 | setKey.keyDirection = eSIR_TX_RX; |
| 3390 | /*Set the group key*/ |
| 3391 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3392 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3393 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3394 | if ( 0 != status ) |
| 3395 | { |
| 3396 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3397 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3398 | return -EINVAL; |
| 3399 | } |
| 3400 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3401 | the PTK after peer joins the IBSS network*/ |
| 3402 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3403 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3404 | return status; |
| 3405 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3406 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3407 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3408 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3409 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3410 | if( pHostapdState->bssState == BSS_START ) |
| 3411 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3412 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3413 | |
| 3414 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3415 | { |
| 3416 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3417 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3418 | __LINE__, status ); |
| 3419 | } |
| 3420 | } |
| 3421 | |
| 3422 | /* Saving WEP keys */ |
| 3423 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3424 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3425 | { |
| 3426 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3427 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3428 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3429 | } |
| 3430 | else |
| 3431 | { |
| 3432 | //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] | 3433 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3434 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3435 | } |
| 3436 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3437 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3438 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3439 | { |
| 3440 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3441 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3442 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3443 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3444 | if (!pairwise) |
| 3445 | #else |
| 3446 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3447 | #endif |
| 3448 | { |
| 3449 | /* set group key*/ |
| 3450 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3451 | { |
| 3452 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3453 | "%s- %d: Perform Set key Complete", |
| 3454 | __func__, __LINE__); |
| 3455 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3456 | } |
| 3457 | } |
| 3458 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3459 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3460 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3461 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3462 | |
| 3463 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3464 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3465 | params->key, params->key_len); |
| 3466 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3467 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3468 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3469 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3470 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3471 | "%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] | 3472 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3473 | setKey.peerMac[2], setKey.peerMac[3], |
| 3474 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3475 | setKey.keyDirection); |
| 3476 | |
| 3477 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3478 | |
| 3479 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3480 | { |
| 3481 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3482 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3483 | __LINE__, vos_status ); |
| 3484 | |
| 3485 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3486 | |
| 3487 | return -EINVAL; |
| 3488 | |
| 3489 | } |
| 3490 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3491 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3492 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3493 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3494 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3495 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3496 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3497 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3498 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3499 | "%s: Update PreAuth Key success", __func__); |
| 3500 | return 0; |
| 3501 | } |
| 3502 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3503 | { |
| 3504 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3505 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3506 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3507 | } |
| 3508 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3509 | |
| 3510 | /* issue set key request to SME*/ |
| 3511 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3512 | pAdapter->sessionId, &setKey, &roamId ); |
| 3513 | |
| 3514 | if ( 0 != status ) |
| 3515 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3516 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3517 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3518 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3519 | return -EINVAL; |
| 3520 | } |
| 3521 | |
| 3522 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3523 | /* in case of IBSS as there was no information available about WEP keys during |
| 3524 | * 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] | 3525 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3526 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3527 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3528 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3529 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3530 | ) |
| 3531 | && |
| 3532 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3533 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3534 | ) |
| 3535 | ) |
| 3536 | { |
| 3537 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3538 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3539 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3540 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3541 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3542 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3543 | setKey.peerMac[2], setKey.peerMac[3], |
| 3544 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3545 | setKey.keyDirection); |
| 3546 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3547 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3548 | pAdapter->sessionId, &setKey, &roamId ); |
| 3549 | |
| 3550 | if ( 0 != status ) |
| 3551 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3552 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3553 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3554 | __func__, status); |
| 3555 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3556 | return -EINVAL; |
| 3557 | } |
| 3558 | } |
| 3559 | } |
| 3560 | |
| 3561 | return 0; |
| 3562 | } |
| 3563 | |
| 3564 | /* |
| 3565 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3566 | * This function is used to get the key information |
| 3567 | */ |
| 3568 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3569 | static int wlan_hdd_cfg80211_get_key( |
| 3570 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3571 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3572 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3573 | const u8 *mac_addr, void *cookie, |
| 3574 | void (*callback)(void *cookie, struct key_params*) |
| 3575 | ) |
| 3576 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3577 | static int wlan_hdd_cfg80211_get_key( |
| 3578 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3579 | struct net_device *ndev, |
| 3580 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3581 | void (*callback)(void *cookie, struct key_params*) |
| 3582 | ) |
| 3583 | #endif |
| 3584 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3585 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3586 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3587 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3588 | struct key_params params; |
| 3589 | |
| 3590 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3591 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3592 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 3593 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3594 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3595 | memset(¶ms, 0, sizeof(params)); |
| 3596 | |
| 3597 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3598 | { |
| 3599 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3600 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3601 | |
| 3602 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3603 | { |
| 3604 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3605 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3606 | break; |
| 3607 | |
| 3608 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3609 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3610 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3611 | break; |
| 3612 | |
| 3613 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3614 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3615 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3616 | break; |
| 3617 | |
| 3618 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3619 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3620 | break; |
| 3621 | |
| 3622 | case eCSR_ENCRYPT_TYPE_AES: |
| 3623 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3624 | break; |
| 3625 | |
| 3626 | default: |
| 3627 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3628 | break; |
| 3629 | } |
| 3630 | |
| 3631 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3632 | params.seq_len = 0; |
| 3633 | params.seq = NULL; |
| 3634 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3635 | callback(cookie, ¶ms); |
| 3636 | return 0; |
| 3637 | } |
| 3638 | |
| 3639 | /* |
| 3640 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3641 | * This function is used to delete the key information |
| 3642 | */ |
| 3643 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3644 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3645 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3646 | u8 key_index, |
| 3647 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3648 | const u8 *mac_addr |
| 3649 | ) |
| 3650 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3651 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3652 | struct net_device *ndev, |
| 3653 | u8 key_index, |
| 3654 | const u8 *mac_addr |
| 3655 | ) |
| 3656 | #endif |
| 3657 | { |
| 3658 | int status = 0; |
| 3659 | |
| 3660 | //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] | 3661 | //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] | 3662 | //it is observed that this is invalidating peer |
| 3663 | //key index whenever re-key is done. This is affecting data link. |
| 3664 | //It should be ok to ignore del_key. |
| 3665 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3666 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3667 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3668 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3669 | tCsrRoamSetKey setKey; |
| 3670 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3671 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3672 | ENTER(); |
| 3673 | |
| 3674 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3675 | __func__,pAdapter->device_mode); |
| 3676 | |
| 3677 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3678 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3679 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3680 | key_index); |
| 3681 | |
| 3682 | return -EINVAL; |
| 3683 | } |
| 3684 | |
| 3685 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3686 | setKey.keyId = key_index; |
| 3687 | |
| 3688 | if (mac_addr) |
| 3689 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3690 | else |
| 3691 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 3692 | |
| 3693 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 3694 | |
| 3695 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3696 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3697 | ) |
| 3698 | { |
| 3699 | |
| 3700 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3701 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 3702 | if( pHostapdState->bssState == BSS_START) |
| 3703 | { |
| 3704 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3705 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3706 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3707 | { |
| 3708 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3709 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3710 | __LINE__, status ); |
| 3711 | } |
| 3712 | } |
| 3713 | } |
| 3714 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3715 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3716 | ) |
| 3717 | { |
| 3718 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3719 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3720 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3721 | |
| 3722 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3723 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3724 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3725 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3726 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3727 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 3728 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3729 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3730 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3731 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3732 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3733 | if ( 0 != status ) |
| 3734 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3735 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3736 | "%s: sme_RoamSetKey failure, returned %d", |
| 3737 | __func__, status); |
| 3738 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3739 | return -EINVAL; |
| 3740 | } |
| 3741 | } |
| 3742 | } |
| 3743 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3744 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3745 | return status; |
| 3746 | } |
| 3747 | |
| 3748 | /* |
| 3749 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 3750 | * This function is used to set the default tx key index |
| 3751 | */ |
| 3752 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3753 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3754 | struct net_device *ndev, |
| 3755 | u8 key_index, |
| 3756 | bool unicast, bool multicast) |
| 3757 | #else |
| 3758 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 3759 | struct net_device *ndev, |
| 3760 | u8 key_index) |
| 3761 | #endif |
| 3762 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3763 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3764 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3765 | hdd_wext_state_t *pWextState; |
| 3766 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3767 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3768 | |
| 3769 | ENTER(); |
| 3770 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3771 | if ((NULL == pAdapter)) |
| 3772 | { |
| 3773 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3774 | "invalid adapter"); |
| 3775 | return -EINVAL; |
| 3776 | } |
| 3777 | |
| 3778 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3779 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3780 | |
| 3781 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 3782 | { |
| 3783 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3784 | "invalid Wext state or HDD context"); |
| 3785 | return -EINVAL; |
| 3786 | } |
| 3787 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3788 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n", |
| 3789 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3790 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3791 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3792 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3793 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3794 | key_index); |
| 3795 | |
| 3796 | return -EINVAL; |
| 3797 | } |
| 3798 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3799 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3800 | status = wlan_hdd_validate_context(pHddCtx); |
| 3801 | |
| 3802 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3803 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3804 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3805 | "%s: HDD context is not valid", __func__); |
| 3806 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3807 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3809 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3810 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3811 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3812 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3813 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3814 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3815 | (eCSR_ENCRYPT_TYPE_AES != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3816 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3817 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3818 | { |
| 3819 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3820 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3821 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3822 | tCsrRoamSetKey setKey; |
| 3823 | v_U32_t roamId= 0xFF; |
| 3824 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3825 | |
| 3826 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3827 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3829 | Keys->defaultIndex = (u8)key_index; |
| 3830 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3831 | setKey.keyId = key_index; |
| 3832 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3833 | |
| 3834 | vos_mem_copy(&setKey.Key[0], |
| 3835 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3836 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3837 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3838 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3839 | |
| 3840 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3841 | &pHddStaCtx->conn_info.bssId[0], |
| 3842 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3843 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3844 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 3845 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 3846 | eCSR_ENCRYPT_TYPE_WEP104) |
| 3847 | { |
| 3848 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 3849 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 3850 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 3851 | type(104) and switching encryption type to 40*/ |
| 3852 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 3853 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3854 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 3855 | eCSR_ENCRYPT_TYPE_WEP40; |
| 3856 | } |
| 3857 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3858 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3859 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3860 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3861 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3862 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3863 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3864 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3865 | if ( 0 != status ) |
| 3866 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3867 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3868 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3869 | status); |
| 3870 | return -EINVAL; |
| 3871 | } |
| 3872 | } |
| 3873 | } |
| 3874 | |
| 3875 | /* In SoftAp mode setting key direction for default mode */ |
| 3876 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 3877 | { |
| 3878 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 3879 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 3880 | (eCSR_ENCRYPT_TYPE_AES != |
| 3881 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 3882 | ) |
| 3883 | { |
| 3884 | /* Saving key direction for default key index to TX default */ |
| 3885 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3886 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 3887 | } |
| 3888 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3889 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3890 | return status; |
| 3891 | } |
| 3892 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3893 | /* |
| 3894 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 3895 | * This function is used to inform the BSS details to nl80211 interface. |
| 3896 | */ |
| 3897 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 3898 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 3899 | { |
| 3900 | struct net_device *dev = pAdapter->dev; |
| 3901 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3902 | struct wiphy *wiphy = wdev->wiphy; |
| 3903 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 3904 | int chan_no; |
| 3905 | int ie_length; |
| 3906 | const char *ie; |
| 3907 | unsigned int freq; |
| 3908 | struct ieee80211_channel *chan; |
| 3909 | int rssi = 0; |
| 3910 | struct cfg80211_bss *bss = NULL; |
| 3911 | |
| 3912 | ENTER(); |
| 3913 | |
| 3914 | if( NULL == pBssDesc ) |
| 3915 | { |
| 3916 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__); |
| 3917 | return bss; |
| 3918 | } |
| 3919 | |
| 3920 | chan_no = pBssDesc->channelId; |
| 3921 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 3922 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 3923 | |
| 3924 | if( NULL == ie ) |
| 3925 | { |
| 3926 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__); |
| 3927 | return bss; |
| 3928 | } |
| 3929 | |
| 3930 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 3931 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 3932 | { |
| 3933 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 3934 | } |
| 3935 | else |
| 3936 | { |
| 3937 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 3938 | } |
| 3939 | #else |
| 3940 | freq = ieee80211_channel_to_frequency(chan_no); |
| 3941 | #endif |
| 3942 | |
| 3943 | chan = __ieee80211_get_channel(wiphy, freq); |
| 3944 | |
| 3945 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 3946 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 3947 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 3948 | if (bss == NULL) |
| 3949 | { |
| 3950 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 3951 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3952 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 3953 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3954 | pBssDesc->capabilityInfo, |
| 3955 | pBssDesc->beaconInterval, ie, ie_length, |
| 3956 | rssi, GFP_KERNEL )); |
| 3957 | } |
| 3958 | else |
| 3959 | { |
| 3960 | return bss; |
| 3961 | } |
| 3962 | } |
| 3963 | |
| 3964 | |
| 3965 | |
| 3966 | /* |
| 3967 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 3968 | * This function is used to inform the BSS details to nl80211 interface. |
| 3969 | */ |
| 3970 | struct cfg80211_bss* |
| 3971 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 3972 | tSirBssDescription *bss_desc |
| 3973 | ) |
| 3974 | { |
| 3975 | /* |
| 3976 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 3977 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 3978 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 3979 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 3980 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 3981 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 3982 | cfg80211_inform_bss_frame. |
| 3983 | */ |
| 3984 | struct net_device *dev = pAdapter->dev; |
| 3985 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 3986 | struct wiphy *wiphy = wdev->wiphy; |
| 3987 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 3988 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 3989 | qcom_ie_age *qie_age = NULL; |
| 3990 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 3991 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3992 | 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] | 3993 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3994 | const char *ie = |
| 3995 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 3996 | unsigned int freq; |
| 3997 | struct ieee80211_channel *chan; |
| 3998 | struct ieee80211_mgmt *mgmt = |
| 3999 | kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 4000 | struct cfg80211_bss *bss_status = NULL; |
| 4001 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 4002 | int rssi = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4003 | #ifdef WLAN_OPEN_SOURCE |
| 4004 | struct timespec ts; |
| 4005 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4006 | |
| 4007 | ENTER(); |
| 4008 | |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4009 | if (!mgmt) |
| 4010 | return NULL; |
| 4011 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4012 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4013 | |
| 4014 | #ifdef WLAN_OPEN_SOURCE |
| 4015 | /* Android does not want the timestamp from the frame. |
| 4016 | Instead it wants a monotonic increasing value */ |
| 4017 | get_monotonic_boottime(&ts); |
| 4018 | mgmt->u.probe_resp.timestamp = |
| 4019 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 4020 | #else |
| 4021 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4022 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 4023 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4024 | |
| 4025 | #endif |
| 4026 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4027 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 4028 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4029 | |
| 4030 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4031 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 4032 | /* Assuming this is the last IE, copy at the end */ |
| 4033 | ie_length -=sizeof(qcom_ie_age); |
| 4034 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 4035 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 4036 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 4037 | qie_age->oui_1 = QCOM_OUI1; |
| 4038 | qie_age->oui_2 = QCOM_OUI2; |
| 4039 | qie_age->oui_3 = QCOM_OUI3; |
| 4040 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 4041 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 4042 | #endif |
| 4043 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4044 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 4045 | if (bss_desc->fProbeRsp) |
| 4046 | { |
| 4047 | mgmt->frame_control |= |
| 4048 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 4049 | } |
| 4050 | else |
| 4051 | { |
| 4052 | mgmt->frame_control |= |
| 4053 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 4054 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4055 | |
| 4056 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4057 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4058 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 4059 | { |
| 4060 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4061 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4062 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4063 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 4064 | |
| 4065 | { |
| 4066 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4067 | } |
| 4068 | else |
| 4069 | { |
| 4070 | kfree(mgmt); |
| 4071 | return NULL; |
| 4072 | } |
| 4073 | #else |
| 4074 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4075 | #endif |
| 4076 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4077 | /*when the band is changed on the fly using the GUI, three things are done |
| 4078 | * 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) |
| 4079 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 4080 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 4081 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 4082 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 4083 | * 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 |
| 4084 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 4085 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 4086 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 4087 | * So drop the bss and continue to next bss. |
| 4088 | */ |
| 4089 | if(chan == NULL) |
| 4090 | { |
| 4091 | hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 4092 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4093 | return NULL; |
| 4094 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4095 | /*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] | 4096 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4097 | * */ |
| 4098 | if (( eConnectionState_Associated == |
| 4099 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4100 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4101 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4102 | WNI_CFG_BSSID_LEN))) |
| 4103 | { |
| 4104 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4105 | rssi = (pAdapter->rssi * 100); |
| 4106 | } |
| 4107 | else |
| 4108 | { |
| 4109 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4110 | } |
| 4111 | |
| 4112 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4113 | frame_len, rssi, GFP_KERNEL); |
| 4114 | kfree(mgmt); |
| 4115 | return bss_status; |
| 4116 | } |
| 4117 | |
| 4118 | /* |
| 4119 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4120 | * This function is used to update the BSS data base of CFG8011 |
| 4121 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4122 | 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] | 4123 | tCsrRoamInfo *pRoamInfo |
| 4124 | ) |
| 4125 | { |
| 4126 | tCsrRoamConnectedProfile roamProfile; |
| 4127 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4128 | struct cfg80211_bss *bss = NULL; |
| 4129 | |
| 4130 | ENTER(); |
| 4131 | |
| 4132 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4133 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4134 | |
| 4135 | if (NULL != roamProfile.pBssDesc) |
| 4136 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4137 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4138 | &roamProfile); |
| 4139 | |
| 4140 | if (NULL == bss) |
| 4141 | { |
| 4142 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4143 | __func__); |
| 4144 | } |
| 4145 | |
| 4146 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4147 | } |
| 4148 | else |
| 4149 | { |
| 4150 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4151 | __func__); |
| 4152 | } |
| 4153 | return bss; |
| 4154 | } |
| 4155 | |
| 4156 | /* |
| 4157 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4158 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4159 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4160 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4161 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4162 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4163 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4164 | tCsrScanResultInfo *pScanResult; |
| 4165 | eHalStatus status = 0; |
| 4166 | tScanResultHandle pResult; |
| 4167 | struct cfg80211_bss *bss_status = NULL; |
| 4168 | |
| 4169 | ENTER(); |
| 4170 | |
| 4171 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4172 | { |
| 4173 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4174 | return -EAGAIN; |
| 4175 | } |
| 4176 | |
| 4177 | /* |
| 4178 | * start getting scan results and populate cgf80211 BSS database |
| 4179 | */ |
| 4180 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4181 | |
| 4182 | /* no scan results */ |
| 4183 | if (NULL == pResult) |
| 4184 | { |
| 4185 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__); |
| 4186 | return status; |
| 4187 | } |
| 4188 | |
| 4189 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4190 | |
| 4191 | while (pScanResult) |
| 4192 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4193 | /* |
| 4194 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4195 | * entry already exists in bss data base of cfg80211 for that |
| 4196 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4197 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4198 | * mgmt packet as input. As of now there is no possibility to get |
| 4199 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4200 | * ieee80211_mgmt(probe response) and passing to c |
| 4201 | * fg80211_inform_bss_frame. |
| 4202 | * */ |
| 4203 | |
| 4204 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4205 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4206 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4207 | |
| 4208 | if (NULL == bss_status) |
| 4209 | { |
| 4210 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4211 | "%s: NULL returned by cfg80211_inform_bss\n", __func__); |
| 4212 | } |
| 4213 | else |
| 4214 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4215 | cfg80211_put_bss( |
| 4216 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 4217 | wiphy, |
| 4218 | #endif |
| 4219 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4220 | } |
| 4221 | |
| 4222 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4223 | } |
| 4224 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4225 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4226 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4227 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4228 | } |
| 4229 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4230 | void |
| 4231 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4232 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4233 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4234 | "%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4235 | macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], |
| 4236 | macAddr[5]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4237 | } /****** end hddPrintMacAddr() ******/ |
| 4238 | |
| 4239 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4240 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4241 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4242 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4243 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", |
| 4244 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4245 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4246 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4247 | } /****** end hddPrintPmkId() ******/ |
| 4248 | |
| 4249 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4250 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4251 | |
| 4252 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4253 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4254 | |
| 4255 | #define dump_bssid(bssid) \ |
| 4256 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4257 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4258 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
| 4259 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4260 | } |
| 4261 | |
| 4262 | #define dump_pmkid(pMac, pmkid) \ |
| 4263 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4264 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4265 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
| 4266 | hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4267 | } |
| 4268 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4269 | #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] | 4270 | /* |
| 4271 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4272 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4273 | */ |
| 4274 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4275 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4276 | int index, bool preauth ) |
| 4277 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4278 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4279 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4280 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4281 | |
| 4282 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4283 | 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] | 4284 | |
| 4285 | if( NULL == pRoamInfo ) |
| 4286 | { |
| 4287 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__); |
| 4288 | return -EINVAL; |
| 4289 | } |
| 4290 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4291 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4292 | { |
| 4293 | dump_bssid(pRoamInfo->bssid); |
| 4294 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4295 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4296 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4297 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4298 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4299 | } |
| 4300 | #endif //FEATURE_WLAN_LFR |
| 4301 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4302 | /* |
| 4303 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4304 | * scanning callback function, called after finishing scan |
| 4305 | * |
| 4306 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4307 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4308 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4309 | { |
| 4310 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4311 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4312 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4313 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4314 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4315 | struct cfg80211_scan_request *req = NULL; |
| 4316 | int ret = 0; |
| 4317 | |
| 4318 | ENTER(); |
| 4319 | |
| 4320 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4321 | "%s called with halHandle = %p, pContext = %p," |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4322 | "scanID = %d, returned status = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4323 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4324 | |
| 4325 | //Block on scan req completion variable. Can't wait forever though. |
| 4326 | ret = wait_for_completion_interruptible_timeout( |
| 4327 | &pScanInfo->scan_req_completion_event, |
| 4328 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
| 4329 | if (!ret) |
| 4330 | { |
| 4331 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4332 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4333 | } |
| 4334 | |
| 4335 | if(pScanInfo->mScanPending != VOS_TRUE) |
| 4336 | { |
| 4337 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4338 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4339 | } |
| 4340 | |
| 4341 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4342 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4343 | { |
| 4344 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4345 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4346 | "scanId = %d \n", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4347 | (int) scanId); |
| 4348 | } |
| 4349 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4350 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4351 | pAdapter); |
| 4352 | |
| 4353 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4354 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4355 | |
| 4356 | |
| 4357 | /* If any client wait scan result through WEXT |
| 4358 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4359 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4360 | { |
| 4361 | /* The other scan request waiting for current scan finish |
| 4362 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4363 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4364 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4365 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4366 | } |
| 4367 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4368 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4369 | { |
| 4370 | struct net_device *dev = pAdapter->dev; |
| 4371 | union iwreq_data wrqu; |
| 4372 | int we_event; |
| 4373 | char *msg; |
| 4374 | |
| 4375 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4376 | we_event = SIOCGIWSCAN; |
| 4377 | msg = NULL; |
| 4378 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4379 | } |
| 4380 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4381 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4382 | |
| 4383 | /* Get the Scan Req */ |
| 4384 | req = pAdapter->request; |
| 4385 | |
| 4386 | if (!req) |
| 4387 | { |
| 4388 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4389 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4390 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4391 | } |
| 4392 | |
| 4393 | /* |
| 4394 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4395 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4396 | req->n_ssids = 0; |
| 4397 | req->n_channels = 0; |
| 4398 | req->ie = 0; |
| 4399 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4400 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4401 | /* Scan is no longer pending */ |
| 4402 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4403 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4404 | /* |
| 4405 | * cfg80211_scan_done informing NL80211 about completion |
| 4406 | * of scanning |
| 4407 | */ |
| 4408 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4409 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4410 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4411 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4412 | /* release the wake lock at the end of the scan*/ |
| 4413 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4414 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4415 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4416 | * immediatly after the driver gets connect request(i.e after scan) |
| 4417 | * from supplicant, this result in app's is suspending and not able |
| 4418 | * to process the connect request to AP */ |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 4419 | hdd_allow_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4420 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4421 | #ifdef FEATURE_WLAN_TDLS |
| 4422 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4423 | #endif |
| 4424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4425 | EXIT(); |
| 4426 | return 0; |
| 4427 | } |
| 4428 | |
| 4429 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4430 | * FUNCTION: hdd_isScanAllowed |
| 4431 | * Go through each adapter and check if scan allowed |
| 4432 | * |
| 4433 | */ |
| 4434 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4435 | { |
| 4436 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4437 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4438 | hdd_adapter_t *pAdapter = NULL; |
| 4439 | VOS_STATUS status = 0; |
| 4440 | v_U8_t staId = 0; |
| 4441 | v_U8_t *staMac = NULL; |
| 4442 | |
| 4443 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4444 | |
| 4445 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4446 | { |
| 4447 | pAdapter = pAdapterNode->pAdapter; |
| 4448 | |
| 4449 | if( pAdapter ) |
| 4450 | { |
| 4451 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4452 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4453 | __func__, pAdapter->device_mode); |
| 4454 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4455 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4456 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4457 | { |
| 4458 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4459 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4460 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4461 | { |
| 4462 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4463 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4464 | "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the " |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4465 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4466 | staMac[0], staMac[1], staMac[2], |
| 4467 | staMac[3], staMac[4], staMac[5]); |
| 4468 | return VOS_FALSE; |
| 4469 | } |
| 4470 | } |
| 4471 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4472 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4473 | { |
| 4474 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4475 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4476 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4477 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4478 | { |
| 4479 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4480 | |
| 4481 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4482 | "%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] | 4483 | "middle of WPS/EAPOL exchange.", __func__, |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4484 | staMac[0], staMac[1], staMac[2], |
| 4485 | staMac[3], staMac[4], staMac[5]); |
| 4486 | return VOS_FALSE; |
| 4487 | } |
| 4488 | } |
| 4489 | } |
| 4490 | } |
| 4491 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4492 | pAdapterNode = pNext; |
| 4493 | } |
| 4494 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4495 | "%s: Scan allowed", __func__); |
| 4496 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4497 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4498 | |
| 4499 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4500 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4501 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4502 | * later, scan dump command can be used to recieve scan results |
| 4503 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4504 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4505 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4506 | struct net_device *dev, |
| 4507 | #endif |
| 4508 | struct cfg80211_scan_request *request) |
| 4509 | { |
| 4510 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4511 | struct net_device *dev = request->wdev->netdev; |
| 4512 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4513 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4514 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4515 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4516 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4517 | tCsrScanRequest scanRequest; |
| 4518 | tANI_U8 *channelList = NULL, i; |
| 4519 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4520 | int status; |
| 4521 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4522 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4523 | |
| 4524 | ENTER(); |
| 4525 | |
| 4526 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
| 4527 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4528 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4529 | status = wlan_hdd_validate_context(pHddCtx); |
| 4530 | |
| 4531 | if (0 != status) |
| 4532 | { |
| 4533 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4534 | "%s: HDD context is not valid", __func__); |
| 4535 | return status; |
| 4536 | } |
| 4537 | |
| 4538 | cfg_param = pHddCtx->cfg_ini; |
| 4539 | pScanInfo = &pHddCtx->scan_info; |
| 4540 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4541 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4542 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4543 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4544 | { |
| 4545 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 4546 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 4547 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4548 | return -EBUSY; |
| 4549 | } |
| 4550 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4551 | #ifdef WLAN_BTAMP_FEATURE |
| 4552 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4553 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4554 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 4555 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4556 | "%s: No scanning when AMP is on", __func__); |
| 4557 | return -EOPNOTSUPP; |
| 4558 | } |
| 4559 | #endif |
| 4560 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4561 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4562 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4563 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4564 | "%s: Not scanning on device_mode = %d", |
| 4565 | __func__, pAdapter->device_mode); |
| 4566 | return -EOPNOTSUPP; |
| 4567 | } |
| 4568 | |
| 4569 | if (TRUE == pScanInfo->mScanPending) |
| 4570 | { |
| 4571 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4572 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4573 | } |
| 4574 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4575 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4576 | //Channel and action frame is pending |
| 4577 | //Otherwise Cancel Remain On Channel and allow Scan |
| 4578 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4579 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4580 | { |
| 4581 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__); |
| 4582 | return -EBUSY; |
| 4583 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4584 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4585 | /* if tdls disagree scan right now, return immediately. |
| 4586 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 4587 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 4588 | */ |
| 4589 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 4590 | wiphy, |
| 4591 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4592 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 4593 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4594 | request); |
| 4595 | if(status <= 0) |
| 4596 | { |
| 4597 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status); |
| 4598 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 4599 | } |
| 4600 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4601 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4602 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 4603 | { |
| 4604 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 4605 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4606 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4607 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4608 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 4609 | { |
| 4610 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4611 | "%s: MAX TM Level Scan not allowed", __func__); |
| 4612 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4613 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4614 | } |
| 4615 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 4616 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4617 | /* Check if scan is allowed at this point of time. |
| 4618 | */ |
| 4619 | if (!hdd_isScanAllowed(pHddCtx)) |
| 4620 | { |
| 4621 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 4622 | return -EBUSY; |
| 4623 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4624 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4625 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 4626 | |
| 4627 | if (NULL != request) |
| 4628 | { |
| 4629 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4630 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4631 | |
| 4632 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 4633 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 4634 | * is not aging out the scan results. |
| 4635 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4636 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4637 | { |
| 4638 | request->n_ssids = 0; |
| 4639 | } |
| 4640 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4641 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4642 | { |
| 4643 | tCsrSSIDInfo *SsidInfo; |
| 4644 | int j; |
| 4645 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 4646 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 4647 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 4648 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 4649 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 4650 | |
| 4651 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 4652 | { |
| 4653 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4654 | "memory alloc failed SSIDInfo buffer"); |
| 4655 | return -ENOMEM; |
| 4656 | } |
| 4657 | |
| 4658 | /* copy all the ssid's and their length */ |
| 4659 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 4660 | { |
| 4661 | /* get the ssid length */ |
| 4662 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 4663 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 4664 | SsidInfo->SSID.length); |
| 4665 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
| 4666 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s", |
| 4667 | j, SsidInfo->SSID.ssId); |
| 4668 | } |
| 4669 | /* set the scan type to active */ |
| 4670 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4671 | } |
| 4672 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 4673 | { |
| 4674 | /* set the scan type to active */ |
| 4675 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4676 | } |
| 4677 | else |
| 4678 | { |
| 4679 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 4680 | scanRequest.scanType = pScanInfo->scan_mode; |
| 4681 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4682 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4683 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 4684 | } |
| 4685 | else |
| 4686 | { |
| 4687 | /* set the scan type to active */ |
| 4688 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4689 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 4690 | |
| 4691 | /* set min and max channel time to zero */ |
| 4692 | scanRequest.minChnTime = 0; |
| 4693 | scanRequest.maxChnTime = 0; |
| 4694 | } |
| 4695 | |
| 4696 | /* set BSSType to default type */ |
| 4697 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 4698 | |
| 4699 | /*TODO: scan the requested channels only*/ |
| 4700 | |
| 4701 | /*Right now scanning all the channels */ |
| 4702 | if( request ) |
| 4703 | { |
| 4704 | if( request->n_channels ) |
| 4705 | { |
| 4706 | channelList = vos_mem_malloc( request->n_channels ); |
| 4707 | if( NULL == channelList ) |
| 4708 | { |
| 4709 | status = -ENOMEM; |
| 4710 | goto free_mem; |
| 4711 | } |
| 4712 | |
| 4713 | for( i = 0 ; i < request->n_channels ; i++ ) |
| 4714 | channelList[i] = request->channels[i]->hw_value; |
| 4715 | } |
| 4716 | |
| 4717 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 4718 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 4719 | |
| 4720 | /* set requestType to full scan */ |
| 4721 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4722 | |
| 4723 | /* 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] | 4724 | * 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] | 4725 | * 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] | 4726 | */ |
| 4727 | |
| 4728 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4729 | * and in that case driver shoudnt flush scan results. If |
| 4730 | * driver flushes the scan results here and unfortunately if |
| 4731 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 4732 | * fails which is not desired |
| 4733 | */ |
| 4734 | |
| 4735 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 4736 | { |
| 4737 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4738 | pAdapter->sessionId ); |
| 4739 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4740 | |
| 4741 | if( request->ie_len ) |
| 4742 | { |
| 4743 | /* save this for future association (join requires this) */ |
| 4744 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 4745 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 4746 | pScanInfo->scanAddIE.length = request->ie_len; |
| 4747 | |
| 4748 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4749 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4750 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4751 | ) |
| 4752 | { |
| 4753 | pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata; |
| 4754 | pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length; |
| 4755 | } |
| 4756 | |
| 4757 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 4758 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 4759 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4760 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 4761 | request->ie_len); |
| 4762 | if (pP2pIe != NULL) |
| 4763 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 4764 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 4765 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 4766 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 4767 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4768 | { |
| 4769 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 4770 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4771 | "Go nego completed to Connection is started"); |
| 4772 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4773 | "for 8way Handshake"); |
| 4774 | } |
| 4775 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 4776 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 4777 | { |
| 4778 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 4779 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 4780 | "Disconnected state to Connection is started"); |
| 4781 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 4782 | "for 4way Handshake"); |
| 4783 | } |
| 4784 | #endif |
| 4785 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4786 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 4787 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4788 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4789 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4790 | "%s: This is a P2P Search", __func__); |
| 4791 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4792 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4793 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 4794 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 4795 | /* set requestType to P2P Discovery */ |
| 4796 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4797 | } |
| 4798 | |
| 4799 | /* |
| 4800 | Skip Dfs Channel in case of P2P Search |
| 4801 | if it is set in ini file |
| 4802 | */ |
| 4803 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 4804 | { |
| 4805 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 4806 | } |
| 4807 | else |
| 4808 | { |
| 4809 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 4810 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4811 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4812 | } |
| 4813 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4814 | } |
| 4815 | } |
| 4816 | |
| 4817 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 4818 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4819 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 4820 | * address the following issues. |
| 4821 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 4822 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 4823 | * for long time, this result in apps running at full power for long time. |
| 4824 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 4825 | * be stuck in full power because of resume BMPS |
| 4826 | */ |
| 4827 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4828 | |
| 4829 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4830 | pAdapter->sessionId, &scanRequest, &scanId, |
| 4831 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4833 | if (eHAL_STATUS_SUCCESS != status) |
| 4834 | { |
| 4835 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4836 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 4837 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 4838 | if(eHAL_STATUS_RESOURCES == status) |
| 4839 | { |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 4840 | 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] | 4841 | status = -EBUSY; |
| 4842 | } else { |
| 4843 | status = -EIO; |
| 4844 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4845 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4846 | goto free_mem; |
| 4847 | } |
| 4848 | |
| 4849 | pScanInfo->mScanPending = TRUE; |
| 4850 | pAdapter->request = request; |
| 4851 | pScanInfo->scanId = scanId; |
| 4852 | |
| 4853 | complete(&pScanInfo->scan_req_completion_event); |
| 4854 | |
| 4855 | free_mem: |
| 4856 | if( scanRequest.SSIDs.SSIDList ) |
| 4857 | { |
| 4858 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 4859 | } |
| 4860 | |
| 4861 | if( channelList ) |
| 4862 | vos_mem_free( channelList ); |
| 4863 | |
| 4864 | EXIT(); |
| 4865 | |
| 4866 | return status; |
| 4867 | } |
| 4868 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 4869 | |
| 4870 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 4871 | { |
| 4872 | v_U8_t iniDot11Mode = |
| 4873 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 4874 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 4875 | |
| 4876 | switch ( iniDot11Mode ) |
| 4877 | { |
| 4878 | case eHDD_DOT11_MODE_AUTO: |
| 4879 | case eHDD_DOT11_MODE_11ac: |
| 4880 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 4881 | #ifdef WLAN_FEATURE_11AC |
| 4882 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 4883 | #else |
| 4884 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4885 | #endif |
| 4886 | break; |
| 4887 | case eHDD_DOT11_MODE_11n: |
| 4888 | case eHDD_DOT11_MODE_11n_ONLY: |
| 4889 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 4890 | break; |
| 4891 | default: |
| 4892 | hddDot11Mode = iniDot11Mode; |
| 4893 | break; |
| 4894 | } |
| 4895 | /* This call decides required channel bonding mode */ |
| 4896 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 4897 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 4898 | operationChannel); |
| 4899 | } |
| 4900 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4901 | /* |
| 4902 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4903 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4904 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4905 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4906 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4907 | { |
| 4908 | int status = 0; |
| 4909 | hdd_wext_state_t *pWextState; |
| 4910 | v_U32_t roamId; |
| 4911 | tCsrRoamProfile *pRoamProfile; |
| 4912 | eMib_dot11DesiredBssType connectedBssType; |
| 4913 | eCsrAuthType RSNAuthType; |
| 4914 | |
| 4915 | ENTER(); |
| 4916 | |
| 4917 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4918 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4919 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 4920 | { |
| 4921 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 4922 | return -EINVAL; |
| 4923 | } |
| 4924 | |
| 4925 | pRoamProfile = &pWextState->roamProfile; |
| 4926 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4927 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4928 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4929 | int ret = 0; |
| 4930 | hdd_station_ctx_t *pHddStaCtx; |
| 4931 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4932 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 4933 | |
| 4934 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 4935 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 4936 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4937 | { |
| 4938 | /* Issue disconnect to CSR */ |
| 4939 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4940 | if( eHAL_STATUS_SUCCESS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4941 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4942 | pAdapter->sessionId, |
| 4943 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 4944 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4945 | ret = wait_for_completion_interruptible_timeout( |
| 4946 | &pAdapter->disconnect_comp_var, |
| 4947 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4948 | if (0 == ret) |
| 4949 | { |
| 4950 | VOS_ASSERT(0); |
| 4951 | } |
| 4952 | } |
| 4953 | } |
| 4954 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 4955 | { |
| 4956 | ret = wait_for_completion_interruptible_timeout( |
| 4957 | &pAdapter->disconnect_comp_var, |
| 4958 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 4959 | if (0 == ret) |
| 4960 | { |
| 4961 | VOS_ASSERT(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4962 | } |
| 4963 | } |
| 4964 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4965 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4966 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 4967 | { |
| 4968 | /*QoS not enabled in cfg file*/ |
| 4969 | pRoamProfile->uapsd_mask = 0; |
| 4970 | } |
| 4971 | else |
| 4972 | { |
| 4973 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4974 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4975 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 4976 | } |
| 4977 | |
| 4978 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 4979 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 4980 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4981 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4982 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 4983 | ssid, ssid_len); |
| 4984 | |
| 4985 | if (bssid) |
| 4986 | { |
| 4987 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 4988 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 4989 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4990 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 4991 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4992 | case of join failure we should send valid BSSID to supplicant |
| 4993 | */ |
| 4994 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 4995 | WNI_CFG_BSSID_LEN); |
| 4996 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 4997 | else |
| 4998 | { |
| 4999 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 5000 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5001 | |
| 5002 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 5003 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5004 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5005 | /*set gen ie*/ |
| 5006 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 5007 | /*set auth*/ |
| 5008 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 5009 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5010 | #ifdef FEATURE_WLAN_WAPI |
| 5011 | if (pAdapter->wapi_info.nWapiMode) |
| 5012 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5013 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5014 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 5015 | { |
| 5016 | case WAPI_AUTH_MODE_PSK: |
| 5017 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5018 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5019 | pAdapter->wapi_info.wapiAuthMode); |
| 5020 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5021 | break; |
| 5022 | } |
| 5023 | case WAPI_AUTH_MODE_CERT: |
| 5024 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5025 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5026 | pAdapter->wapi_info.wapiAuthMode); |
| 5027 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5028 | break; |
| 5029 | } |
| 5030 | } // End of switch |
| 5031 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 5032 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 5033 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5034 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5035 | pRoamProfile->AuthType.numEntries = 1; |
| 5036 | pRoamProfile->EncryptionType.numEntries = 1; |
| 5037 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5038 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 5039 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5040 | } |
| 5041 | } |
| 5042 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5043 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5044 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5045 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5046 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5047 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5048 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 5049 | sizeof (tSirGtkOffloadParams)); |
| 5050 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5051 | } |
| 5052 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5053 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 5054 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5055 | if( operatingChannel ) |
| 5056 | { |
| 5057 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 5058 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5059 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5060 | else |
| 5061 | { |
| 5062 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5063 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5064 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5065 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 5066 | { |
| 5067 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 5068 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5069 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 5070 | * 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] | 5071 | * 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] | 5072 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5073 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 5074 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5075 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5076 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5077 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 5078 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5079 | |
| 5080 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5081 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 5082 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5083 | if ((eHAL_STATUS_SUCCESS != status) && |
| 5084 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5085 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5086 | |
| 5087 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5088 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 5089 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 5090 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5091 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5092 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5093 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5094 | |
| 5095 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5096 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5097 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5098 | } |
| 5099 | else |
| 5100 | { |
| 5101 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 5102 | return -EINVAL; |
| 5103 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5104 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5105 | return status; |
| 5106 | } |
| 5107 | |
| 5108 | /* |
| 5109 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 5110 | * This function is used to set the authentication type (OPEN/SHARED). |
| 5111 | * |
| 5112 | */ |
| 5113 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 5114 | enum nl80211_auth_type auth_type) |
| 5115 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5116 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5117 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5118 | |
| 5119 | ENTER(); |
| 5120 | |
| 5121 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5122 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5123 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5124 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5125 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5126 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 5127 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5128 | break; |
| 5129 | |
| 5130 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5131 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5132 | case NL80211_AUTHTYPE_FT: |
| 5133 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5134 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5135 | "%s: set authentication type to OPEN", __func__); |
| 5136 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5137 | break; |
| 5138 | |
| 5139 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5140 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5141 | "%s: set authentication type to SHARED", __func__); |
| 5142 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5143 | break; |
| 5144 | #ifdef FEATURE_WLAN_CCX |
| 5145 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5146 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5147 | "%s: set authentication type to CCKM WPA", __func__); |
| 5148 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5149 | break; |
| 5150 | #endif |
| 5151 | |
| 5152 | |
| 5153 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5154 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5155 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5156 | auth_type); |
| 5157 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5158 | return -EINVAL; |
| 5159 | } |
| 5160 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5161 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5162 | pHddStaCtx->conn_info.authType; |
| 5163 | return 0; |
| 5164 | } |
| 5165 | |
| 5166 | /* |
| 5167 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5168 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5169 | * |
| 5170 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5171 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5172 | u32 key_mgmt |
| 5173 | ) |
| 5174 | { |
| 5175 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5176 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5177 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5178 | /*set key mgmt type*/ |
| 5179 | switch(key_mgmt) |
| 5180 | { |
| 5181 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5182 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5183 | case WLAN_AKM_SUITE_FT_PSK: |
| 5184 | #endif |
| 5185 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5186 | __func__); |
| 5187 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5188 | break; |
| 5189 | |
| 5190 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5191 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5192 | case WLAN_AKM_SUITE_FT_8021X: |
| 5193 | #endif |
| 5194 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5195 | __func__); |
| 5196 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5197 | break; |
| 5198 | #ifdef FEATURE_WLAN_CCX |
| 5199 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5200 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5201 | case WLAN_AKM_SUITE_CCKM: |
| 5202 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5203 | __func__); |
| 5204 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5205 | break; |
| 5206 | #endif |
| 5207 | |
| 5208 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5209 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5210 | __func__, key_mgmt); |
| 5211 | return -EINVAL; |
| 5212 | |
| 5213 | } |
| 5214 | return 0; |
| 5215 | } |
| 5216 | |
| 5217 | /* |
| 5218 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5219 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5220 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5221 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5222 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5223 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5224 | bool ucast |
| 5225 | ) |
| 5226 | { |
| 5227 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5228 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5229 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5230 | |
| 5231 | ENTER(); |
| 5232 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5233 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5234 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5235 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5236 | __func__, cipher); |
| 5237 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5238 | } |
| 5239 | else |
| 5240 | { |
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 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5243 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5244 | { |
| 5245 | case IW_AUTH_CIPHER_NONE: |
| 5246 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5247 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5248 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5249 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5250 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5251 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5252 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5253 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5254 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5255 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5256 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5257 | case WLAN_CIPHER_SUITE_TKIP: |
| 5258 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5259 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5260 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5261 | case WLAN_CIPHER_SUITE_CCMP: |
| 5262 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5263 | break; |
| 5264 | #ifdef FEATURE_WLAN_WAPI |
| 5265 | case WLAN_CIPHER_SUITE_SMS4: |
| 5266 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5267 | break; |
| 5268 | #endif |
| 5269 | |
| 5270 | #ifdef FEATURE_WLAN_CCX |
| 5271 | case WLAN_CIPHER_SUITE_KRK: |
| 5272 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5273 | break; |
| 5274 | #endif |
| 5275 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5276 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5277 | __func__, cipher); |
| 5278 | return -EOPNOTSUPP; |
| 5279 | } |
| 5280 | } |
| 5281 | |
| 5282 | if (ucast) |
| 5283 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5284 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5285 | __func__, encryptionType); |
| 5286 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5287 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5288 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5289 | encryptionType; |
| 5290 | } |
| 5291 | else |
| 5292 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5293 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5294 | __func__, encryptionType); |
| 5295 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5296 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5297 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5298 | } |
| 5299 | |
| 5300 | return 0; |
| 5301 | } |
| 5302 | |
| 5303 | |
| 5304 | /* |
| 5305 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5306 | * This function is used to parse WPA/RSN IE's. |
| 5307 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5308 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5309 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5310 | size_t ie_len |
| 5311 | ) |
| 5312 | { |
| 5313 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5314 | u8 *genie = ie; |
| 5315 | v_U16_t remLen = ie_len; |
| 5316 | #ifdef FEATURE_WLAN_WAPI |
| 5317 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5318 | u16 *tmp; |
| 5319 | v_U16_t akmsuiteCount; |
| 5320 | int *akmlist; |
| 5321 | #endif |
| 5322 | ENTER(); |
| 5323 | |
| 5324 | /* clear previous assocAddIE */ |
| 5325 | pWextState->assocAddIE.length = 0; |
| 5326 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5327 | |
| 5328 | while (remLen >= 2) |
| 5329 | { |
| 5330 | v_U16_t eLen = 0; |
| 5331 | v_U8_t elementId; |
| 5332 | elementId = *genie++; |
| 5333 | eLen = *genie++; |
| 5334 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5335 | |
| 5336 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5337 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5338 | |
| 5339 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5340 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5341 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5342 | 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] | 5343 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5344 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5345 | "%s: Invalid WPA IE", __func__); |
| 5346 | return -EINVAL; |
| 5347 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5348 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5349 | { |
| 5350 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5351 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5352 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5353 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5354 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5355 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5356 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5357 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5358 | VOS_ASSERT(0); |
| 5359 | return -ENOMEM; |
| 5360 | } |
| 5361 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5362 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5363 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5364 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5365 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5366 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5367 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5368 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5369 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5370 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5371 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5372 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5373 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5374 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5375 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5376 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5377 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 5378 | P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5379 | /*Consider P2P IE, only for P2P Client */ |
| 5380 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5381 | { |
| 5382 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5383 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5384 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5385 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5386 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5387 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5388 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5389 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5390 | VOS_ASSERT(0); |
| 5391 | return -ENOMEM; |
| 5392 | } |
| 5393 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5394 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5395 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5396 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5397 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5398 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5399 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5400 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5401 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5402 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5403 | /*Consider WFD IE, only for P2P Client */ |
| 5404 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5405 | { |
| 5406 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5407 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5408 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5409 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5410 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5411 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5412 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5413 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5414 | VOS_ASSERT(0); |
| 5415 | return -ENOMEM; |
| 5416 | } |
| 5417 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5418 | // WPS IE + P2P IE + WFD IE |
| 5419 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5420 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5422 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5423 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5424 | } |
| 5425 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5426 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5427 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5428 | HS20_OUI_TYPE_SIZE)) ) |
| 5429 | { |
| 5430 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5431 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5432 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5433 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5434 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5435 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5436 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5437 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5438 | VOS_ASSERT(0); |
| 5439 | return -ENOMEM; |
| 5440 | } |
| 5441 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5442 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5443 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5444 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5445 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5446 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5447 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | break; |
| 5449 | case DOT11F_EID_RSN: |
| 5450 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 5451 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5452 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 5453 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 5454 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 5455 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5456 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 5457 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5458 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5459 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5460 | 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] | 5461 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5462 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5463 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5464 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5465 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5466 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5467 | VOS_ASSERT(0); |
| 5468 | return -ENOMEM; |
| 5469 | } |
| 5470 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5471 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5472 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5473 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5474 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5475 | break; |
| 5476 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5477 | #ifdef FEATURE_WLAN_WAPI |
| 5478 | case WLAN_EID_WAPI: |
| 5479 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
| 5480 | hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n", |
| 5481 | pAdapter->wapi_info.nWapiMode); |
| 5482 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5483 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5484 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 5485 | tmp = tmp + 1; |
| 5486 | akmlist = (int *)(tmp); |
| 5487 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 5488 | { |
| 5489 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 5490 | } |
| 5491 | else |
| 5492 | { |
| 5493 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n"); |
| 5494 | VOS_ASSERT(0); |
| 5495 | return -EINVAL; |
| 5496 | } |
| 5497 | |
| 5498 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 5499 | { |
| 5500 | 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] | 5501 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5502 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5503 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5504 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5505 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5506 | 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] | 5507 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5508 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 5509 | } |
| 5510 | break; |
| 5511 | #endif |
| 5512 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5513 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5514 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5515 | /* when Unknown IE is received we should break and continue |
| 5516 | * to the next IE in the buffer instead we were returning |
| 5517 | * so changing this to break */ |
| 5518 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5519 | } |
| 5520 | genie += eLen; |
| 5521 | remLen -= eLen; |
| 5522 | } |
| 5523 | EXIT(); |
| 5524 | return 0; |
| 5525 | } |
| 5526 | |
| 5527 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 5528 | * FUNCTION: hdd_isWPAIEPresent |
| 5529 | * Parse the received IE to find the WPA IE |
| 5530 | * |
| 5531 | */ |
| 5532 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 5533 | { |
| 5534 | v_U8_t eLen = 0; |
| 5535 | v_U16_t remLen = ie_len; |
| 5536 | v_U8_t elementId = 0; |
| 5537 | |
| 5538 | while (remLen >= 2) |
| 5539 | { |
| 5540 | elementId = *ie++; |
| 5541 | eLen = *ie++; |
| 5542 | remLen -= 2; |
| 5543 | if (eLen > remLen) |
| 5544 | { |
| 5545 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5546 | "%s: IE length is wrong %d", __func__, eLen); |
| 5547 | return FALSE; |
| 5548 | } |
| 5549 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 5550 | { |
| 5551 | /* OUI - 0x00 0X50 0XF2 |
| 5552 | WPA Information Element - 0x01 |
| 5553 | WPA version - 0x01*/ |
| 5554 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 5555 | return TRUE; |
| 5556 | } |
| 5557 | ie += eLen; |
| 5558 | remLen -= eLen; |
| 5559 | } |
| 5560 | return FALSE; |
| 5561 | } |
| 5562 | |
| 5563 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5564 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5565 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5566 | * parameters during connect operation. |
| 5567 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5568 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5569 | struct cfg80211_connect_params *req |
| 5570 | ) |
| 5571 | { |
| 5572 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5573 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5574 | ENTER(); |
| 5575 | |
| 5576 | /*set wpa version*/ |
| 5577 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5578 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5579 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5580 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 5581 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5582 | { |
| 5583 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5584 | } |
| 5585 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 5586 | { |
| 5587 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5588 | } |
| 5589 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5590 | |
| 5591 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5592 | pWextState->wpaVersion); |
| 5593 | |
| 5594 | /*set authentication type*/ |
| 5595 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 5596 | |
| 5597 | if (0 > status) |
| 5598 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5599 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5600 | "%s: failed to set authentication type ", __func__); |
| 5601 | return status; |
| 5602 | } |
| 5603 | |
| 5604 | /*set key mgmt type*/ |
| 5605 | if (req->crypto.n_akm_suites) |
| 5606 | { |
| 5607 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 5608 | if (0 > status) |
| 5609 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5610 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5611 | __func__); |
| 5612 | return status; |
| 5613 | } |
| 5614 | } |
| 5615 | |
| 5616 | /*set pairwise cipher type*/ |
| 5617 | if (req->crypto.n_ciphers_pairwise) |
| 5618 | { |
| 5619 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 5620 | req->crypto.ciphers_pairwise[0], true); |
| 5621 | if (0 > status) |
| 5622 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5623 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5624 | "%s: failed to set unicast cipher type", __func__); |
| 5625 | return status; |
| 5626 | } |
| 5627 | } |
| 5628 | else |
| 5629 | { |
| 5630 | /*Reset previous cipher suite to none*/ |
| 5631 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 5632 | if (0 > status) |
| 5633 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5634 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5635 | "%s: failed to set unicast cipher type", __func__); |
| 5636 | return status; |
| 5637 | } |
| 5638 | } |
| 5639 | |
| 5640 | /*set group cipher type*/ |
| 5641 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 5642 | false); |
| 5643 | |
| 5644 | if (0 > status) |
| 5645 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5646 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5647 | __func__); |
| 5648 | return status; |
| 5649 | } |
| 5650 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5651 | #ifdef WLAN_FEATURE_11W |
| 5652 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 5653 | #endif |
| 5654 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5655 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 5656 | if (req->ie_len) |
| 5657 | { |
| 5658 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 5659 | if ( 0 > status) |
| 5660 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5661 | 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] | 5662 | __func__); |
| 5663 | return status; |
| 5664 | } |
| 5665 | } |
| 5666 | |
| 5667 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5668 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5669 | { |
| 5670 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 5671 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 5672 | ) |
| 5673 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5674 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5675 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 5676 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5677 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5678 | __func__); |
| 5679 | return -EOPNOTSUPP; |
| 5680 | } |
| 5681 | else |
| 5682 | { |
| 5683 | u8 key_len = req->key_len; |
| 5684 | u8 key_idx = req->key_idx; |
| 5685 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5686 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5687 | && (CSR_MAX_NUM_KEY > key_idx) |
| 5688 | ) |
| 5689 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5690 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5691 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5692 | __func__, key_idx, key_len); |
| 5693 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5694 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5695 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5696 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5697 | (u8)key_len; |
| 5698 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 5699 | } |
| 5700 | } |
| 5701 | } |
| 5702 | } |
| 5703 | |
| 5704 | return status; |
| 5705 | } |
| 5706 | |
| 5707 | /* |
| 5708 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5709 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5710 | * parameters during connect operation. |
| 5711 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5712 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5713 | struct net_device *ndev, |
| 5714 | struct cfg80211_connect_params *req |
| 5715 | ) |
| 5716 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5717 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5718 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5719 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
| 5720 | hdd_context_t *pHddCtx = NULL; |
| 5721 | |
| 5722 | ENTER(); |
| 5723 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5724 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5725 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 5726 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5727 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5728 | status = wlan_hdd_validate_context(pHddCtx); |
| 5729 | |
| 5730 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5731 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5732 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5733 | "%s: HDD context is not valid", __func__); |
| 5734 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5735 | } |
| 5736 | |
| 5737 | #ifdef WLAN_BTAMP_FEATURE |
| 5738 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5739 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5740 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5741 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5742 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5743 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5744 | } |
| 5745 | #endif |
| 5746 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5747 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5748 | |
| 5749 | if ( 0 > status) |
| 5750 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5751 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5752 | __func__); |
| 5753 | return status; |
| 5754 | } |
| 5755 | |
| 5756 | //If Device Mode is Station Concurrent Sessions Exit BMps |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 5757 | //P2P Mode will be taken care in Open/close adapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5758 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 5759 | (vos_concurrent_sessions_running())) |
| 5760 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5761 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5762 | } |
| 5763 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5764 | if ( req->channel ) |
| 5765 | { |
| 5766 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 5767 | req->ssid_len, req->bssid, |
| 5768 | req->channel->hw_value); |
| 5769 | } |
| 5770 | else |
| 5771 | { |
| 5772 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5773 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 5774 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5775 | |
| 5776 | if (0 > status) |
| 5777 | { |
| 5778 | //ReEnable BMPS if disabled |
| 5779 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 5780 | (NULL != pHddCtx)) |
| 5781 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5782 | if (pHddCtx->hdd_wlan_suspended) |
| 5783 | { |
| 5784 | hdd_set_pwrparams(pHddCtx); |
| 5785 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5786 | //ReEnable Bmps and Imps back |
| 5787 | hdd_enable_bmps_imps(pHddCtx); |
| 5788 | } |
| 5789 | |
| 5790 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 5791 | return status; |
| 5792 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5793 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5794 | EXIT(); |
| 5795 | return status; |
| 5796 | } |
| 5797 | |
| 5798 | |
| 5799 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5800 | * FUNCTION: wlan_hdd_disconnect |
| 5801 | * This function is used to issue a disconnect request to SME |
| 5802 | */ |
| 5803 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 5804 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5805 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5806 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5807 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5808 | |
| 5809 | status = wlan_hdd_validate_context(pHddCtx); |
| 5810 | |
| 5811 | if (0 != status) |
| 5812 | { |
| 5813 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5814 | "%s: HDD context is not valid", __func__); |
| 5815 | return status; |
| 5816 | } |
| 5817 | |
| 5818 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5819 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5820 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5821 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5822 | /*issue disconnect*/ |
| 5823 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5824 | pAdapter->sessionId, reason); |
| 5825 | |
| 5826 | if ( 0 != status ) |
| 5827 | { |
| 5828 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5829 | "%s csrRoamDisconnect failure, returned %d \n", |
| 5830 | __func__, (int)status ); |
| 5831 | return -EINVAL; |
| 5832 | } |
| 5833 | wait_for_completion_interruptible_timeout( |
| 5834 | &pAdapter->disconnect_comp_var, |
| 5835 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5836 | /*stop tx queues*/ |
| 5837 | netif_tx_disable(pAdapter->dev); |
| 5838 | netif_carrier_off(pAdapter->dev); |
| 5839 | return status; |
| 5840 | } |
| 5841 | |
| 5842 | |
| 5843 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5844 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 5845 | * This function is used to issue a disconnect request to SME |
| 5846 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5847 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5848 | struct net_device *dev, |
| 5849 | u16 reason |
| 5850 | ) |
| 5851 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5852 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 5853 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5854 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5855 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5856 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5857 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5858 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5859 | tANI_U8 staIdx; |
| 5860 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5861 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5862 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5863 | |
| 5864 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5865 | __func__,pAdapter->device_mode); |
| 5866 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5867 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 5868 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5869 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5870 | status = wlan_hdd_validate_context(pHddCtx); |
| 5871 | |
| 5872 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5873 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5874 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5875 | "%s: HDD context is not valid", __func__); |
| 5876 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5877 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5878 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5879 | if (NULL != pRoamProfile) |
| 5880 | { |
| 5881 | /*issue disconnect request to SME, if station is in connected state*/ |
| 5882 | if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) |
| 5883 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5884 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5885 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5886 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5887 | switch(reason) |
| 5888 | { |
| 5889 | case WLAN_REASON_MIC_FAILURE: |
| 5890 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 5891 | break; |
| 5892 | |
| 5893 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 5894 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 5895 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 5896 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 5897 | break; |
| 5898 | |
| 5899 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 5900 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 5901 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 5902 | break; |
| 5903 | |
| 5904 | case WLAN_REASON_DEAUTH_LEAVING: |
| 5905 | default: |
| 5906 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 5907 | break; |
| 5908 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5909 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5910 | pScanInfo = &pHddCtx->scan_info; |
| 5911 | if (pScanInfo->mScanPending) |
| 5912 | { |
| 5913 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
| 5914 | "Aborting Scan"); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 5915 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 5916 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5917 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5918 | #ifdef FEATURE_WLAN_TDLS |
| 5919 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5920 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5921 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5922 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 5923 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5924 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5925 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5926 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5927 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5928 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5929 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 5930 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5931 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5932 | pAdapter->sessionId, |
| 5933 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 5934 | } |
| 5935 | } |
| 5936 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5937 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 5938 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5939 | { |
| 5940 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5941 | "%s wlan_hdd_disconnect failure, returned %d \n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5942 | __func__, (int)status ); |
| 5943 | return -EINVAL; |
| 5944 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5945 | } |
| 5946 | } |
| 5947 | else |
| 5948 | { |
| 5949 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 5950 | } |
| 5951 | |
| 5952 | return status; |
| 5953 | } |
| 5954 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 5955 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5956 | /* |
| 5957 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5958 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5959 | * settings in IBSS mode. |
| 5960 | */ |
| 5961 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5962 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5963 | struct cfg80211_ibss_params *params |
| 5964 | ) |
| 5965 | { |
| 5966 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5967 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5968 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5969 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5970 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5971 | ENTER(); |
| 5972 | |
| 5973 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 5974 | |
| 5975 | if (params->ie_len && ( NULL != params->ie) ) |
| 5976 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5977 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5978 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5979 | { |
| 5980 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 5981 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5982 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5983 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5984 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5985 | tDot11fIEWPA dot11WPAIE; |
| 5986 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5987 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 5988 | |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 5989 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 5990 | params->ie_len, DOT11F_EID_WPA); |
| 5991 | if ( NULL != ie ) |
| 5992 | { |
| 5993 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 5994 | // Unpack the WPA IE |
| 5995 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 5996 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 5997 | &ie[2+4], |
| 5998 | ie[1] - 4, |
| 5999 | &dot11WPAIE); |
| 6000 | /*Extract the multicast cipher, the encType for unicast |
| 6001 | cipher for wpa-none is none*/ |
| 6002 | encryptionType = |
| 6003 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 6004 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6005 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6006 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6007 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 6008 | |
| 6009 | if (0 > status) |
| 6010 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6011 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6012 | __func__); |
| 6013 | return status; |
| 6014 | } |
| 6015 | } |
| 6016 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6017 | pWextState->roamProfile.AuthType.authType[0] = |
| 6018 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6019 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6020 | |
| 6021 | if (params->privacy) |
| 6022 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6023 | /* Security enabled IBSS, At this time there is no information available |
| 6024 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6025 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6026 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6027 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6028 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6029 | *enable privacy bit in beacons */ |
| 6030 | |
| 6031 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 6032 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6033 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6034 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6035 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 6036 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 6037 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6038 | return status; |
| 6039 | } |
| 6040 | |
| 6041 | /* |
| 6042 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6043 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6044 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6045 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6046 | struct net_device *dev, |
| 6047 | struct cfg80211_ibss_params *params |
| 6048 | ) |
| 6049 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6050 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6051 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6052 | tCsrRoamProfile *pRoamProfile; |
| 6053 | int status; |
| 6054 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6055 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6056 | |
| 6057 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6058 | |
| 6059 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6060 | "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6061 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6062 | status = wlan_hdd_validate_context(pHddCtx); |
| 6063 | |
| 6064 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6065 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6066 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6067 | "%s: HDD context is not valid", __func__); |
| 6068 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6069 | } |
| 6070 | |
| 6071 | if (NULL == pWextState) |
| 6072 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6073 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6074 | __func__); |
| 6075 | return -EIO; |
| 6076 | } |
| 6077 | |
| 6078 | pRoamProfile = &pWextState->roamProfile; |
| 6079 | |
| 6080 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 6081 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6082 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6083 | "%s Interface type is not set to IBSS \n", __func__); |
| 6084 | return -EINVAL; |
| 6085 | } |
| 6086 | |
| 6087 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6088 | if (NULL != |
| 6089 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6090 | params->chandef.chan) |
| 6091 | #else |
| 6092 | params->channel) |
| 6093 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6094 | { |
| 6095 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6096 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6097 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6098 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6099 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6100 | |
| 6101 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6102 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6103 | ieee80211_frequency_to_channel( |
| 6104 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6105 | params->chandef.chan->center_freq); |
| 6106 | #else |
| 6107 | params->channel->center_freq); |
| 6108 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6109 | |
| 6110 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 6111 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6112 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6113 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 6114 | __func__); |
| 6115 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6116 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6117 | |
| 6118 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6119 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6120 | if (channelNum == validChan[indx]) |
| 6121 | { |
| 6122 | break; |
| 6123 | } |
| 6124 | } |
| 6125 | if (indx >= numChans) |
| 6126 | { |
| 6127 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6128 | __func__, channelNum); |
| 6129 | return -EINVAL; |
| 6130 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6131 | /* Set the Operational Channel */ |
| 6132 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 6133 | channelNum); |
| 6134 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 6135 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6136 | pRoamProfile->ChannelInfo.ChannelList = |
| 6137 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6138 | } |
| 6139 | |
| 6140 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6141 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6142 | if (status < 0) |
| 6143 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6144 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6145 | __func__); |
| 6146 | return status; |
| 6147 | } |
| 6148 | |
| 6149 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6150 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6151 | params->ssid_len, params->bssid, |
| 6152 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6153 | |
| 6154 | if (0 > status) |
| 6155 | { |
| 6156 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6157 | return status; |
| 6158 | } |
| 6159 | |
| 6160 | return 0; |
| 6161 | } |
| 6162 | |
| 6163 | /* |
| 6164 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6165 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6166 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6167 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6168 | struct net_device *dev |
| 6169 | ) |
| 6170 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6171 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6172 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6173 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6174 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6175 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6176 | |
| 6177 | ENTER(); |
| 6178 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6179 | status = wlan_hdd_validate_context(pHddCtx); |
| 6180 | |
| 6181 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6182 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6183 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6184 | "%s: HDD context is not valid", __func__); |
| 6185 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6186 | } |
| 6187 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6188 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode); |
| 6189 | if (NULL == pWextState) |
| 6190 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6191 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6192 | __func__); |
| 6193 | return -EIO; |
| 6194 | } |
| 6195 | |
| 6196 | pRoamProfile = &pWextState->roamProfile; |
| 6197 | |
| 6198 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6199 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6200 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6201 | 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] | 6202 | __func__); |
| 6203 | return -EINVAL; |
| 6204 | } |
| 6205 | |
| 6206 | /* Issue Disconnect request */ |
| 6207 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6208 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6209 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6210 | |
| 6211 | return 0; |
| 6212 | } |
| 6213 | |
| 6214 | /* |
| 6215 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6216 | * This function is used to set the phy parameters |
| 6217 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6218 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6219 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6220 | u32 changed) |
| 6221 | { |
| 6222 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6223 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6224 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6225 | |
| 6226 | ENTER(); |
| 6227 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6228 | status = wlan_hdd_validate_context(pHddCtx); |
| 6229 | |
| 6230 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6231 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6232 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6233 | "%s: HDD context is not valid", __func__); |
| 6234 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6235 | } |
| 6236 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6237 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6238 | { |
| 6239 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6240 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6241 | wiphy->rts_threshold; |
| 6242 | |
| 6243 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6244 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6245 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6246 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6247 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6248 | __func__, rts_threshold); |
| 6249 | return -EINVAL; |
| 6250 | } |
| 6251 | |
| 6252 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6253 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6254 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6255 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6256 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6257 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6258 | __func__, rts_threshold); |
| 6259 | return -EIO; |
| 6260 | } |
| 6261 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6262 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6263 | rts_threshold); |
| 6264 | } |
| 6265 | |
| 6266 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 6267 | { |
| 6268 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 6269 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 6270 | wiphy->frag_threshold; |
| 6271 | |
| 6272 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6273 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6274 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6275 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6276 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6277 | frag_threshold); |
| 6278 | return -EINVAL; |
| 6279 | } |
| 6280 | |
| 6281 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 6282 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6283 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6284 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6285 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6286 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6287 | __func__, frag_threshold); |
| 6288 | return -EIO; |
| 6289 | } |
| 6290 | |
| 6291 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 6292 | frag_threshold); |
| 6293 | } |
| 6294 | |
| 6295 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 6296 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 6297 | { |
| 6298 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 6299 | wiphy->retry_short : |
| 6300 | wiphy->retry_long; |
| 6301 | |
| 6302 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 6303 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 6304 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6305 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6306 | __func__, retry_value); |
| 6307 | return -EINVAL; |
| 6308 | } |
| 6309 | |
| 6310 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6311 | { |
| 6312 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 6313 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6314 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6315 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6316 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6317 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6318 | __func__, retry_value); |
| 6319 | return -EIO; |
| 6320 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6321 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6322 | __func__, retry_value); |
| 6323 | } |
| 6324 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 6325 | { |
| 6326 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 6327 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6328 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6329 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6330 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6331 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6332 | __func__, retry_value); |
| 6333 | return -EIO; |
| 6334 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6335 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6336 | __func__, retry_value); |
| 6337 | } |
| 6338 | } |
| 6339 | |
| 6340 | return 0; |
| 6341 | } |
| 6342 | |
| 6343 | /* |
| 6344 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 6345 | * This function is used to set the txpower |
| 6346 | */ |
| 6347 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6348 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6349 | struct wireless_dev *wdev, |
| 6350 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6351 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6352 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6353 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6354 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6355 | #endif |
| 6356 | int dbm) |
| 6357 | { |
| 6358 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6359 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6360 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 6361 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6362 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6363 | |
| 6364 | ENTER(); |
| 6365 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6366 | status = wlan_hdd_validate_context(pHddCtx); |
| 6367 | |
| 6368 | if (0 != status) |
| 6369 | { |
| 6370 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6371 | "%s: HDD context is not valid", __func__); |
| 6372 | return status; |
| 6373 | } |
| 6374 | |
| 6375 | hHal = pHddCtx->hHal; |
| 6376 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6377 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 6378 | dbm, ccmCfgSetCallback, |
| 6379 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6380 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6381 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6382 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 6383 | return -EIO; |
| 6384 | } |
| 6385 | |
| 6386 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 6387 | dbm); |
| 6388 | |
| 6389 | switch(type) |
| 6390 | { |
| 6391 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 6392 | /* Fall through */ |
| 6393 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 6394 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 6395 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6396 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 6397 | __func__); |
| 6398 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6399 | } |
| 6400 | break; |
| 6401 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6402 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6403 | __func__); |
| 6404 | return -EOPNOTSUPP; |
| 6405 | break; |
| 6406 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6407 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 6408 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6409 | return -EIO; |
| 6410 | } |
| 6411 | |
| 6412 | return 0; |
| 6413 | } |
| 6414 | |
| 6415 | /* |
| 6416 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 6417 | * This function is used to read the txpower |
| 6418 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6419 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 6420 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 6421 | struct wireless_dev *wdev, |
| 6422 | #endif |
| 6423 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6424 | { |
| 6425 | |
| 6426 | hdd_adapter_t *pAdapter; |
| 6427 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6428 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6429 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6430 | ENTER(); |
| 6431 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6432 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6433 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6434 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6435 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6436 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6437 | "%s: HDD context is not valid", __func__); |
| 6438 | *dbm = 0; |
| 6439 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6440 | } |
| 6441 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6442 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6443 | if (NULL == pAdapter) |
| 6444 | { |
| 6445 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 6446 | return -ENOENT; |
| 6447 | } |
| 6448 | |
| 6449 | wlan_hdd_get_classAstats(pAdapter); |
| 6450 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 6451 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6452 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6453 | return 0; |
| 6454 | } |
| 6455 | |
| 6456 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 6457 | u8* mac, struct station_info *sinfo) |
| 6458 | { |
| 6459 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6460 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6461 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 6462 | tANI_U8 rate_flags; |
| 6463 | |
| 6464 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 6465 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6466 | |
| 6467 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 6468 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 6469 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 6470 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 6471 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 6472 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 6473 | tANI_U16 maxRate = 0; |
| 6474 | tANI_U16 myRate; |
| 6475 | tANI_U16 currentRate = 0; |
| 6476 | tANI_U8 maxSpeedMCS = 0; |
| 6477 | tANI_U8 maxMCSIdx = 0; |
| 6478 | tANI_U8 rateFlag = 1; |
| 6479 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6480 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6481 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6482 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6483 | #ifdef WLAN_FEATURE_11AC |
| 6484 | tANI_U32 vht_mcs_map; |
| 6485 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 6486 | #endif /* WLAN_FEATURE_11AC */ |
| 6487 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6488 | ENTER(); |
| 6489 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6490 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 6491 | (0 == ssidlen)) |
| 6492 | { |
| 6493 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 6494 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 6495 | /*To keep GUI happy*/ |
| 6496 | return 0; |
| 6497 | } |
| 6498 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6499 | status = wlan_hdd_validate_context(pHddCtx); |
| 6500 | |
| 6501 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6502 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6503 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6504 | "%s: HDD context is not valid", __func__); |
| 6505 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6506 | } |
| 6507 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6508 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 6509 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 6510 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6511 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6512 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 6513 | |
| 6514 | //convert to the UI units of 100kbps |
| 6515 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 6516 | |
| 6517 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6518 | 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] | 6519 | sinfo->signal, |
| 6520 | pCfg->reportMaxLinkSpeed, |
| 6521 | myRate, |
| 6522 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6523 | (int) pCfg->linkSpeedRssiMid, |
| 6524 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6525 | (int) rate_flags, |
| 6526 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6527 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6528 | |
| 6529 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 6530 | { |
| 6531 | // we do not want to necessarily report the current speed |
| 6532 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 6533 | { |
| 6534 | // report the max possible speed |
| 6535 | rssidx = 0; |
| 6536 | } |
| 6537 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 6538 | { |
| 6539 | // report the max possible speed with RSSI scaling |
| 6540 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 6541 | { |
| 6542 | // report the max possible speed |
| 6543 | rssidx = 0; |
| 6544 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6545 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6546 | { |
| 6547 | // report middle speed |
| 6548 | rssidx = 1; |
| 6549 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6550 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 6551 | { |
| 6552 | // report middle speed |
| 6553 | rssidx = 2; |
| 6554 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6555 | else |
| 6556 | { |
| 6557 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6558 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6559 | } |
| 6560 | } |
| 6561 | else |
| 6562 | { |
| 6563 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 6564 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6565 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 6566 | __func__, pCfg->reportMaxLinkSpeed); |
| 6567 | rssidx = 0; |
| 6568 | } |
| 6569 | |
| 6570 | maxRate = 0; |
| 6571 | |
| 6572 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6573 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 6574 | OperationalRates, &ORLeng)) |
| 6575 | { |
| 6576 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6577 | /*To keep GUI happy*/ |
| 6578 | return 0; |
| 6579 | } |
| 6580 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6581 | for (i = 0; i < ORLeng; i++) |
| 6582 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6583 | 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] | 6584 | { |
| 6585 | /* Validate Rate Set */ |
| 6586 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 6587 | { |
| 6588 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6589 | break; |
| 6590 | } |
| 6591 | } |
| 6592 | /* Update MAX rate */ |
| 6593 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6594 | } |
| 6595 | |
| 6596 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6597 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 6598 | ExtendedRates, &ERLeng)) |
| 6599 | { |
| 6600 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6601 | /*To keep GUI happy*/ |
| 6602 | return 0; |
| 6603 | } |
| 6604 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6605 | for (i = 0; i < ERLeng; i++) |
| 6606 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6607 | 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] | 6608 | { |
| 6609 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 6610 | { |
| 6611 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 6612 | break; |
| 6613 | } |
| 6614 | } |
| 6615 | /* Update MAX rate */ |
| 6616 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 6617 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6618 | /* Get MCS Rate Set -- but only if we are connected at MCS |
| 6619 | rates or if we are always reporting max speed or if we have |
| 6620 | good rssi */ |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 6621 | if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6622 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 6623 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 6624 | MCSRates, &MCSLeng)) |
| 6625 | { |
| 6626 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 6627 | /*To keep GUI happy*/ |
| 6628 | return 0; |
| 6629 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6630 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6631 | #ifdef WLAN_FEATURE_11AC |
| 6632 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6633 | 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] | 6634 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6635 | 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] | 6636 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6637 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6638 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6639 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6640 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6641 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6642 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6643 | maxMCSIdx = 7; |
| 6644 | } |
| 6645 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 6646 | { |
| 6647 | maxMCSIdx = 8; |
| 6648 | } |
| 6649 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 6650 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6651 | //VHT20 is supporting 0~8 |
| 6652 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6653 | maxMCSIdx = 8; |
| 6654 | else |
| 6655 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6656 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6657 | |
| 6658 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6659 | { |
| 6660 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 6661 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 6662 | } |
| 6663 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 6664 | { |
| 6665 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 6666 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 6667 | } |
| 6668 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6669 | { |
| 6670 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 6671 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 6672 | } |
| 6673 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6674 | maxSpeedMCS = 1; |
| 6675 | if (currentRate > maxRate) |
| 6676 | { |
| 6677 | maxRate = currentRate; |
| 6678 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6679 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6680 | } |
| 6681 | else |
| 6682 | #endif /* WLAN_FEATURE_11AC */ |
| 6683 | { |
| 6684 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6685 | { |
| 6686 | rateFlag |= 1; |
| 6687 | } |
| 6688 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6689 | { |
| 6690 | rateFlag |= 2; |
| 6691 | } |
| 6692 | |
| 6693 | for (i = 0; i < MCSLeng; i++) |
| 6694 | { |
| 6695 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 6696 | for (j = 0; j < temp; j++) |
| 6697 | { |
| 6698 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 6699 | { |
| 6700 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 6701 | break; |
| 6702 | } |
| 6703 | } |
| 6704 | if ((j < temp) && (currentRate > maxRate)) |
| 6705 | { |
| 6706 | maxRate = currentRate; |
| 6707 | maxSpeedMCS = 1; |
| 6708 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 6709 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6710 | } |
| 6711 | } |
| 6712 | } |
| 6713 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6714 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 6715 | { |
| 6716 | maxRate = myRate; |
| 6717 | maxSpeedMCS = 1; |
| 6718 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6719 | } |
| 6720 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6721 | // 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] | 6722 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 6723 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6724 | { |
| 6725 | maxRate = myRate; |
| 6726 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6727 | { |
| 6728 | maxSpeedMCS = 0; |
| 6729 | } |
| 6730 | else |
| 6731 | { |
| 6732 | maxSpeedMCS = 1; |
| 6733 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 6734 | } |
| 6735 | } |
| 6736 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6737 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6738 | { |
| 6739 | sinfo->txrate.legacy = maxRate; |
| 6740 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6741 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 6742 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6743 | } |
| 6744 | else |
| 6745 | { |
| 6746 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6747 | #ifdef WLAN_FEATURE_11AC |
| 6748 | sinfo->txrate.nss = 1; |
| 6749 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6750 | { |
| 6751 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6752 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6753 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6754 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6755 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6756 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6757 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6758 | } |
| 6759 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 6760 | { |
| 6761 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6762 | } |
| 6763 | #endif /* WLAN_FEATURE_11AC */ |
| 6764 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 6765 | { |
| 6766 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6767 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6768 | { |
| 6769 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6770 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6771 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6772 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6773 | { |
| 6774 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6775 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 6776 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6777 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6778 | pr_info("Reporting MCS rate %d flags %x\n", |
| 6779 | sinfo->txrate.mcs, |
| 6780 | sinfo->txrate.flags ); |
| 6781 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6782 | } |
| 6783 | } |
| 6784 | else |
| 6785 | { |
| 6786 | // report current rate instead of max rate |
| 6787 | |
| 6788 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 6789 | { |
| 6790 | //provide to the UI in units of 100kbps |
| 6791 | sinfo->txrate.legacy = myRate; |
| 6792 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6793 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 6794 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6795 | } |
| 6796 | else |
| 6797 | { |
| 6798 | //must be MCS |
| 6799 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6800 | #ifdef WLAN_FEATURE_11AC |
| 6801 | sinfo->txrate.nss = 1; |
| 6802 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6803 | { |
| 6804 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 6805 | } |
| 6806 | else |
| 6807 | #endif /* WLAN_FEATURE_11AC */ |
| 6808 | { |
| 6809 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 6810 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6811 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 6812 | { |
| 6813 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 6814 | } |
| 6815 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 6816 | { |
| 6817 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 6818 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 6819 | #ifdef WLAN_FEATURE_11AC |
| 6820 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 6821 | { |
| 6822 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 6823 | } |
| 6824 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6825 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 6826 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 6827 | sinfo->txrate.mcs, |
| 6828 | sinfo->txrate.flags ); |
| 6829 | #endif //LINKSPEED_DEBUG_ENABLED |
| 6830 | } |
| 6831 | } |
| 6832 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 6833 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 6834 | sinfo->tx_packets = |
| 6835 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 6836 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 6837 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 6838 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 6839 | |
| 6840 | sinfo->tx_retries = |
| 6841 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 6842 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 6843 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 6844 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 6845 | |
| 6846 | sinfo->tx_failed = |
| 6847 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 6848 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 6849 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 6850 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 6851 | |
| 6852 | sinfo->filled |= |
| 6853 | STATION_INFO_TX_PACKETS | |
| 6854 | STATION_INFO_TX_RETRIES | |
| 6855 | STATION_INFO_TX_FAILED; |
| 6856 | |
| 6857 | EXIT(); |
| 6858 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6859 | } |
| 6860 | |
| 6861 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 6862 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6863 | { |
| 6864 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6865 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6866 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6867 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6868 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6869 | ENTER(); |
| 6870 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6871 | if (NULL == pAdapter) |
| 6872 | { |
| 6873 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 6874 | return -ENODEV; |
| 6875 | } |
| 6876 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6877 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6878 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6879 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6880 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6881 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6882 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6883 | "%s: HDD context is not valid", __func__); |
| 6884 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6885 | } |
| 6886 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6887 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 6888 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 6889 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 6890 | (eConnectionState_Associated == |
| 6891 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 6892 | { |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 6893 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 6894 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6895 | { |
| 6896 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6897 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
| 6898 | __func__, vos_status); |
| 6899 | } |
| 6900 | } |
| 6901 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6902 | /**The get power cmd from the supplicant gets updated by the nl only |
| 6903 | *on successful execution of the function call |
| 6904 | *we are oppositely mapped w.r.t mode in the driver |
| 6905 | **/ |
| 6906 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 6907 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6908 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6909 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 6910 | { |
| 6911 | return -EINVAL; |
| 6912 | } |
| 6913 | return 0; |
| 6914 | } |
| 6915 | |
| 6916 | |
| 6917 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6918 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 6919 | struct net_device *netdev, |
| 6920 | u8 key_index) |
| 6921 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6922 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6923 | return 0; |
| 6924 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6925 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6926 | |
| 6927 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 6928 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6929 | struct net_device *dev, |
| 6930 | struct ieee80211_txq_params *params) |
| 6931 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6932 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6933 | return 0; |
| 6934 | } |
| 6935 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6936 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 6937 | struct ieee80211_txq_params *params) |
| 6938 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6939 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6940 | return 0; |
| 6941 | } |
| 6942 | #endif //LINUX_VERSION_CODE |
| 6943 | |
| 6944 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 6945 | struct net_device *dev, u8 *mac) |
| 6946 | { |
| 6947 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6948 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6949 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6950 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6951 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6952 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6953 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6954 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6955 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6956 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6957 | return -EINVAL; |
| 6958 | } |
| 6959 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6960 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6961 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6962 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6963 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6964 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6965 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6966 | "%s: HDD context is not valid", __func__); |
| 6967 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6968 | } |
| 6969 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6970 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6971 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6972 | ) |
| 6973 | { |
| 6974 | if( NULL == mac ) |
| 6975 | { |
| 6976 | v_U16_t i; |
| 6977 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 6978 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 6979 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 6980 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6981 | { |
| 6982 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 6983 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6984 | "%s: Delete STA with MAC::" |
| 6985 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 6986 | __func__, |
| 6987 | macAddr[0], macAddr[1], macAddr[2], |
| 6988 | macAddr[3], macAddr[4], macAddr[5]); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 6989 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 6990 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 6991 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6992 | } |
| 6993 | } |
| 6994 | } |
| 6995 | else |
| 6996 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 6997 | |
| 6998 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 6999 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7000 | { |
| 7001 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7002 | "%s: Skip this DEL STA as this is not used::" |
| 7003 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7004 | __func__, |
| 7005 | mac[0], mac[1], mac[2], |
| 7006 | mac[3], mac[4], mac[5]); |
| 7007 | return -ENOENT; |
| 7008 | } |
| 7009 | |
| 7010 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 7011 | { |
| 7012 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7013 | "%s: Skip this DEL STA as deauth is in progress::" |
| 7014 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7015 | __func__, |
| 7016 | mac[0], mac[1], mac[2], |
| 7017 | mac[3], mac[4], mac[5]); |
| 7018 | return -ENOENT; |
| 7019 | } |
| 7020 | |
| 7021 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 7022 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7023 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7024 | "%s: Delete STA with MAC::" |
| 7025 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7026 | __func__, |
| 7027 | mac[0], mac[1], mac[2], |
| 7028 | mac[3], mac[4], mac[5]); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7029 | |
| 7030 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 7031 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7032 | { |
| 7033 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 7034 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7035 | "%s: STA removal failed for ::" |
| 7036 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 7037 | __func__, |
| 7038 | mac[0], mac[1], mac[2], |
| 7039 | mac[3], mac[4], mac[5]); |
| 7040 | return -ENOENT; |
| 7041 | } |
| 7042 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7043 | } |
| 7044 | } |
| 7045 | |
| 7046 | EXIT(); |
| 7047 | |
| 7048 | return 0; |
| 7049 | } |
| 7050 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7051 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 7052 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 7053 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7054 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7055 | #ifdef FEATURE_WLAN_TDLS |
| 7056 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7057 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7058 | mask = params->sta_flags_mask; |
| 7059 | |
| 7060 | set = params->sta_flags_set; |
| 7061 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7062 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7063 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7064 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 7065 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 7066 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7067 | |
| 7068 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7069 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7070 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7071 | } |
| 7072 | } |
| 7073 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7074 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7075 | } |
| 7076 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7077 | |
| 7078 | #ifdef FEATURE_WLAN_LFR |
| 7079 | 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] | 7080 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7081 | { |
| 7082 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 7083 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7084 | static tANI_U32 i; // HDD Local Cache index |
| 7085 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7086 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7087 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7088 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7089 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7090 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7091 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7092 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7093 | ENTER(); |
| 7094 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7095 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7096 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7097 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7098 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7099 | return -EINVAL; |
| 7100 | } |
| 7101 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7102 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7103 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7104 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7105 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7106 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7107 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7108 | "%s: HDD context is not valid", __func__); |
| 7109 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7110 | } |
| 7111 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7112 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7113 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7114 | |
| 7115 | for (j = 0; j < i; j++) |
| 7116 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7117 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7118 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 7119 | { |
| 7120 | /* BSSID matched previous entry. Overwrite it. */ |
| 7121 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7122 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7123 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7124 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7125 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7126 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7127 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7128 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7129 | dump_bssid(pmksa->bssid); |
| 7130 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7131 | break; |
| 7132 | } |
| 7133 | } |
| 7134 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7135 | /* Check we compared all entries,if then take the first slot now */ |
| 7136 | if(j == MAX_PMKSAIDS_IN_CACHE) i=0; |
| 7137 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7138 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7139 | { |
| 7140 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
| 7141 | vos_mem_copy(PMKIDCache[i].BSSID, |
| 7142 | pmksa->bssid, ETHER_ADDR_LEN); |
| 7143 | vos_mem_copy(PMKIDCache[i].PMKID, |
| 7144 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7145 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7146 | 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] | 7147 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7148 | dump_bssid(pmksa->bssid); |
| 7149 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7150 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7151 | // 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] | 7152 | if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7153 | } |
| 7154 | |
| 7155 | |
| 7156 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7157 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7158 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7159 | 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] | 7160 | __func__, i ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7161 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7162 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7163 | PMKIDCache, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7164 | i ); |
| 7165 | return 0; |
| 7166 | } |
| 7167 | |
| 7168 | |
| 7169 | 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] | 7170 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7171 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7172 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7173 | // TODO: Implement this later. |
| 7174 | return 0; |
| 7175 | } |
| 7176 | |
| 7177 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 7178 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7179 | ENTER(); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7180 | // TODO: Implement this later. |
| 7181 | return 0; |
| 7182 | } |
| 7183 | #endif |
| 7184 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7185 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7186 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7187 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 7188 | { |
| 7189 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7190 | hdd_station_ctx_t *pHddStaCtx; |
| 7191 | |
| 7192 | if (NULL == pAdapter) |
| 7193 | { |
| 7194 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__); |
| 7195 | return -ENODEV; |
| 7196 | } |
| 7197 | |
| 7198 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7199 | |
| 7200 | // Added for debug on reception of Re-assoc Req. |
| 7201 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 7202 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7203 | 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] | 7204 | ftie->ie_len); |
| 7205 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 7206 | } |
| 7207 | |
| 7208 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7209 | 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] | 7210 | ftie->ie_len); |
| 7211 | #endif |
| 7212 | |
| 7213 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 7214 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 7215 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 7216 | ftie->ie_len); |
| 7217 | return 0; |
| 7218 | } |
| 7219 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7220 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7221 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 7222 | |
| 7223 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 7224 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7225 | { |
| 7226 | int ret; |
| 7227 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 7228 | hdd_context_t *pHddCtx; |
| 7229 | |
| 7230 | if (NULL == pAdapter) |
| 7231 | { |
| 7232 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7233 | "%s: HDD adapter is Null", __func__); |
| 7234 | return ; |
| 7235 | } |
| 7236 | |
| 7237 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7238 | if (NULL == pHddCtx) |
| 7239 | { |
| 7240 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7241 | "%s: HDD context is Null!!!", __func__); |
| 7242 | return ; |
| 7243 | } |
| 7244 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7245 | spin_lock(&pHddCtx->schedScan_lock); |
| 7246 | if (TRUE == pHddCtx->isWiphySuspended) |
| 7247 | { |
| 7248 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 7249 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7250 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7251 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 7252 | return ; |
| 7253 | } |
| 7254 | spin_unlock(&pHddCtx->schedScan_lock); |
| 7255 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7256 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 7257 | |
| 7258 | if (0 > ret) |
| 7259 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 7260 | |
| 7261 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7262 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7263 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7264 | } |
| 7265 | |
| 7266 | /* |
| 7267 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 7268 | * NL interface to enable PNO |
| 7269 | */ |
| 7270 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 7271 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 7272 | { |
| 7273 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7274 | tpSirPNOScanReq pPnoRequest = NULL; |
| 7275 | hdd_context_t *pHddCtx; |
| 7276 | tHalHandle hHal; |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 7277 | v_U32_t i, indx, num_ch, tempInterval; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7278 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7279 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7280 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7281 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7282 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7283 | |
| 7284 | if (NULL == pAdapter) |
| 7285 | { |
| 7286 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7287 | "%s: HDD adapter is Null", __func__); |
| 7288 | return -ENODEV; |
| 7289 | } |
| 7290 | |
| 7291 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7292 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7293 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7294 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7295 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7296 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7297 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7298 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7299 | } |
| 7300 | |
| 7301 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7302 | if (NULL == hHal) |
| 7303 | { |
| 7304 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7305 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7306 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7307 | } |
| 7308 | |
| 7309 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7310 | if (NULL == pPnoRequest) |
| 7311 | { |
| 7312 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7313 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7314 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7315 | } |
| 7316 | |
| 7317 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 7318 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 7319 | |
| 7320 | if (( !pPnoRequest->ucNetworksCount ) || |
| 7321 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 7322 | { |
| 7323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7324 | "Network input is not correct"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7325 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7326 | goto error; |
| 7327 | } |
| 7328 | |
| 7329 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 7330 | { |
| 7331 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7332 | "Incorrect number of channels"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7333 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7334 | goto error; |
| 7335 | } |
| 7336 | |
| 7337 | /* Framework provides one set of channels(all) |
| 7338 | * common for all saved profile */ |
| 7339 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 7340 | channels_allowed, &num_channels_allowed)) |
| 7341 | { |
| 7342 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7343 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7344 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7345 | goto error; |
| 7346 | } |
| 7347 | /* Checking each channel against allowed channel list */ |
| 7348 | num_ch = 0; |
| 7349 | for (i = 0; i < request->n_channels; i++) |
| 7350 | { |
| 7351 | for (indx = 0; indx < num_channels_allowed; indx++) |
| 7352 | { |
| 7353 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 7354 | { |
| 7355 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 7356 | break ; |
| 7357 | } |
| 7358 | } |
| 7359 | } |
| 7360 | |
| 7361 | /* Filling per profile params */ |
| 7362 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 7363 | { |
| 7364 | pPnoRequest->aNetworks[i].ssId.length = |
| 7365 | request->match_sets[i].ssid.ssid_len; |
| 7366 | |
| 7367 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 7368 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 7369 | { |
| 7370 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7371 | "SSID Len %d is not correct for network %d", |
| 7372 | pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7373 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7374 | goto error; |
| 7375 | } |
| 7376 | |
| 7377 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 7378 | request->match_sets[i].ssid.ssid, |
| 7379 | request->match_sets[i].ssid.ssid_len); |
| 7380 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 7381 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 7382 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 7383 | |
| 7384 | /*Copying list of valid channel into request */ |
| 7385 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 7386 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 7387 | |
| 7388 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 7389 | } |
| 7390 | |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 7391 | /* Driver gets only one time interval which is hardcoded in |
| 7392 | * supplicant for 10000ms. Taking power consumption into account 6 timers |
| 7393 | * will be used, Timervalue is increased exponentially i.e 10,20,40, |
| 7394 | * 80,160,320 secs. And number of scan cycle for each timer |
| 7395 | * is configurable through INI param gPNOScanTimerRepeatValue. |
| 7396 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 7397 | * will be repeated after each interval specified by supplicant |
| 7398 | * till PNO is disabled. |
| 7399 | */ |
| 7400 | if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue) |
| 7401 | pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 7402 | else |
| 7403 | pPnoRequest->scanTimers.ucScanTimersCount = |
| 7404 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 7405 | |
| 7406 | tempInterval = (request->interval)/1000; |
| 7407 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7408 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 7409 | tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue); |
| 7410 | for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++) |
| 7411 | { |
| 7412 | pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat = |
| 7413 | pHddCtx->cfg_ini->configPNOScanTimerRepeatValue; |
| 7414 | pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval; |
| 7415 | tempInterval *= 2; |
| 7416 | } |
| 7417 | //Repeat last timer until pno disabled. |
| 7418 | pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
| 7419 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7420 | pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND; |
| 7421 | |
| 7422 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7423 | pPnoRequest, pAdapter->sessionId, |
| 7424 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 7425 | if (eHAL_STATUS_SUCCESS != status) |
| 7426 | { |
| 7427 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7428 | "Failed to enable PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7429 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7430 | goto error; |
| 7431 | } |
| 7432 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7433 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7434 | "PNO scanRequest offloaded"); |
| 7435 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7436 | error: |
| 7437 | vos_mem_free(pPnoRequest); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7438 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7439 | } |
| 7440 | |
| 7441 | /* |
| 7442 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 7443 | * NL interface to disable PNO |
| 7444 | */ |
| 7445 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 7446 | struct net_device *dev) |
| 7447 | { |
| 7448 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 7449 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7450 | hdd_context_t *pHddCtx; |
| 7451 | tHalHandle hHal; |
| 7452 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7453 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7454 | |
| 7455 | ENTER(); |
| 7456 | |
| 7457 | if (NULL == pAdapter) |
| 7458 | { |
| 7459 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7460 | "%s: HDD adapter is Null", __func__); |
| 7461 | return -ENODEV; |
| 7462 | } |
| 7463 | |
| 7464 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7465 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7466 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7467 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 7468 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7469 | "%s: HDD context is Null", __func__); |
| 7470 | return -ENODEV; |
| 7471 | } |
| 7472 | |
| 7473 | /* The return 0 is intentional when isLogpInProgress and |
| 7474 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 7475 | * failure in sched_scan_stop , especially for a case where the unload |
| 7476 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 7477 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 7478 | * success. If it returns a failure , then its next invocation due to the |
| 7479 | * clean up of the second interface will have the dev pointer corresponding |
| 7480 | * to the first one leading to a crash. |
| 7481 | */ |
| 7482 | if (pHddCtx->isLogpInProgress) |
| 7483 | { |
| 7484 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7485 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 7486 | return ret; |
| 7487 | } |
| 7488 | |
| 7489 | if (pHddCtx->isLoadUnloadInProgress) |
| 7490 | { |
| 7491 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7492 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 7493 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7494 | } |
| 7495 | |
| 7496 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7497 | if (NULL == hHal) |
| 7498 | { |
| 7499 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7500 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7501 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7502 | } |
| 7503 | |
| 7504 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 7505 | if (NULL == pPnoRequest) |
| 7506 | { |
| 7507 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7508 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7509 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7510 | } |
| 7511 | |
| 7512 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 7513 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 7514 | pPnoRequest->ucNetworksCount = 0; |
| 7515 | |
| 7516 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 7517 | pAdapter->sessionId, |
| 7518 | NULL, pAdapter); |
| 7519 | if (eHAL_STATUS_SUCCESS != status) |
| 7520 | { |
| 7521 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7522 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7523 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7524 | } |
| 7525 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 7526 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7527 | "%s: PNO scan disabled", __func__); |
| 7528 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7529 | vos_mem_free(pPnoRequest); |
| 7530 | |
| 7531 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 7532 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 7533 | } |
| 7534 | |
| 7535 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 7536 | |
| 7537 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7538 | #ifdef FEATURE_WLAN_TDLS |
| 7539 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 7540 | u8 *peer, u8 action_code, u8 dialog_token, |
| 7541 | u16 status_code, const u8 *buf, size_t len) |
| 7542 | { |
| 7543 | |
| 7544 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7545 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7546 | u8 peerMac[6]; |
| 7547 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7548 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7549 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7550 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7551 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7552 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7553 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7554 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7555 | "Invalid arguments"); |
| 7556 | return -EINVAL; |
| 7557 | } |
| 7558 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7559 | if (pHddCtx->isLogpInProgress) |
| 7560 | { |
| 7561 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7562 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7563 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7564 | return -EBUSY; |
| 7565 | } |
| 7566 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7567 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7568 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7569 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7570 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 7571 | MAC_ADDRESS_STR " action %d declined.", |
| 7572 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7573 | return -ENOTSUPP; |
| 7574 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7575 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7576 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 7577 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 7578 | { |
| 7579 | /* if tdls_mode is disabled to respond to peer's request */ |
| 7580 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 7581 | { |
| 7582 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 7583 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7584 | " TDLS mode is disabled. action %d declined.", |
| 7585 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 7586 | |
| 7587 | return -ENOTSUPP; |
| 7588 | } |
| 7589 | } |
| 7590 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7591 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 7592 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 7593 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7594 | { |
| 7595 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7596 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7597 | " TDLS setup is ongoing. action %d declined.", |
| 7598 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7599 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7600 | } |
| 7601 | } |
| 7602 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7603 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 7604 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7605 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7606 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7607 | { |
| 7608 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 7609 | we return error code at 'add_station()'. Hence we have this |
| 7610 | check again in addtion to add_station(). |
| 7611 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7612 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7613 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7614 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7615 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7616 | " TDLS Max peer already connected. action %d declined.", |
| 7617 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7618 | goto error; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7619 | } |
| 7620 | else |
| 7621 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7622 | /* maximum reached. tweak to send error code to peer and return |
| 7623 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7624 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7625 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7626 | "%s: " MAC_ADDRESS_STR |
| 7627 | " TDLS Max peer already connected send response status %d", |
| 7628 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7629 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7630 | /* fall through to send setup resp with failure status |
| 7631 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7632 | } |
| 7633 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7634 | else |
| 7635 | { |
| 7636 | hddTdlsPeer_t *pTdlsPeer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7637 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7638 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7639 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7640 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 7641 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 7642 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7643 | return -EPERM; |
| 7644 | } |
| 7645 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7646 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7647 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7648 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7649 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7650 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7651 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 7652 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 7653 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7654 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7655 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7656 | /*Except teardown responder will not be used so just make 0*/ |
| 7657 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7658 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7659 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7660 | |
| 7661 | hddTdlsPeer_t *pTdlsPeer; |
| 7662 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac); |
| 7663 | |
| 7664 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 7665 | responder = pTdlsPeer->is_responder; |
| 7666 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7667 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 7668 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7669 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 7670 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 7671 | dialog_token, status_code, len); |
| 7672 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7673 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7674 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7675 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7676 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 7677 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7678 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7679 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 7680 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7681 | { |
| 7682 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 7683 | { |
| 7684 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7685 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7686 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7687 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 7688 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 7689 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7690 | } |
| 7691 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7692 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 7693 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 7694 | { |
| 7695 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7696 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n", |
| 7697 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 7698 | return -EBUSY; |
| 7699 | } |
| 7700 | |
| 7701 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7702 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 7703 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7704 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7705 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7706 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7707 | if (VOS_STATUS_SUCCESS != status) |
| 7708 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7709 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7710 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7711 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7712 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7713 | goto error; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7714 | } |
| 7715 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7716 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 7717 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 7718 | |
| 7719 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7720 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7721 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7722 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu", |
| 7723 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7724 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 7725 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 7726 | goto error; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7727 | } |
| 7728 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7729 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7730 | { |
| 7731 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7732 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7733 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7734 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7735 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 7736 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7737 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7738 | } |
| 7739 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 7740 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 7741 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 7742 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7743 | |
| 7744 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 7745 | error: |
| 7746 | /* max_sta_failed ; we didn't set to CONNECTING for this case, |
| 7747 | because we already know that this transaction will be failed, |
| 7748 | but we weren't sure if supplicant call DISABLE_LINK or not. So, |
| 7749 | to be safe, do not change the state mahine. |
| 7750 | */ |
| 7751 | if(max_sta_failed == 0 && |
| 7752 | (WLAN_IS_TDLS_SETUP_ACTION(action_code))) |
| 7753 | wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE); |
| 7754 | return -EPERM; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7755 | } |
| 7756 | |
| 7757 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 7758 | u8 *peer, enum nl80211_tdls_operation oper) |
| 7759 | { |
| 7760 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7761 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7762 | int status; |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7763 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7764 | const char *tdls_oper_str[]= { |
| 7765 | "NL80211_TDLS_DISCOVERY_REQ", |
| 7766 | "NL80211_TDLS_SETUP", |
| 7767 | "NL80211_TDLS_TEARDOWN", |
| 7768 | "NL80211_TDLS_ENABLE_LINK", |
| 7769 | "NL80211_TDLS_DISABLE_LINK", |
Gopichand Nakkala | 29d0019 | 2013-06-20 19:03:52 +0530 | [diff] [blame] | 7770 | "NL80211_TDLS_UNKNOWN_OPER"}; |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7771 | #endif |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7772 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7773 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7774 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7775 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7776 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7777 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7778 | return -EINVAL; |
| 7779 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7780 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7781 | status = wlan_hdd_validate_context(pHddCtx); |
| 7782 | |
| 7783 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7784 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7785 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7786 | "%s: HDD context is not valid", __func__); |
| 7787 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 7788 | } |
| 7789 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7790 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer); |
| 7791 | |
| 7792 | if ( NULL == pTdlsPeer ) { |
| 7793 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored", |
| 7794 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 7795 | return -EINVAL; |
| 7796 | } |
| 7797 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7798 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7799 | if((int)oper > 4) |
| 7800 | oper = 5; |
| 7801 | |
| 7802 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7803 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 7804 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7805 | tdls_oper_str[(int)oper]); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7806 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7807 | |
| 7808 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7809 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7810 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 7811 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 7812 | "TDLS Disabled in INI OR not enabled in FW. " |
| 7813 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7814 | return -ENOTSUPP; |
| 7815 | } |
| 7816 | |
| 7817 | switch (oper) { |
| 7818 | case NL80211_TDLS_ENABLE_LINK: |
| 7819 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7820 | VOS_STATUS status; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7821 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7822 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 7823 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 7824 | { |
| 7825 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 7826 | MAC_ADDRESS_STR " failed", |
| 7827 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 7828 | return -EINVAL; |
| 7829 | } |
| 7830 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7831 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7832 | { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7833 | long ret; |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 7834 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 7835 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 7836 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 7837 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 7838 | return -EINVAL; |
| 7839 | } |
| 7840 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7841 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 7842 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7843 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 7844 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 7845 | * register with the TL on after the response for this operation |
| 7846 | * is received . |
| 7847 | */ |
| 7848 | ret = wait_for_completion_interruptible_timeout( |
| 7849 | &pAdapter->tdls_link_establish_req_comp, |
| 7850 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 7851 | if (ret <= 0) |
| 7852 | { |
| 7853 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7854 | "%s: Link Establish Request Faled Status %ld", |
| 7855 | __func__, ret); |
| 7856 | return -EINVAL; |
| 7857 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7858 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7859 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 7860 | /* Mark TDLS client Authenticated .*/ |
| 7861 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 7862 | pTdlsPeer->staId, |
| 7863 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7864 | if (VOS_STATUS_SUCCESS == status) |
| 7865 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 7866 | if (pTdlsPeer->is_responder == 0) |
| 7867 | { |
| 7868 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 7869 | |
| 7870 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 7871 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 7872 | WAIT_TIME_TDLS_INITIATOR); |
| 7873 | /* suspend initiator TX until it receives direct packet from the |
| 7874 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 7875 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7876 | &staId, NULL); |
| 7877 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 7878 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 7879 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7880 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7881 | |
| 7882 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 7883 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 7884 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7885 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 7886 | int ac; |
| 7887 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 7888 | WLANTL_AC_VI, |
| 7889 | WLANTL_AC_BK, |
| 7890 | WLANTL_AC_BE }; |
| 7891 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 7892 | for(ac=0; ac < 4; ac++) |
| 7893 | { |
| 7894 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 7895 | pTdlsPeer->staId, ucAc[ac], |
| 7896 | tlTid[ac], tlTid[ac], 0, 0, |
| 7897 | WLANTL_BI_DIR ); |
| 7898 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 7899 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7900 | } |
| 7901 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7902 | } |
| 7903 | break; |
| 7904 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7905 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7906 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7907 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7908 | long status; |
| 7909 | |
| 7910 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 7911 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7912 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7913 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7914 | |
| 7915 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 7916 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 7917 | if (status <= 0) |
| 7918 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7919 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 7920 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7921 | "%s: Del station failed status %ld", |
| 7922 | __func__, status); |
| 7923 | return -EPERM; |
| 7924 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 7925 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7926 | } |
| 7927 | else |
| 7928 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7929 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7930 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7931 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 7932 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7933 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7934 | case NL80211_TDLS_TEARDOWN: |
| 7935 | case NL80211_TDLS_SETUP: |
| 7936 | case NL80211_TDLS_DISCOVERY_REQ: |
| 7937 | /* We don't support in-driver setup/teardown/discovery */ |
| 7938 | return -ENOTSUPP; |
| 7939 | default: |
| 7940 | return -ENOTSUPP; |
| 7941 | } |
| 7942 | return 0; |
| 7943 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 7944 | |
| 7945 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 7946 | struct net_device *dev, u8 *peer) |
| 7947 | { |
| 7948 | hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x", |
| 7949 | peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]); |
| 7950 | |
| 7951 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 7952 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 7953 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7954 | #endif |
| 7955 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7956 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 7957 | /* |
| 7958 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 7959 | * Callback rountine called upon receiving response for |
| 7960 | * get offload info |
| 7961 | */ |
| 7962 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 7963 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 7964 | { |
| 7965 | |
| 7966 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7967 | tANI_U8 tempReplayCounter[8]; |
| 7968 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 7969 | |
| 7970 | ENTER(); |
| 7971 | |
| 7972 | if (NULL == pAdapter) |
| 7973 | { |
| 7974 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7975 | "%s: HDD adapter is Null", __func__); |
| 7976 | return ; |
| 7977 | } |
| 7978 | |
| 7979 | if (NULL == pGtkOffloadGetInfoRsp) |
| 7980 | { |
| 7981 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7982 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 7983 | return ; |
| 7984 | } |
| 7985 | |
| 7986 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 7987 | { |
| 7988 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7989 | "%s: wlan Failed to get replay counter value", |
| 7990 | __func__); |
| 7991 | return ; |
| 7992 | } |
| 7993 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 7994 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7995 | /* Update replay counter */ |
| 7996 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 7997 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 7998 | |
| 7999 | { |
| 8000 | /* changing from little to big endian since supplicant |
| 8001 | * works on big endian format |
| 8002 | */ |
| 8003 | int i; |
| 8004 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 8005 | |
| 8006 | for (i = 0; i < 8; i++) |
| 8007 | { |
| 8008 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 8009 | } |
| 8010 | } |
| 8011 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8012 | /* Update replay counter to NL */ |
| 8013 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8014 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8015 | } |
| 8016 | |
| 8017 | /* |
| 8018 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 8019 | * This function is used to offload GTK rekeying job to the firmware. |
| 8020 | */ |
| 8021 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 8022 | struct cfg80211_gtk_rekey_data *data) |
| 8023 | { |
| 8024 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8025 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8026 | hdd_station_ctx_t *pHddStaCtx; |
| 8027 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8028 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8029 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8030 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8031 | |
| 8032 | ENTER(); |
| 8033 | |
| 8034 | if (NULL == pAdapter) |
| 8035 | { |
| 8036 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8037 | "%s: HDD adapter is Null", __func__); |
| 8038 | return -ENODEV; |
| 8039 | } |
| 8040 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8041 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8042 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8043 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8044 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8045 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8046 | "%s: HDD context is not valid", __func__); |
| 8047 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8048 | } |
| 8049 | |
| 8050 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8051 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8052 | if (NULL == hHal) |
| 8053 | { |
| 8054 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8055 | "%s: HAL context is Null!!!", __func__); |
| 8056 | return -EAGAIN; |
| 8057 | } |
| 8058 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8059 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 8060 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 8061 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 8062 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8063 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8064 | { |
| 8065 | /* changing from big to little endian since driver |
| 8066 | * works on little endian format |
| 8067 | */ |
| 8068 | tANI_U8 *p = |
| 8069 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 8070 | int i; |
| 8071 | |
| 8072 | for (i = 0; i < 8; i++) |
| 8073 | { |
| 8074 | p[7-i] = data->replay_ctr[i]; |
| 8075 | } |
| 8076 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8077 | |
| 8078 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 8079 | { |
| 8080 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8081 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 8082 | sizeof (tSirGtkOffloadParams)); |
| 8083 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8084 | pAdapter->sessionId); |
| 8085 | |
| 8086 | if (eHAL_STATUS_SUCCESS != status) |
| 8087 | { |
| 8088 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8089 | "%s: sme_SetGTKOffload failed, returned %d", |
| 8090 | __func__, status); |
| 8091 | return status; |
| 8092 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8093 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8094 | "%s: sme_SetGTKOffload successfull", __func__); |
| 8095 | } |
| 8096 | else |
| 8097 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8098 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8099 | "%s: wlan not suspended GTKOffload request is stored", |
| 8100 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8101 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 8102 | |
| 8103 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8104 | } |
| 8105 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 8106 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8107 | /* |
| 8108 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 8109 | * This function is used to set access control policy |
| 8110 | */ |
| 8111 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 8112 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 8113 | { |
| 8114 | int i; |
| 8115 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8116 | hdd_hostapd_state_t *pHostapdState; |
| 8117 | tsap_Config_t *pConfig; |
| 8118 | v_CONTEXT_t pVosContext = NULL; |
| 8119 | hdd_context_t *pHddCtx; |
| 8120 | int status; |
| 8121 | |
| 8122 | ENTER(); |
| 8123 | |
| 8124 | if (NULL == pAdapter) |
| 8125 | { |
| 8126 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8127 | "%s: HDD adapter is Null", __func__); |
| 8128 | return -ENODEV; |
| 8129 | } |
| 8130 | |
| 8131 | if (NULL == params) |
| 8132 | { |
| 8133 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8134 | "%s: params is Null", __func__); |
| 8135 | return -EINVAL; |
| 8136 | } |
| 8137 | |
| 8138 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8139 | status = wlan_hdd_validate_context(pHddCtx); |
| 8140 | |
| 8141 | if (0 != status) |
| 8142 | { |
| 8143 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8144 | "%s: HDD context is not valid", __func__); |
| 8145 | return status; |
| 8146 | } |
| 8147 | |
| 8148 | pVosContext = pHddCtx->pvosContext; |
| 8149 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8150 | |
| 8151 | if (NULL == pHostapdState) |
| 8152 | { |
| 8153 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8154 | "%s: pHostapdState is Null", __func__); |
| 8155 | return -EINVAL; |
| 8156 | } |
| 8157 | |
| 8158 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 8159 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 8160 | |
| 8161 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 8162 | { |
| 8163 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 8164 | |
| 8165 | /* default value */ |
| 8166 | pConfig->num_accept_mac = 0; |
| 8167 | pConfig->num_deny_mac = 0; |
| 8168 | |
| 8169 | /** |
| 8170 | * access control policy |
| 8171 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 8172 | * listed in hostapd.deny file. |
| 8173 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 8174 | * listed in hostapd.accept file. |
| 8175 | */ |
| 8176 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 8177 | { |
| 8178 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 8179 | } |
| 8180 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 8181 | { |
| 8182 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 8183 | } |
| 8184 | else |
| 8185 | { |
| 8186 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8187 | "%s:Acl Policy : %d is not supported", |
| 8188 | __func__, params->acl_policy); |
| 8189 | return -ENOTSUPP; |
| 8190 | } |
| 8191 | |
| 8192 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 8193 | { |
| 8194 | pConfig->num_accept_mac = params->n_acl_entries; |
| 8195 | for (i = 0; i < params->n_acl_entries; i++) |
| 8196 | { |
| 8197 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8198 | "** Add ACL MAC entry %i in WhiletList :" |
| 8199 | MAC_ADDRESS_STR, i, |
| 8200 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8201 | |
| 8202 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 8203 | sizeof(qcmacaddr)); |
| 8204 | } |
| 8205 | } |
| 8206 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 8207 | { |
| 8208 | pConfig->num_deny_mac = params->n_acl_entries; |
| 8209 | for (i = 0; i < params->n_acl_entries; i++) |
| 8210 | { |
| 8211 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8212 | "** Add ACL MAC entry %i in BlackList :" |
| 8213 | MAC_ADDRESS_STR, i, |
| 8214 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 8215 | |
| 8216 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 8217 | sizeof(qcmacaddr)); |
| 8218 | } |
| 8219 | } |
| 8220 | |
| 8221 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 8222 | { |
| 8223 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8224 | "%s: SAP Set Mac Acl fail", __func__); |
| 8225 | return -EINVAL; |
| 8226 | } |
| 8227 | } |
| 8228 | else |
| 8229 | { |
| 8230 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8231 | "%s: Invalid device_mode = %d", |
| 8232 | __func__, pAdapter->device_mode); |
| 8233 | return -EINVAL; |
| 8234 | } |
| 8235 | |
| 8236 | return 0; |
| 8237 | } |
| 8238 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8239 | #ifdef WLAN_NL80211_TESTMODE |
| 8240 | #ifdef FEATURE_WLAN_LPHB |
| 8241 | static void wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler |
| 8242 | ( |
| 8243 | void *pAdapter, |
| 8244 | void *indCont |
| 8245 | ) |
| 8246 | { |
| 8247 | tSirLPHBTimeoutInd *lphbTimeoutInd; |
| 8248 | struct sk_buff *skb; |
| 8249 | |
| 8250 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8251 | "LPHB wait timeout indication arrived"); |
| 8252 | |
| 8253 | if (NULL == indCont) |
| 8254 | { |
| 8255 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8256 | "LPHB timeout, invalid argument"); |
| 8257 | return; |
| 8258 | } |
| 8259 | |
| 8260 | lphbTimeoutInd = (tSirLPHBTimeoutInd *)indCont; |
| 8261 | skb = cfg80211_testmode_alloc_event_skb( |
| 8262 | ((hdd_adapter_t *)pAdapter)->wdev.wiphy, |
| 8263 | sizeof(tSirLPHBTimeoutInd), |
| 8264 | GFP_ATOMIC); |
| 8265 | if (!skb) |
| 8266 | { |
| 8267 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8268 | "LPHB timeout, NL buffer alloc fail"); |
| 8269 | return; |
| 8270 | } |
| 8271 | |
| 8272 | NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB); |
| 8273 | NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbTimeoutInd->protocolType); |
| 8274 | NLA_PUT(skb, WLAN_HDD_TM_ATTR_DATA, |
| 8275 | sizeof(tSirLPHBTimeoutInd), lphbTimeoutInd); |
| 8276 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 8277 | return; |
| 8278 | |
| 8279 | nla_put_failure: |
| 8280 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8281 | "NLA Put fail"); |
| 8282 | kfree_skb(skb); |
| 8283 | |
| 8284 | return; |
| 8285 | } |
| 8286 | #endif /* FEATURE_WLAN_LPHB */ |
| 8287 | |
| 8288 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 8289 | { |
| 8290 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 8291 | int err = 0; |
| 8292 | #ifdef FEATURE_WLAN_LPHB |
| 8293 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8294 | #endif /* FEATURE_WLAN_LPHB */ |
| 8295 | |
| 8296 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 8297 | if (err) |
| 8298 | { |
| 8299 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8300 | "%s Testmode INV ATTR", __func__); |
| 8301 | return err; |
| 8302 | } |
| 8303 | |
| 8304 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 8305 | { |
| 8306 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8307 | "%s Testmode INV CMD", __func__); |
| 8308 | return -EINVAL; |
| 8309 | } |
| 8310 | |
| 8311 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 8312 | { |
| 8313 | #ifdef FEATURE_WLAN_LPHB |
| 8314 | /* Low Power Heartbeat configuration request */ |
| 8315 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 8316 | { |
| 8317 | int buf_len; |
| 8318 | void *buf; |
| 8319 | tSirLPHBReq *hb_params = NULL; |
| 8320 | |
| 8321 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 8322 | { |
| 8323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8324 | "%s Testmode INV DATA", __func__); |
| 8325 | return -EINVAL; |
| 8326 | } |
| 8327 | |
| 8328 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 8329 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 8330 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 8331 | if (NULL == hb_params) |
| 8332 | { |
| 8333 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8334 | "%s Request Buffer Alloc Fail", __func__); |
| 8335 | return -EINVAL; |
| 8336 | } |
| 8337 | |
| 8338 | vos_mem_copy(hb_params, buf, buf_len); |
| 8339 | |
| 8340 | /* LPHB enable and disable request will send to FW |
| 8341 | * when host suspend and resume |
| 8342 | * host suspend -> enable LPHB |
| 8343 | * host resume -> disable LPHB |
| 8344 | * if host is not suspend, cache into HDD context |
| 8345 | * and when host goes to suspend, send request to FW */ |
| 8346 | if ((LPHB_SET_EN_PARAMS_INDID == hb_params->cmd) && |
| 8347 | (!pHddCtx->hdd_wlan_suspended)) |
| 8348 | { |
| 8349 | /* Feature enable command cache into HDD context, |
| 8350 | * if WLAN is not suspend |
| 8351 | * When WLAN goes into suspend, send enable command to FW */ |
| 8352 | pHddCtx->lphbEnableReq.enable = |
| 8353 | hb_params->params.lphbEnableReq.enable; |
| 8354 | pHddCtx->lphbEnableReq.item = |
| 8355 | hb_params->params.lphbEnableReq.item; |
| 8356 | pHddCtx->lphbEnableReq.session = |
| 8357 | hb_params->params.lphbEnableReq.session; |
| 8358 | vos_mem_free(hb_params); |
| 8359 | } |
| 8360 | else |
| 8361 | { |
| 8362 | eHalStatus smeStatus; |
| 8363 | |
| 8364 | /* If WLAN is suspend state, send enable command immediately */ |
| 8365 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 8366 | hb_params, |
| 8367 | wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler); |
| 8368 | if (eHAL_STATUS_SUCCESS != smeStatus) |
| 8369 | { |
| 8370 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8371 | "LPHB Config Fail, disable"); |
| 8372 | pHddCtx->lphbEnableReq.enable = 0; |
| 8373 | vos_mem_free(hb_params); |
| 8374 | } |
| 8375 | } |
| 8376 | return 0; |
| 8377 | } |
| 8378 | #endif /* FEATURE_WLAN_LPHB */ |
| 8379 | default: |
| 8380 | return -EOPNOTSUPP; |
| 8381 | } |
| 8382 | |
| 8383 | return err; |
| 8384 | } |
| 8385 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 8386 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8387 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 8388 | struct net_device *dev, |
| 8389 | int idx, struct survey_info *survey) |
| 8390 | { |
| 8391 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8392 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8393 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8394 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8395 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8396 | v_S7_t snr,rssi; |
| 8397 | int status, i, j, filled = 0; |
| 8398 | |
| 8399 | ENTER(); |
| 8400 | |
| 8401 | |
| 8402 | if (NULL == pAdapter) |
| 8403 | { |
| 8404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8405 | "%s: HDD adapter is Null", __func__); |
| 8406 | return -ENODEV; |
| 8407 | } |
| 8408 | |
| 8409 | if (NULL == wiphy) |
| 8410 | { |
| 8411 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8412 | "%s: wiphy is Null", __func__); |
| 8413 | return -ENODEV; |
| 8414 | } |
| 8415 | |
| 8416 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8417 | status = wlan_hdd_validate_context(pHddCtx); |
| 8418 | |
| 8419 | if (0 != status) |
| 8420 | { |
| 8421 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8422 | "%s: HDD context is not valid", __func__); |
| 8423 | return status; |
| 8424 | } |
| 8425 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8426 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8427 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8428 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 8429 | 0 != pAdapter->survey_idx || |
| 8430 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8431 | { |
| 8432 | /* The survey dump ops when implemented completely is expected to |
| 8433 | * return a survey of all channels and the ops is called by the |
| 8434 | * kernel with incremental values of the argument 'idx' till it |
| 8435 | * returns -ENONET. But we can only support the survey for the |
| 8436 | * operating channel for now. survey_idx is used to track |
| 8437 | * that the ops is called only once and then return -ENONET for |
| 8438 | * the next iteration |
| 8439 | */ |
| 8440 | pAdapter->survey_idx = 0; |
| 8441 | return -ENONET; |
| 8442 | } |
| 8443 | |
| 8444 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8445 | |
| 8446 | wlan_hdd_get_snr(pAdapter, &snr); |
| 8447 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 8448 | |
| 8449 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 8450 | hdd_wlan_get_freq(channel, &freq); |
| 8451 | |
| 8452 | |
| 8453 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 8454 | { |
| 8455 | if (NULL == wiphy->bands[i]) |
| 8456 | { |
| 8457 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 8458 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 8459 | continue; |
| 8460 | } |
| 8461 | |
| 8462 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 8463 | { |
| 8464 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 8465 | |
| 8466 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 8467 | { |
| 8468 | survey->channel = &band->channels[j]; |
| 8469 | /* The Rx BDs contain SNR values in dB for the received frames |
| 8470 | * while the supplicant expects noise. So we calculate and |
| 8471 | * return the value of noise (dBm) |
| 8472 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 8473 | */ |
| 8474 | survey->noise = rssi - snr; |
| 8475 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 8476 | filled = 1; |
| 8477 | } |
| 8478 | } |
| 8479 | } |
| 8480 | |
| 8481 | if (filled) |
| 8482 | pAdapter->survey_idx = 1; |
| 8483 | else |
| 8484 | { |
| 8485 | pAdapter->survey_idx = 0; |
| 8486 | return -ENONET; |
| 8487 | } |
| 8488 | |
| 8489 | return 0; |
| 8490 | } |
| 8491 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8492 | /* |
| 8493 | * FUNCTION: wlan_hdd_cfg80211_resume_wlan |
| 8494 | * this is called when cfg80211 driver resume |
| 8495 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 8496 | */ |
| 8497 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 8498 | { |
| 8499 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8500 | hdd_adapter_t *pAdapter; |
| 8501 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 8502 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 8503 | |
| 8504 | ENTER(); |
| 8505 | |
| 8506 | if ( NULL == pHddCtx ) |
| 8507 | { |
| 8508 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8509 | "%s: HddCtx validation failed", __func__); |
| 8510 | return 0; |
| 8511 | } |
| 8512 | |
| 8513 | if (pHddCtx->isLogpInProgress) |
| 8514 | { |
| 8515 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8516 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8517 | return 0; |
| 8518 | } |
| 8519 | |
| 8520 | if (pHddCtx->isLoadUnloadInProgress) |
| 8521 | { |
| 8522 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8523 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 8524 | return 0; |
| 8525 | } |
| 8526 | |
| 8527 | spin_lock(&pHddCtx->schedScan_lock); |
| 8528 | pHddCtx->isWiphySuspended = FALSE; |
| 8529 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 8530 | { |
| 8531 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8532 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8533 | "%s: Return resume is not due to PNO indication", __func__); |
| 8534 | return 0; |
| 8535 | } |
| 8536 | // Reset flag to avoid updatating cfg80211 data old results again |
| 8537 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 8538 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8539 | |
| 8540 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8541 | |
| 8542 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 8543 | { |
| 8544 | pAdapter = pAdapterNode->pAdapter; |
| 8545 | if ( (NULL != pAdapter) && |
| 8546 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 8547 | { |
| 8548 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
| 8549 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 8550 | "%s: NO SCAN result", __func__); |
| 8551 | else |
| 8552 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
| 8553 | |
| 8554 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8555 | "%s : cfg80211 scan result database updated", __func__); |
| 8556 | |
| 8557 | return 0; |
| 8558 | |
| 8559 | } |
| 8560 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8561 | pAdapterNode = pNext; |
| 8562 | } |
| 8563 | |
| 8564 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8565 | "%s: Failed to find Adapter", __func__); |
| 8566 | return 0; |
| 8567 | } |
| 8568 | |
| 8569 | /* |
| 8570 | * FUNCTION: wlan_hdd_cfg80211_suspend_wlan |
| 8571 | * this is called when cfg80211 driver suspends |
| 8572 | */ |
| 8573 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 8574 | struct cfg80211_wowlan *wow) |
| 8575 | { |
| 8576 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 8577 | |
| 8578 | ENTER(); |
| 8579 | if (NULL == pHddCtx) |
| 8580 | { |
| 8581 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8582 | "%s: HddCtx validation failed", __func__); |
| 8583 | return 0; |
| 8584 | } |
| 8585 | |
| 8586 | pHddCtx->isWiphySuspended = TRUE; |
| 8587 | |
| 8588 | EXIT(); |
| 8589 | |
| 8590 | return 0; |
| 8591 | } |
| 8592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8593 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8594 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8595 | { |
| 8596 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 8597 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 8598 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 8599 | .change_station = wlan_hdd_change_station, |
| 8600 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 8601 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 8602 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 8603 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8604 | #else |
| 8605 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 8606 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 8607 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8608 | #endif |
| 8609 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 8610 | .add_key = wlan_hdd_cfg80211_add_key, |
| 8611 | .get_key = wlan_hdd_cfg80211_get_key, |
| 8612 | .del_key = wlan_hdd_cfg80211_del_key, |
| 8613 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8614 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8615 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 8616 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8617 | .scan = wlan_hdd_cfg80211_scan, |
| 8618 | .connect = wlan_hdd_cfg80211_connect, |
| 8619 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 8620 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 8621 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 8622 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 8623 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 8624 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8625 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 8626 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 8627 | .mgmt_tx = wlan_hdd_action, |
| 8628 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 8629 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 8630 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 8631 | .set_txq_params = wlan_hdd_set_txq_params, |
| 8632 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8633 | .get_station = wlan_hdd_cfg80211_get_station, |
| 8634 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 8635 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8636 | .add_station = wlan_hdd_cfg80211_add_station, |
| 8637 | #ifdef FEATURE_WLAN_LFR |
| 8638 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 8639 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 8640 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 8641 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8642 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 8643 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 8644 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8645 | #ifdef FEATURE_WLAN_TDLS |
| 8646 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 8647 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 8648 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8649 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8650 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 8651 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8652 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8653 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 8654 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 8655 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8656 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 8657 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8658 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 8659 | #ifdef WLAN_NL80211_TESTMODE |
| 8660 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 8661 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8662 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8663 | }; |
| 8664 | |